More cleaning, fixing up interactions

This commit is contained in:
ZioPao
2024-01-08 22:40:15 +01:00
parent d3722c1171
commit 06e41790ca
9 changed files with 110 additions and 167 deletions

View File

@@ -7,7 +7,6 @@ local CommonMethods = require("TOC/CommonMethods")
local ItemsController = {} local ItemsController = {}
--* Player Methods *-- --* Player Methods *--
---@class ItemsController.Player ---@class ItemsController.Player
ItemsController.Player = {} ItemsController.Player = {}

View File

@@ -215,7 +215,6 @@ function LocalPlayerController.UpdateAmputations()
end end
local pl = LocalPlayerController.playerObj local pl = LocalPlayerController.playerObj
local bd = pl:getBodyDamage()
local visual = pl:getHumanVisual() local visual = pl:getHumanVisual()
local amputatedLimbs = CachedDataHandler.GetAmputatedLimbs(pl:getUsername()) local amputatedLimbs = CachedDataHandler.GetAmputatedLimbs(pl:getUsername())
local needsUpdate = false local needsUpdate = false
@@ -227,26 +226,16 @@ function LocalPlayerController.UpdateAmputations()
if not isCicatrized then if not isCicatrized then
needsUpdate = true needsUpdate = true
local cicTime = dcInst:getCicatrizationTime(limbName) local cicTime = dcInst:getCicatrizationTime(limbName)
TOC_DEBUG.print("updating cicatrization for " .. tostring(limbName)) TOC_DEBUG.print("Updating cicatrization for " .. tostring(limbName))
-- TODO Check if bandaged, sutured, whatever --* Dirtyness of the wound
-- TODO Clean
-- TODO Check dirtyness of zone and add to it
--local bptEnum = StaticData.BODYLOCS_IND_BPT[limbName] -- We need to get the BloodBodyPartType to find out how dirty the zone is
-- TODO Workaround
local bbptEnum = BloodBodyPartType[limbName] local bbptEnum = BloodBodyPartType[limbName]
--local bodyPart = bd:getBodyPart(bptEnum)
local modifier = 0.01 * SandboxVars.TOC.WoundDirtynessMultiplier local modifier = 0.01 * SandboxVars.TOC.WoundDirtynessMultiplier
--------------
-- TEST SECTION
local dirtynessVis = visual:getDirt(bbptEnum) + visual:getBlood(bbptEnum) local dirtynessVis = visual:getDirt(bbptEnum) + visual:getBlood(bbptEnum)
local dirtynessWound = dcInst:getWoundDirtyness(limbName) + modifier local dirtynessWound = dcInst:getWoundDirtyness(limbName) + modifier
--------------
local dirtyness = dirtynessVis + dirtynessWound local dirtyness = dirtynessVis + dirtynessWound
@@ -255,12 +244,17 @@ function LocalPlayerController.UpdateAmputations()
end end
dcInst:setWoundDirtyness(limbName, dirtyness) dcInst:setWoundDirtyness(limbName, dirtyness)
TOC_DEBUG.print("Dirtyness for this zone: " .. tostring(dirtyness))
--* Cicatrization
local cicDec = SandboxVars.TOC.CicatrizationSpeed - dirtyness
if cicDec <= 0 then cicDec = 0.1 end
cicTime = cicTime - cicDec
TOC_DEBUG.print("dirtyness for this zone: " .. tostring(dirtyness))
cicTime = cicTime - SandboxVars.TOC.CicatrizationSpeed
dcInst:setCicatrizationTime(limbName, cicTime) dcInst:setCicatrizationTime(limbName, cicTime)
TOC_DEBUG.print("new cicatrization time: " .. tostring(cicTime)) TOC_DEBUG.print("New cicatrization time: " .. tostring(cicTime))
if cicTime <= 0 then if cicTime <= 0 then
TOC_DEBUG.print(tostring(limbName) .. " is cicatrized") TOC_DEBUG.print(tostring(limbName) .. " is cicatrized")
dcInst:setIsCicatrized(limbName, true) dcInst:setIsCicatrized(limbName, true)

