From 0a1918d9e4fb24a725d9eba6e14ac574c600397a Mon Sep 17 00:00:00 2001 From: Ceikry Date: Sun, 27 Jun 2021 21:50:07 +0000 Subject: [PATCH] Added NPC who sells fighter torso for 7.5M - Captain Cain --- .gitlab-ci.yml | 35 ++++++++++ .../game/content/dialogue/DialoguePlugin.java | 18 +++++ Server/src/main/kotlin/api/DialUtils.kt | 1 + .../content/dialogue/CaptainCainDialogue.kt | 67 +++++++++++++++++++ 4 files changed, 121 insertions(+) create mode 100644 .gitlab-ci.yml create mode 100644 Server/src/main/kotlin/rs09/game/content/dialogue/CaptainCainDialogue.kt diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml new file mode 100644 index 000000000..64251f0b3 --- /dev/null +++ b/.gitlab-ci.yml @@ -0,0 +1,35 @@ +# This file is a template, and might need editing before it works on your project. +# This is the Gradle build system for JVM applications +# https://gradle.org/ +# https://github.com/gradle/gradle +image: gradle:alpine + +# Disable the Gradle daemon for Continuous Integration servers as correctness +# is usually a priority over speed in CI environments. Using a fresh +# runtime for each build is more reliable since the runtime is completely +# isolated from any previous builds. +variables: + GRADLE_OPTS: "-Dorg.gradle.daemon=false" + +before_script: + - export GRADLE_USER_HOME=`pwd`/.gradle + +build: + stage: build + script: gradle --build-cache assemble + cache: + key: "$CI_COMMIT_REF_NAME" + policy: push + paths: + - build + - .gradle + +test: + stage: test + script: gradle check + cache: + key: "$CI_COMMIT_REF_NAME" + policy: pull + paths: + - build + - .gradle diff --git a/Server/src/main/java/core/game/content/dialogue/DialoguePlugin.java b/Server/src/main/java/core/game/content/dialogue/DialoguePlugin.java index 119bf38b9..962164acf 100644 --- a/Server/src/main/java/core/game/content/dialogue/DialoguePlugin.java +++ b/Server/src/main/java/core/game/content/dialogue/DialoguePlugin.java @@ -311,4 +311,22 @@ public abstract class DialoguePlugin implements Plugin { } } + /** + * Use the automatic linesplitting feature in DialUtils to produce npc dialogues + * @param expr the FacialExpression to use, located in the FacialExpression enum. + * @param msg the message for the NPC to say + */ + public Component npcl(FacialExpression expr, String msg){ + return npc(expr, api.DialUtils.splitLines(msg)); + } + + /** + * Use the automatic linesplitting feature in DialUtils to produce player dialogues + * @param expr the FacialExpression to use, located in the FacialExpression enum. + * @param msg the message for the player to say + */ + public Component playerl(FacialExpression expr, String msg){ + return player(expr, api.DialUtils.splitLines(msg)); + } + } \ No newline at end of file diff --git a/Server/src/main/kotlin/api/DialUtils.kt b/Server/src/main/kotlin/api/DialUtils.kt index 37f89c69e..a0db709e3 100644 --- a/Server/src/main/kotlin/api/DialUtils.kt +++ b/Server/src/main/kotlin/api/DialUtils.kt @@ -1,3 +1,4 @@ +package api import rs09.game.system.SystemLogger import java.util.* import kotlin.system.exitProcess diff --git a/Server/src/main/kotlin/rs09/game/content/dialogue/CaptainCainDialogue.kt b/Server/src/main/kotlin/rs09/game/content/dialogue/CaptainCainDialogue.kt new file mode 100644 index 000000000..f5de9b1fd --- /dev/null +++ b/Server/src/main/kotlin/rs09/game/content/dialogue/CaptainCainDialogue.kt @@ -0,0 +1,67 @@ +package rs09.game.content.dialogue + +import api.ContentAPI +import core.game.content.dialogue.DialoguePlugin +import core.game.content.dialogue.FacialExpression +import core.game.node.entity.player.Player +import core.game.node.item.Item +import core.plugin.Initializable +import org.rs09.consts.Items +import org.rs09.consts.NPCs +import rs09.tools.END_DIALOGUE +import java.text.SimpleDateFormat +import java.time.temporal.ChronoUnit +import java.util.* + +@Initializable +class CaptainCainDialogue(player: Player? = null) : DialoguePlugin(player) { + val sdf = SimpleDateFormat("ddMMyyyy") + override fun newInstance(player: Player?): DialoguePlugin { + return CaptainCainDialogue(player) + } + + override fun open(vararg args: Any?): Boolean { + npcl(FacialExpression.FRIENDLY, "Hello, there, adventurer. Say, you wouldn't happen to be interested in purchasing a Fighter Torso would you?") + stage = 0 + return true + } + + override fun handle(interfaceId: Int, buttonId: Int): Boolean { + val start = sdf.parse("27112020").toInstant() + val now = Date().toInstant() + val days = ChronoUnit.DAYS.between(start,now) + when(stage){ + 0 -> npcl(FacialExpression.ANNOYED,"I'm having to offer this service because it's been $days days since Ryan promised to give us barbarian assault.").also { stage++ } + 1 -> options("Yes, please.","No, thanks.").also { stage++ } + 2 -> when(buttonId){ + 1 -> playerl(FacialExpression.FRIENDLY, "Yes, please.").also { stage = 10 } + 2 -> playerl(FacialExpression.HALF_THINKING, "No, thanks.").also { stage = END_DIALOGUE } + } + + 10 -> npcl(FacialExpression.FRIENDLY, "Alright, then, that'll be 7,500,000 gold please.").also { stage++ } + 11 -> options("Here you go!","Nevermind.").also { stage++ } + 12 -> when(buttonId){ + 1 -> if(ContentAPI.inInventory(player, 995, 7500000)) + playerl(FacialExpression.FRIENDLY, "Here you go!").also { stage = 20 } + else + playerl(FacialExpression.HALF_GUILTY, "Actually, I don't have that much.").also { stage = END_DIALOGUE } + + 2 -> playerl(FacialExpression.FRIENDLY, "On second thought, nevermind.").also { stage = END_DIALOGUE } + } + + 20 -> { + npcl(FacialExpression.FRIENDLY, "Thank you much, kind sir. And here's your torso.") + if(ContentAPI.removeItem(player, Item(995,7500000), api.Container.INVENTORY)) { + ContentAPI.addItem(player, Items.FIGHTER_TORSO_10551, 1) + } + stage = END_DIALOGUE + } + } + return true + } + + override fun getIds(): IntArray { + return intArrayOf(NPCs.CAPTAIN_CAIN_5030) + } + +} \ No newline at end of file