Page 1 of 1

logic error in code for fertile soil

Posted: Wed Sep 21, 2022 10:18 pm
by bushtail
So it's allowing me to fertilize the soil despite the patch being weedy. for some reason, the return does not actually return. Anyone spot anything?

Code: Select all

    private fun fertileSoil(player: Player, target: Scenery) {
        if (target.id == 7808) {
            sendMessage(player, "No, that would be silly.")
            return
        } else {
            val fPatch = FarmingPatch.forObject(target)
            if(fPatch == null) {
                sendMessage(player, "Um... I don't want to fertilize that! peepee poopoo")
                return
            } else {
                val patch = fPatch.getPatchFor(player)
                if(patch.isWeedy()) {
                    return
                } else if(patch.isFertilized()) {
                    sendMessage(player, "This patch has already been composted.")
                    return
                } else if(patch.isGrown()) {
                    sendMessage(player, "Composting isn't going to make it get any bigger.")
                    return
                } else {
                    visualizeSpell(player, FERTILE_SOIL_ANIM, FERTILE_SOIL_GFX, 2891)
                    patch.compost = CompostType.SUPER
                    sendMessage(player, "You fertilize the soil.")
                    addXP(player, 87.0)
                }
            }
        }
    }

Re: logic error in code for fertile soil

Posted: Wed Sep 21, 2022 10:20 pm
by Ceikry
You can fertilize a weedy patch anyways. I was just being sarcastic on discord.

Re: logic error in code for fertile soil

Posted: Wed Sep 21, 2022 10:22 pm
by bushtail
my knowledge of rs is extremely limited no booli