View File

@@ -1,5 +1,6 @@
local StaticData = require("TOC/StaticData")
local DataController = require("TOC/Controllers/DataController") local DataController = require("TOC/Controllers/DataController")
local StaticData = require("TOC/StaticData")
local CommonMethods = require("TOC/CommonMethods") local CommonMethods = require("TOC/CommonMethods")
--------------------------- ---------------------------
@@ -23,7 +24,6 @@ function CachedDataHandler.CalculateAmputatedLimbs(username)
CachedDataHandler.amputatedLimbs[username] = {} CachedDataHandler.amputatedLimbs[username] = {}
local dcInst = DataController.GetInstance(username) local dcInst = DataController.GetInstance(username)
-- TODO If the data hasn't arrived, this won't work
for i=1, #StaticData.LIMBS_STR do for i=1, #StaticData.LIMBS_STR do
local limbName = StaticData.LIMBS_STR[i] local limbName = StaticData.LIMBS_STR[i]
if dcInst:getIsCut(limbName) then if dcInst:getIsCut(limbName) then

View File

@@ -22,17 +22,9 @@ end
---@param item InventoryItem ---@param item InventoryItem
---@return string ---@return string
function ProsthesisHandler.GetGroup(item) function ProsthesisHandler.GetGroup(item)
local bodyLocation = item:getBodyLocation() local bodyLocation = item:getBodyLocation()
local side = CommonMethods.GetSide(bodyLocation) local side = CommonMethods.GetSide(bodyLocation)
local index local index = bodyLocation:contains(bodyLocArmProst) and "Top_" .. side or "Bottom_" .. side
if bodyLocation:contains(bodyLocArmProst) then
index = "Top_" .. side
else
index = "Bottom_" .. side
end
local group = StaticData.PROSTHESES_GROUPS_IND_STR[index] local group = StaticData.PROSTHESES_GROUPS_IND_STR[index]
return group return group
end end
@@ -41,15 +33,15 @@ end
---@param bodyLocation string ---@param bodyLocation string
---@return boolean ---@return boolean
function ProsthesisHandler.CheckIfEquippable(bodyLocation) function ProsthesisHandler.CheckIfEquippable(bodyLocation)
TOC_DEBUG.print("current item is a prosthesis") TOC_DEBUG.print("Current item is a prosthesis")
local side = CommonMethods.GetSide(bodyLocation) local side = CommonMethods.GetSide(bodyLocation)
TOC_DEBUG.print("checking side: " .. tostring(side)) TOC_DEBUG.print("Checking side: " .. tostring(side))
local amputatedLimbs = CachedDataHandler.GetAmputatedLimbs(getPlayer():getUsername()) local amputatedLimbs = CachedDataHandler.GetAmputatedLimbs(getPlayer():getUsername())
for k, _ in pairs(amputatedLimbs) do for k, _ in pairs(amputatedLimbs) do
local limbName = k local limbName = k
if string.contains(limbName, side) and not string.contains(limbName, "UpperArm") then if string.contains(limbName, side) and not string.contains(limbName, "UpperArm") then
TOC_DEBUG.print("found acceptable limb to use prosthesis") TOC_DEBUG.print("Found acceptable limb to use prosthesis")
return true return true
end end
end end
@@ -66,20 +58,12 @@ function ProsthesisHandler.SearchAndSetupProsthesis(item, isEquipping)
if not ProsthesisHandler.CheckIfProst(item) then return end if not ProsthesisHandler.CheckIfProst(item) then return end
local group = ProsthesisHandler.GetGroup(item) local group = ProsthesisHandler.GetGroup(item)
TOC_DEBUG.print("applying prosthesis stuff for " .. group) TOC_DEBUG.print("Applying prosthesis stuff for " .. group)
local dcInst = DataController.GetInstance() local dcInst = DataController.GetInstance()
dcInst:setIsProstEquipped(group, isEquipping) dcInst:setIsProstEquipped(group, isEquipping)
dcInst:apply() dcInst:apply()
end end
-------------------------
--* Events *--
------------------------- -------------------------
--* Overrides *-- --* Overrides *--
@@ -136,7 +120,6 @@ function ISClothingExtraAction:isValid()
return isEquippable return isEquippable
end end
local og_ISClothingExtraAction_perform = ISClothingExtraAction.perform local og_ISClothingExtraAction_perform = ISClothingExtraAction.perform
function ISClothingExtraAction:perform() function ISClothingExtraAction:perform()
og_ISClothingExtraAction_perform(self) og_ISClothingExtraAction_perform(self)
@@ -150,5 +133,4 @@ function ISUnequipAction:perform()
end end
return ProsthesisHandler return ProsthesisHandler

