Skip to content

Commit

Permalink
Update to better handle message content
Browse files Browse the repository at this point in the history
  • Loading branch information
mugmuggy committed Mar 21, 2019
1 parent cac0564 commit d3feed0
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 16 deletions.
22 changes: 14 additions & 8 deletions CorsixTH/Lua/entities/patient.lua
Expand Up @@ -1076,35 +1076,41 @@ end
]]
function Patient:updateMessage(choice)
if self.message and self.message.choices then
local message_choice
local enabled = false
if choice == "research" then

for _, c in ipairs(self.message.choices) do
if c.choice == choice then
message_choice = choice
end
end

if choice == "research" and message_choice == choice then
-- enable only if research department is built and a room in the treatment chain is undiscovered
local req = self.hospital:checkDiseaseRequirements(self.disease.id)
if req then
local strings = _S.fax.disease_discovered_patient_choice
enabled = self.hospital:hasRoomOfType("research") and self.hospital:hasStaffOfCategory("Researcher")
local output_text = strings.can_not_cure
if #req.rooms > 0 then
local room_name, _, staff_name = self.world:getRoomNameAndRequiredStaffName(req.rooms[#req.rooms])
if next(req.staff) then
if #req.rooms == 1 then
local room_name, required_staff, staff_name = self.world:getRoomNameAndRequiredStaffName(req.rooms[#req.rooms])
if req.staff[required_staff] or 0 > 0 then
output_text = strings.need_to_build_and_employ:format(room_name, staff_name)
else
output_text = strings.need_to_build:format(room_name)
end
elseif next(req.staff) then
elseif #req.rooms == 0 and next(req.staff) then
local staffclass_to_string = {
Nurse = _S.staff_title.nurse,
Doctor = _S.staff_title.doctor,
Surgeon = _S.staff_title.surgeon,
Psychiatrist = _S.staff_title.psychiatrist,
}
output_text = strings.need_to_employ:format(staffclass_to_string[next(req.staff)])
else
enabled = false
end
self.message[3].text = output_text
else
--no requirements
-- no requirements missing
enabled = false
end
else -- if choice == "guess_cure" then
Expand Down
23 changes: 15 additions & 8 deletions CorsixTH/Lua/humanoid_actions/seek_room.lua
Expand Up @@ -126,28 +126,35 @@ local function action_seek_room_no_treatment_room_found(room_type, humanoid)
end
-- Wait two months before going home anyway.
humanoid.waiting = 60
local strings = _S.fax.disease_discovered_patient_choice
-- Can this room be built right now? What is then missing?
local output_text = strings.can_not_cure
-- TODO: can we really assert this? Or should we just make the patient go home?
--local room = assert(humanoid.world.available_rooms[room_type], "room " .. room_type .. " not available")
local req = humanoid.hospital:checkDiseaseRequirements(humanoid.disease.id)
local research_enabled = false
if req then
local room_name, _, staff_name = humanoid.world:getRoomNameAndRequiredStaffName(room_type)
if #req.rooms > 0 then
if next(req.staff) then
local strings = _S.fax.disease_discovered_patient_choice
research_enabled = humanoid.hospital:hasRoomOfType("research") and humanoid.hospital:hasStaffOfCategory("Researcher")
if #req.rooms == 1 then
local room_name, required_staff, staff_name = humanoid.world:getRoomNameAndRequiredStaffName(req.rooms[1])
if req.staff[required_staff] or 0 > 0 then
output_text = strings.need_to_build_and_employ:format(room_name, staff_name)
else
output_text = strings.need_to_build:format(room_name)
end
else
output_text = strings.need_to_employ:format(staff_name)
elseif #req.rooms == 0 and next(req.staff) then
local staffclass_to_string = {
Nurse = _S.staff_title.nurse,
Doctor = _S.staff_title.doctor,
Surgeon = _S.staff_title.surgeon,
Psychiatrist = _S.staff_title.psychiatrist,
}
output_text = strings.need_to_employ:format(staffclass_to_string[next(req.staff)])
end
end
local research_enabled = humanoid.hospital:hasStaffOfCategory("Researcher") and humanoid.hospital:hasRoomOfType("research")
local message = {
{text = strings.disease_name:format(humanoid.disease.name)},
{text = " "},
Expand Down

0 comments on commit d3feed0

Please sign in to comment.