From 2a9f089ea105d470c61b85bfa94a188ab8fd7bd3 Mon Sep 17 00:00:00 2001 From: Ceikry Date: Mon, 8 Mar 2021 20:03:30 -0600 Subject: [PATCH] Implemented flower protection --- .../core/game/node/entity/skill/farming/Patch.kt | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/Server/src/main/java/Server/core/game/node/entity/skill/farming/Patch.kt b/Server/src/main/java/Server/core/game/node/entity/skill/farming/Patch.kt index afb3d6c2d..49333f646 100644 --- a/Server/src/main/java/Server/core/game/node/entity/skill/farming/Patch.kt +++ b/Server/src/main/java/Server/core/game/node/entity/skill/farming/Patch.kt @@ -127,7 +127,7 @@ class Patch(val player: Player, val patch: FarmingPatch, var plantable: Plantabl CompostType.SUPER -> 13 } - if(RandomFunction.random(128) <= (17 - diseaseMod) && !isWatered && !isGrown() && !protectionPaid){ + if(RandomFunction.random(128) <= (17 - diseaseMod) && !isWatered && !isGrown() && !protectionPaid && !isFlowerProtected()){ //bush, tree, fruit tree can not disease on stage 1(0) of growth. if(!((patch.type == PatchType.BUSH || patch.type == PatchType.TREE || patch.type == PatchType.FRUIT_TREE) && currentGrowthStage == 0)) { isDiseased = true @@ -181,4 +181,18 @@ class Patch(val player: Player, val patch: FarmingPatch, var plantable: Plantabl plantable ?: return 0 return getCurrentState() - plantable!!.value - plantable!!.stages } + + fun isFlowerProtected(): Boolean{ + if(patch.type != PatchType.ALLOTMENT) return false + + val fpatch = when(patch){ + FarmingPatch.S_FALADOR_ALLOTMENT_SE,FarmingPatch.S_FALADOR_ALLOTMENT_NW -> FarmingPatch.S_FALADOR_FLOWER_C + FarmingPatch.ARDOUGNE_ALLOTMENT_S,FarmingPatch.ARDOUGNE_ALLOTMENT_N -> FarmingPatch.ARDOUGNE_FLOWER_C + FarmingPatch.CATHERBY_ALLOTMENT_S,FarmingPatch.CATHERBY_ALLOTMENT_N -> FarmingPatch.CATHERBY_FLOWER_C + FarmingPatch.PORT_PHAS_ALLOTMENT_SE,FarmingPatch.PORT_PHAS_ALLOTMENT_NW -> FarmingPatch.PORT_PHAS_FLOWER_C + else -> return false + }.getPatchFor(player) + + return (fpatch.plantable != null && fpatch.plantable == plantable?.protectionFlower && fpatch.isGrown()) + } } \ No newline at end of file