View File

@@ -1,44 +0,0 @@
local DataController = require("TOC/Controllers/DataController")
---@class SurgeryHandler
---@field type string
---@field limbName string
local SurgeryHandler = {}
function SurgeryHandler:new(type, limbName)
local o = {}
setmetatable(o, self)
self.__index = self
-- TODO use getjob for this
o.type = type
o.limbName = limbName
return o
end
-- TODO Should we consider stitching as "operating?"
function SurgeryHandler:execute()
if self.type == "needle" then
-- TODO
end
if self.type == "oven" then
DataController.GetInstance():setIsCauterized(self.limbName, true)
end
end
-- Cauterize
-- Needle and stitching (scrap surgery kits and crap like that)
return SurgeryHandler

View File

@@ -1,10 +1,41 @@
local DataController = require("TOC/Controllers/DataController") local DataController = require("TOC/Controllers/DataController")
local CommonMethods = require("TOC/CommonMethods") local CommonMethods = require("TOC/CommonMethods")
---- --------------------
---@class CleanWoundAction : ISBaseTimedAction ---@class CleanWoundAction : ISBaseTimedAction
---@field doctor IsoPlayer
---@field otherPlayer IsoPlayer
---@field bandage InventoryItem
---@field bodyPart any
local CleanWoundAction = ISBaseTimedAction:derive("CleanWoundAction") local CleanWoundAction = ISBaseTimedAction:derive("CleanWoundAction")
---@param doctor IsoPlayer
---@param otherPlayer IsoPlayer
---@param bandage InventoryItem
---@param bodyPart any
---@return CleanWoundAction
function CleanWoundAction:new(doctor, otherPlayer, bandage, bodyPart)
local o = {}
setmetatable(o, self)
self.__index = self
o.character = doctor
o.otherPlayer = otherPlayer
o.doctorLevel = doctor:getPerkLevel(Perks.Doctor)
o.bodyPart = bodyPart
o.bandage = bandage
o.stopOnWalk = true
o.stopOnRun = true
o.bandagedPlayerX = otherPlayer:getX()
o.bandagedPlayerY = otherPlayer:getY()
o.maxTime = 250 - (o.doctorLevel * 6)
if doctor:isTimedActionInstant() then
o.maxTime = 1
end
if doctor:getAccessLevel() ~= "None" then
o.doctorLevel = 10
end
return o
end
function CleanWoundAction:isValid() function CleanWoundAction:isValid()
if ISHealthPanel.DidPatientMove(self.character, self.otherPlayer, self.bandagedPlayerX, self.bandagedPlayerY) then if ISHealthPanel.DidPatientMove(self.character, self.otherPlayer, self.bandagedPlayerX, self.bandagedPlayerY) then
return false return false
@@ -52,26 +83,24 @@ function CleanWoundAction:perform()
ISBaseTimedAction.perform(self) ISBaseTimedAction.perform(self)
if self.character:HasTrait("Hemophobic") then if self.character:HasTrait("Hemophobic") then
self.character:getStats():setPanic(self.character:getStats():getPanic() + 50) self.character:getStats():setPanic(self.character:getStats():getPanic() + 15)
end end
self.character:getXp():AddXP(Perks.Doctor, 10) self.character:getXp():AddXP(Perks.Doctor, 10)
local addPain = (60 - (self.doctorLevel * 1)) local addPain = (60 - (self.doctorLevel * 1))
self.bodyPart:setAdditionalPain(self.bodyPart:getAdditionalPain() + addPain) self.bodyPart:setAdditionalPain(self.bodyPart:getAdditionalPain() + addPain)
--self.bodyPart:setNeedBurnWash(false)
self.bandage:Use() self.bandage:Use()
-- TODO Use Water too
if isClient() then
--sendCleanBurn(self.character, self.otherPlayer, self.bodyPart, self.bandage)
end
local limbName = CommonMethods.GetLimbNameFromBodyPart(self.bodyPart) local limbName = CommonMethods.GetLimbNameFromBodyPart(self.bodyPart)
-- TODO CHeck if correct in MP -- TODO CHeck if correct in MP
local dcInst = DataController.GetInstance(self.otherPlayer:getUsername()) local dcInst = DataController.GetInstance(self.otherPlayer:getUsername())
dcInst:setWoundDirtyness(limbName, 0)
local currentWoundDirtyness = dcInst:getWoundDirtyness(limbName)
local newWoundDirtyness = currentWoundDirtyness - (self.bandage:getBandagePower() * 10)
if newWoundDirtyness < 0 then newWoundDirtyness = 0 end
dcInst:setWoundDirtyness(limbName, newWoundDirtyness)
-- Clean visual -- Clean visual
@@ -85,29 +114,4 @@ function CleanWoundAction:perform()
ISHealthPanel.setBodyPartActionForPlayer(self.otherPlayer, self.bodyPart, nil, nil, nil) ISHealthPanel.setBodyPartActionForPlayer(self.otherPlayer, self.bodyPart, nil, nil, nil)
end end
---@return CleanWoundAction
function CleanWoundAction:new(doctor, otherPlayer, bandage, bodyPart)
local o = {}
setmetatable(o, self)
self.__index = self
o.character = doctor
o.otherPlayer = otherPlayer
o.doctorLevel = doctor:getPerkLevel(Perks.Doctor)
o.bodyPart = bodyPart
o.bandage = bandage
o.stopOnWalk = true
o.stopOnRun = true
o.bandagedPlayerX = otherPlayer:getX()
o.bandagedPlayerY = otherPlayer:getY()
o.maxTime = 250 - (o.doctorLevel * 6)
if doctor:isTimedActionInstant() then
o.maxTime = 1
end
if doctor:getAccessLevel() ~= "None" then
o.doctorLevel = 10
end
return o
end
return CleanWoundAction return CleanWoundAction

