Class: CEML::WaitingRoom

Inherits:
Struct
  • Object
show all
Includes:
Redis::Objects
Defined in:
lib/ceml/models/waiting_room.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#idObject

Returns the value of attribute id

Returns:

  • (Object)

    the current value of id



3
4
5
# File 'lib/ceml/models/waiting_room.rb', line 3

def id
  @id
end

Instance Method Details

#audition_for_incidents(player) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/ceml/models/waiting_room.rb', line 8

def audition_for_incidents(player)
  reorder = waiting_incident_roles.members.sort_by{ |irs| irs.split(':')[1] }
  reorder.each do |key|
    incident_id, idx, role, count = *key.split(':')
    CEML.log 3, "#{player[:id]}: auditioning against #{incident_id}: #{role}"
    count = count.to_i
    role_slot = IncidentRoleSlot.new(incident_id, role, count)
    next unless role_slot.reserve_spot!
    waiting_incident_roles.delete(key) if role_slot.full?
    IncidentModel.new(role_slot.incident_id).add_castings({ role_slot.role => [ player ] })
    return role_slot.incident_id
  end
  return false
end

#list_job(incident_id, idx, rolename, count) ⇒ Object



23
24
25
# File 'lib/ceml/models/waiting_room.rb', line 23

def list_job(incident_id, idx, rolename, count)
  waiting_incident_roles << [incident_id, idx, rolename, count].join(':')
end