~kalon33/corsix-th/master

« back to all changes in this revision

Viewing changes to CorsixTH/Lua/rooms/ward.lua

  • Committer: corsixth.bot at gmail
  • Date: 2014-03-31 23:30:23 UTC
  • Revision ID: svn-v4:c39591fa-788f-11de-a72b-d90af8dea425:trunk:2687
Remove trailing whitespaces in .h, .cpp, .c and .lua files.

Show diffs side-by-side

added added

removed removed

Lines of Context:
25
25
room.name = _S.rooms_short.ward
26
26
room.tooltip = _S.tooltip.rooms.ward
27
27
room.long_name = _S.rooms_long.ward
28
 
room.objects_additional = { 
29
 
  "extinguisher", 
30
 
  "radiator", 
31
 
  "plant", 
 
28
room.objects_additional = {
 
29
  "extinguisher",
 
30
  "radiator",
 
31
  "plant",
32
32
  "desk",
33
 
  "bin", 
 
33
  "bin",
34
34
  "bed" }
35
35
room.objects_needed = { desk = 1, bed = 1 }
36
36
room.build_preview_animation = 910
63
63
  for object, value in pairs(objects) do
64
64
    if object.object_type.id == "bed" then
65
65
      beds = beds + 1
66
 
    end  
 
66
    end
67
67
    if object.object_type.id == "desk" then
68
68
      desks = desks + 1
69
69
    end
70
70
  end
71
71
  self.maximum_staff = {
72
72
    Nurse = desks,
73
 
  } 
 
73
  }
74
74
  self.maximum_patients = beds
75
75
  if not self.hospital:hasStaffOfCategory("Nurse") then
76
76
    self.world.ui.adviser
92
92
function WardRoom:doStaffUseCycle(humanoid)
93
93
  local meander_time = math.random(4, 10)
94
94
  local desk_use_time = math.random(8, 16)
95
 
  
 
95
 
96
96
  humanoid:setNextAction{
97
97
    name = "meander",
98
98
    count = meander_time,
112
112
        self:doStaffUseCycle(humanoid)
113
113
      end
114
114
    end,
115
 
  }    
116
 
  end  
 
115
  }
 
116
  end
117
117
 
118
118
  end
119
119
  local num_meanders = math.random(2, 4)
125
125
        self:doStaffUseCycle(humanoid)
126
126
      end
127
127
    end
128
 
  }    
 
128
  }
129
129
end
130
130
 
131
131
 
142
142
  else
143
143
    bed.reserved_for = patient
144
144
    self:countWorkingNurses()
145
 
    local length = (math.random(200, 800) * (1.5 - staff.profile.skill))  / self.nursecount -- reduce time in ward if there is more than one nurse on duty 
146
 
    local --[[persistable:ward_loop_callback]] function loop_callback(action)  
147
 
    -- TODO Perhaps it should take longer if there are more used beds! 
 
145
    local length = (math.random(200, 800) * (1.5 - staff.profile.skill))  / self.nursecount -- reduce time in ward if there is more than one nurse on duty
 
146
    local --[[persistable:ward_loop_callback]] function loop_callback(action)
 
147
    -- TODO Perhaps it should take longer if there are more used beds!
148
148
      if length <= 0 then
149
149
        action.prolonged_usage = false
150
150
      end
151
151
      length = length - 1
152
 
    end    
 
152
    end
153
153
    local after_use = --[[persistable:ward_after_use]] function()
154
154
      self:dealtWithPatient(patient)
155
155
    end
156
156
    patient:walkTo(pat_x, pat_y)
157
157
    patient:queueAction{
158
 
      name = "use_object", 
 
158
      name = "use_object",
159
159
      object = bed,
160
160
      prolonged_usage = true,
161
161
      loop_callback = loop_callback,
179
179
    end
180
180
  end
181
181
  return staff
182
 
end 
 
182
end
183
183
 
184
184
function WardRoom:setStaffMember(staff)
185
185
  self.staff_member_set[staff] = true
186
186
end
187
187
 
188
188
function WardRoom:countWorkingNurses()
189
 
  local staff = next(self.staff_member_set) 
 
189
  local staff = next(self.staff_member_set)
190
190
  self.nursecount = 0
191
191
  for staff_member, _ in pairs(self.staff_member_set) do
192
192
    if staff then
193
193
      staff = staff_member
194
 
      self.nursecount = self.nursecount + 1   
195
 
    end  
196
 
  end 
 
194
      self.nursecount = self.nursecount + 1
 
195
    end
 
196
  end
197
197
end
198
198
 
199
199
function WardRoom:setStaffMembersAttribute(attribute, value)
200
200
  for staff_member, _ in pairs(self.staff_member_set) do
201
201
    staff_member[attribute] = value
202
202
  end
203
 
end 
 
203
end
204
204
 
205
205
function WardRoom:onHumanoidLeave(humanoid)
206
206
  self.staff_member_set[humanoid] = nil
218
218
    local flags = {}
219
219
 
220
220
    local function checkLocation(x, y)
221
 
      if self.world:getRoom(x, y) 
 
221
      if self.world:getRoom(x, y)
222
222
      or not map:getCellFlags(x, y, flags).passable then
223
223
        local message = "Warning: An update has resolved a problem concerning "
224
224
        .. "swing doors, but not all tiles adjacent to them could be fixed."
254
254
    self.staff_member_set = {}
255
255
    self.nursecount = 0
256
256
    -- reset any wards that already exist
257
 
    self:roomFinished()  
 
257
    self:roomFinished()
258
258
    -- if there is already a nurse in the ward
259
259
    -- make her leave so she gets counted properly
260
260
    local nurse = self.staff_member
261
 
    if nurse then 
 
261
    if nurse then
262
262
      nurse:setNextAction(self:createLeaveAction())
263
263
      nurse:queueAction({name = "meander"})
264
264
    end
265
 
  end  
 
265
  end
266
266
  Room.afterLoad(self, old, new)
267
267
end
268
268