View File

@@ -2,8 +2,8 @@ local StaticData = require("TOC/StaticData")
local DataController = require("TOC/Controllers/DataController") local DataController = require("TOC/Controllers/DataController")
local CachedDataHandler = require("TOC/Handlers/CachedDataHandler") local CachedDataHandler = require("TOC/Handlers/CachedDataHandler")
local CutLimbHandler = require("TOC/UI/Interactions/CutLimbHandler") local CutLimbInteractionHandler = require("TOC/UI/Interactions/CutLimbInteractionHandler")
local WoundCleaningHandler = require("TOC/UI/Interactions/WoundCleaningHandler") local WoundCleaningInteractionHandler = require("TOC/UI/Interactions/WoundCleaningInteractionHandler")
------------------------ ------------------------
@@ -30,11 +30,14 @@ function ISHealthPanel:dropItemsOnBodyPart(bodyPart, items)
og_ISHealthPanel_dropItemsOnBodyPart(self, bodyPart, items) og_ISHealthPanel_dropItemsOnBodyPart(self, bodyPart, items)
TOC_DEBUG.print("override to dropItemsOnBodyPart running") TOC_DEBUG.print("override to dropItemsOnBodyPart running")
local cutLimbHandler = CutLimbHandler:new(self, bodyPart) local cutLimbInteraction = CutLimbInteractionHandler:new(self, bodyPart)
local woundCleaningInteraction = WoundCleaningInteractionHandler:new(self, bodyPart, self.character:getUsername())
for _,item in ipairs(items) do for _,item in ipairs(items) do
cutLimbHandler:checkItem(item) cutLimbInteraction:checkItem(item)
woundCleaningInteraction:checkItem(item)
end end
if cutLimbHandler:dropItems(items) then if cutLimbInteraction:dropItems(items) or woundCleaningInteraction:dropItems(items) then
return return
end end
@@ -48,13 +51,13 @@ function ISHealthPanel:doBodyPartContextMenu(bodyPart, x, y)
-- To not recreate it but reuse the one that has been created in the original method -- To not recreate it but reuse the one that has been created in the original method
local context = getPlayerContextMenu(playerNum) local context = getPlayerContextMenu(playerNum)
local cutLimbHandler = CutLimbHandler:new(self, bodyPart) local cutLimbInteraction = CutLimbInteractionHandler:new(self, bodyPart)
self:checkItems({cutLimbHandler}) self:checkItems({cutLimbInteraction})
cutLimbHandler:addToMenu(context) cutLimbInteraction:addToMenu(context)
local woundCleaningHandler = WoundCleaningHandler:new(self, bodyPart, self.character:getUsername()) local woundCleaningInteraction = WoundCleaningInteractionHandler:new(self, bodyPart, self.character:getUsername())
self:checkItems({woundCleaningHandler}) self:checkItems({woundCleaningInteraction})
woundCleaningHandler:addToMenu(context) woundCleaningInteraction:addToMenu(context)
end end

