From 4f5d753104849b8da3e608a8ac454d83588b217d Mon Sep 17 00:00:00 2001 From: GregF Date: Sun, 3 Mar 2024 05:17:17 +0000 Subject: [PATCH] Ported Peksa from Java to Kotlin --- .../barbvillage/dialogue/PeksaDialogue.java | 82 ------------------- .../barbvillage/dialogue/PeksaDialogue.kt | 62 ++++++++++++++ 2 files changed, 62 insertions(+), 82 deletions(-) delete mode 100644 Server/src/main/content/region/misthalin/barbvillage/dialogue/PeksaDialogue.java create mode 100644 Server/src/main/content/region/misthalin/barbvillage/dialogue/PeksaDialogue.kt diff --git a/Server/src/main/content/region/misthalin/barbvillage/dialogue/PeksaDialogue.java b/Server/src/main/content/region/misthalin/barbvillage/dialogue/PeksaDialogue.java deleted file mode 100644 index 00779051a..000000000 --- a/Server/src/main/content/region/misthalin/barbvillage/dialogue/PeksaDialogue.java +++ /dev/null @@ -1,82 +0,0 @@ -package content.region.misthalin.barbvillage.dialogue; - -import core.game.dialogue.DialoguePlugin; -import core.game.dialogue.FacialExpression; -import core.game.node.entity.npc.NPC; -import core.plugin.Initializable; -import core.game.node.entity.player.Player; - -/** - * Represents the plugin used for peksa. - * @author 'Vexia - * @version 1.0 - */ -@Initializable -public final class PeksaDialogue extends DialoguePlugin { - - /** - * Constructs a new {@code PeksaDialogue} {@code Object}. - */ - public PeksaDialogue() { - /** - * empty. - */ - } - - /** - * Constructs a new {@code PeksaDialogue} {@code Object}. - * @param player the player. - */ - public PeksaDialogue(Player player) { - super(player); - } - - @Override - public DialoguePlugin newInstance(Player player) { - return new PeksaDialogue(player); - } - - @Override - public boolean open(Object... args) { - npc = (NPC) args[0]; - interpreter.sendDialogues(npc, FacialExpression.HALF_GUILTY, "Are you interested in buying or selling a helmet?"); - stage = 0; - return true; - } - - @Override - public boolean handle(int interfaceId, int buttonId) { - switch (stage) { - case 0: - interpreter.sendOptions("Select an Option", "I could be, yes.", "No, I'll pass on that."); - stage = 1; - break; - case 1: - switch (buttonId) { - case 1: - end(); - npc.openShop(player); - break; - case 2: - interpreter.sendDialogues(player, FacialExpression.HALF_GUILTY, "No, I'll pass on that."); - stage = 20; - break; - } - break; - case 20: - interpreter.sendDialogues(npc, FacialExpression.HALF_GUILTY, "Well, come back if you change your mind."); - stage = 21; - break; - case 21: - end(); - break; - } - - return true; - } - - @Override - public int[] getIds() { - return new int[] { 538 }; - } -} diff --git a/Server/src/main/content/region/misthalin/barbvillage/dialogue/PeksaDialogue.kt b/Server/src/main/content/region/misthalin/barbvillage/dialogue/PeksaDialogue.kt new file mode 100644 index 000000000..890d74eb9 --- /dev/null +++ b/Server/src/main/content/region/misthalin/barbvillage/dialogue/PeksaDialogue.kt @@ -0,0 +1,62 @@ +package content.region.misthalin.barbvillage.dialogue + +import core.api.getQuestStage +import core.api.openDialogue +import core.game.dialogue.DialoguePlugin +import core.game.dialogue.FacialExpression +import core.game.dialogue.IfTopic +import core.game.dialogue.Topic +import core.game.node.entity.npc.NPC +import core.game.node.entity.player.Player +import core.plugin.Initializable +import core.tools.END_DIALOGUE +import core.tools.START_DIALOGUE +import org.rs09.consts.NPCs + +@Initializable +class PeksaDialogue(player: Player? = null) : DialoguePlugin(player){ + + companion object { + const val GO_SHOPPING = 10 + const val LEAVE = 20 + const val DIALOGUE_SCORPION_CATCHER = 30 + } + + override fun open(vararg args: Any): Boolean { + npc = args[0] as NPC + npcl(FacialExpression.HALF_GUILTY, "Are you interested in buying or selling a helmet?").also { stage = START_DIALOGUE } + return true + } + + override fun handle(interfaceId: Int, buttonId: Int): Boolean { + when (stage) { + START_DIALOGUE -> { + showTopics( + Topic("I could be, yes.", GO_SHOPPING), + Topic("No, I'll pass on that.", LEAVE), + // todo get the quest state from Scorpion catcher to make this work + // IfTopic("Scorpion Stuff", SCORPION_CATCHER, getQuestStage(player, "Scorpion Catcher") == 50) + ) + } + + GO_SHOPPING -> { + end() + npc.openShop(player) + } + + LEAVE -> { + npcl(FacialExpression.HALF_GUILTY, "Well, come back if you change your mind.").also { stage = END_DIALOGUE } + } + + // DIALOGUE_SCORPION_CATCHER -> { + // openDialogue(player, PeksaDialogueSC(), npc) + // } + } + + return true + } + + override fun getIds(): IntArray { + return intArrayOf(NPCs.PEKSA_538) + } +} \ No newline at end of file