View File

@@ -142,31 +142,30 @@ Events.OnFillInventoryObjectContextMenu.Add(AddInventoryAmputationMenu)
------------------------------------- -------------------------------------
---@class CutLimbHandler : BaseHandler ---@class CutLimbInteractionHandler : BaseHandler
---@field items table ---@field items table
---@field limbName string ---@field limbName string
---@field itemType string temporary ---@field itemType string temporary
local CutLimbHandler = BaseHandler:derive("CutLimbHandler") local CutLimbInteractionHandler = BaseHandler:derive("CutLimbInteractionHandler")
---Creates new CutLimbHandler ---Creates new CutLimbInteractionHandler
---@param panel ISUIElement ---@param panel ISUIElement
---@param bodyPart BodyPart ---@param bodyPart BodyPart
---@return CutLimbHandler ---@return CutLimbInteractionHandler
function CutLimbHandler:new(panel, bodyPart) function CutLimbInteractionHandler:new(panel, bodyPart)
local o = BaseHandler.new(self, panel, bodyPart) local o = BaseHandler.new(self, panel, bodyPart)
o.items.ITEMS = {} o.items.ITEMS = {}
o.limbName = BodyPartType.ToString(bodyPart:getType()) o.limbName = BodyPartType.ToString(bodyPart:getType())
o.itemType = "Saw" o.itemType = "Saw"
TOC_DEBUG.print("init CutLimbHandler") --TOC_DEBUG.print("init CutLimbInteractionHandler")
return o return o
end end
---@param item InventoryItem ---@param item InventoryItem
function CutLimbHandler:checkItem(item) function CutLimbInteractionHandler:checkItem(item)
TOC_DEBUG.print("CutLimbHandler checkItem") --TOC_DEBUG.print("CutLimbInteractionHandler checkItem")
local itemType = item:getType() local itemType = item:getType()
--TOC_DEBUG.print("checkItem: " .. tostring(itemType))
if CheckIfSaw(itemType) then if CheckIfSaw(itemType) then
TOC_DEBUG.print("added to list -> " .. itemType) TOC_DEBUG.print("added to list -> " .. itemType)
@@ -175,8 +174,8 @@ function CutLimbHandler:checkItem(item)
end end
---@param context ISContextMenu ---@param context ISContextMenu
function CutLimbHandler:addToMenu(context) function CutLimbInteractionHandler:addToMenu(context)
TOC_DEBUG.print("CutLimbHandler addToMenu") --TOC_DEBUG.print("CutLimbInteractionHandler addToMenu")
local types = self:getAllItemTypes(self.items.ITEMS) local types = self:getAllItemTypes(self.items.ITEMS)
if #types > 0 and StaticData.BODYLOCS_IND_BPT[self.limbName] and not DataController.GetInstance():getIsCut(self.limbName) then if #types > 0 and StaticData.BODYLOCS_IND_BPT[self.limbName] and not DataController.GetInstance():getIsCut(self.limbName) then
TOC_DEBUG.print("addToMenu, types > 0") TOC_DEBUG.print("addToMenu, types > 0")
@@ -186,7 +185,7 @@ function CutLimbHandler:addToMenu(context)
end end
end end
function CutLimbHandler:dropItems(items) function CutLimbInteractionHandler:dropItems(items)
local types = self:getAllItemTypes(items) local types = self:getAllItemTypes(items)
if #self.items.ITEMS > 0 and #types == 1 and StaticData.BODYLOCS_IND_BPT[self.limbName] then if #self.items.ITEMS > 0 and #types == 1 and StaticData.BODYLOCS_IND_BPT[self.limbName] then
self:onMenuOptionSelected(types[1]) self:onMenuOptionSelected(types[1])
@@ -195,20 +194,20 @@ function CutLimbHandler:dropItems(items)
return false return false
end end
---Check if CutLimbHandler is valid, the limb must not be cut to be valid ---Check if CutLimbInteractionHandler is valid, the limb must not be cut to be valid
---@return boolean ---@return boolean
function CutLimbHandler:isValid() function CutLimbInteractionHandler:isValid()
TOC_DEBUG.print("CutLimbHandler isValid") --TOC_DEBUG.print("CutLimbInteractionHandler isValid")
self:checkItems() self:checkItems()
return not DataController.GetInstance():getIsCut(self.limbName) return not DataController.GetInstance():getIsCut(self.limbName)
end end
function CutLimbHandler:perform(previousAction, itemType) function CutLimbInteractionHandler:perform(previousAction, itemType)
local item = self:getItemOfType(self.items.ITEMS, itemType) local item = self:getItemOfType(self.items.ITEMS, itemType)
previousAction = self:toPlayerInventory(item, previousAction) previousAction = self:toPlayerInventory(item, previousAction)
TOC_DEBUG.print("perform CutLimbHandler on " .. self.limbName) TOC_DEBUG.print("Perform CutLimbInteractionHandler on " .. self.limbName)
local action = CutLimbAction:new(self:getDoctor(),self:getPatient(), self.limbName, item) local action = CutLimbAction:new(self:getDoctor(),self:getPatient(), self.limbName, item)
ISTimedActionQueue.addAfter(previousAction, action) ISTimedActionQueue.addAfter(previousAction, action)
end end
return CutLimbHandler return CutLimbInteractionHandler

View File

@@ -5,17 +5,16 @@ local DataController = require("TOC/Controllers/DataController")
local CleanWoundAction = require("TOC/TimedActions/CleanWoundAction") local CleanWoundAction = require("TOC/TimedActions/CleanWoundAction")
------------------------- -------------------------
---@class WoundCleaningHandler : BaseHandler ---@class WoundCleaningInteractionHandler : BaseHandler
---@field username string ---@field username string
---@field limbName string ---@field limbName string
local WoundCleaningHandler = BaseHandler:derive("WoundCleaningHandler") local WoundCleaningInteractionHandler = BaseHandler:derive("WoundCleaningInteractionHandler")
---comment
---@param panel any ---@param panel any
---@param bodyPart any ---@param bodyPart any
---@param username string ---@param username string
---@return table ---@return table
function WoundCleaningHandler:new(panel, bodyPart, username) function WoundCleaningInteractionHandler:new(panel, bodyPart, username)
local o = BaseHandler.new(self, panel, bodyPart) local o = BaseHandler.new(self, panel, bodyPart)
o.items.ITEMS = {} o.items.ITEMS = {}
o.username = username o.username = username
@@ -25,26 +24,32 @@ function WoundCleaningHandler:new(panel, bodyPart, username)
return o return o
end end
function WoundCleaningHandler:checkItem(item) function WoundCleaningInteractionHandler:checkItem(item)
if item:getBandagePower() >= 2 then -- Disinfected rag or bandage
--TOC_DEBUG.print("WoundCleaningInteractionHandler checkItem")
if item:getBandagePower() >=2 and item:isAlcoholic() then
--TOC_DEBUG.print("Adding " .. item:getName())
self:addItem(self.items.ITEMS, item) self:addItem(self.items.ITEMS, item)
end end
end end
function WoundCleaningHandler:addToMenu(context) function WoundCleaningInteractionHandler:addToMenu(context)
--TOC_DEBUG.print("WoundCleaningInteraction addToMenu")
local types = self:getAllItemTypes(self.items.ITEMS) local types = self:getAllItemTypes(self.items.ITEMS)
if #types > 0 and self:isValid() then if #types > 0 and self:isValid() then
local option = context:addOption("Clean Wound", nil) --TOC_DEBUG.print("WoundCleaningInteraction inside addToMenu")
local option = context:addOption(getText("ContextMenu_CleanWound"), nil)
local subMenu = context:getNew(context) local subMenu = context:getNew(context)
context:addSubMenu(option, subMenu) context:addSubMenu(option, subMenu)
for i=1,#types do for i=1, #types do
local item = self:getItemOfType(self.items.ITEMS, types[i]) local item = self:getItemOfType(self.items.ITEMS, types[i])
--TOC_DEBUG.print(item:getName())
subMenu:addOption(item:getName(), self, self.onMenuOptionSelected, item:getFullType()) subMenu:addOption(item:getName(), self, self.onMenuOptionSelected, item:getFullType())
end end
end end
end end
function WoundCleaningHandler:dropItems(items) function WoundCleaningInteractionHandler:dropItems(items)
local types = self:getAllItemTypes(items) local types = self:getAllItemTypes(items)
if #self.items.ITEMS > 0 and #types == 1 and self:isInjured() and self.bodyPart:isNeedBurnWash() then if #self.items.ITEMS > 0 and #types == 1 and self:isInjured() and self.bodyPart:isNeedBurnWash() then
-- FIXME: A bandage can be used to clean a burn or bandage it -- FIXME: A bandage can be used to clean a burn or bandage it
@@ -54,7 +59,7 @@ function WoundCleaningHandler:dropItems(items)
return false return false
end end
function WoundCleaningHandler:isValid() function WoundCleaningInteractionHandler:isValid()
-- TODO Check if cut and not cicatrized and dirty -- TODO Check if cut and not cicatrized and dirty
-- todo get username -- todo get username
@@ -63,12 +68,13 @@ function WoundCleaningHandler:isValid()
local dcInst = DataController.GetInstance(self.username) local dcInst = DataController.GetInstance(self.username)
--and dcInst:getWoundDirtyness(self.limbName) > 0.1 --and dcInst:getWoundDirtyness(self.limbName) > 0.1
local check = dcInst:getIsCut(self.limbName) and not dcInst:getIsCicatrized(self.limbName) and dcInst:getWoundDirtyness(self.limbName) > 0
return dcInst:getIsCut(self.limbName) and not dcInst:getIsCicatrized(self.limbName) --TOC_DEBUG.print("WoundCleaningInteraction isValid: " .. tostring(check))
return check
--return self:getItemOfType(self.items.ITEMS, itemType) --return self:getItemOfType(self.items.ITEMS, itemType)
end end
function WoundCleaningHandler:perform(previousAction, itemType) function WoundCleaningInteractionHandler:perform(previousAction, itemType)
local item = self:getItemOfType(self.items.ITEMS, itemType) local item = self:getItemOfType(self.items.ITEMS, itemType)
previousAction = self:toPlayerInventory(item, previousAction) previousAction = self:toPlayerInventory(item, previousAction)
local action = CleanWoundAction:new(self:getDoctor(), self:getPatient(), item, self.bodyPart) local action = CleanWoundAction:new(self:getDoctor(), self:getPatient(), item, self.bodyPart)
@@ -76,4 +82,4 @@ function WoundCleaningHandler:perform(previousAction, itemType)
end end
return WoundCleaningHandler return WoundCleaningInteractionHandler