From 65014f851383b0fa5bde3829599a479e9ef2a952 Mon Sep 17 00:00:00 2001 From: = Date: Thu, 25 Apr 2019 08:17:13 -0400 Subject: [PATCH 1/5] Add 'junk' fish --- .../src/org/apollo/game/plugin/skills/fishing/Fish.kt | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/game/plugin/skills/fishing/src/org/apollo/game/plugin/skills/fishing/Fish.kt b/game/plugin/skills/fishing/src/org/apollo/game/plugin/skills/fishing/Fish.kt index 45f76b826..7f921f87d 100644 --- a/game/plugin/skills/fishing/src/org/apollo/game/plugin/skills/fishing/Fish.kt +++ b/game/plugin/skills/fishing/src/org/apollo/game/plugin/skills/fishing/Fish.kt @@ -19,7 +19,14 @@ enum class Fish(val id: Int, val level: Int, val experience: Double, catchSuffix LOBSTER(id = 377, level = 40, experience = 90.0), BASS(id = 363, level = 46, experience = 100.0), SWORDFISH(id = 371, level = 50, experience = 100.0), - SHARK(id = 383, level = 76, experience = 110.0, catchSuffix = "a shark!"); + SHARK(id = 383, level = 76, experience = 110.0, catchSuffix = "a shark!"), + + /* + * Junk 'fish' + */ + SEAWEED(id = 401, level = 16, experience = 1.0), + CASKET(id = 405, level = 16, experience = 1.0) + ; /** * The name of this fish, formatted so it can be inserted into a message. From d1e8d9ce2aafa5dc42f495a13ae768c9f06850bc Mon Sep 17 00:00:00 2001 From: = Date: Thu, 25 Apr 2019 08:17:52 -0400 Subject: [PATCH 2/5] Add caskets and seaweed to big net fishing --- .../game/plugin/skills/fishing/FishingSpot.kt | 29 +++++++++++++++---- 1 file changed, 23 insertions(+), 6 deletions(-) diff --git a/game/plugin/skills/fishing/src/org/apollo/game/plugin/skills/fishing/FishingSpot.kt b/game/plugin/skills/fishing/src/org/apollo/game/plugin/skills/fishing/FishingSpot.kt index 380dd1a07..d48880f8b 100644 --- a/game/plugin/skills/fishing/src/org/apollo/game/plugin/skills/fishing/FishingSpot.kt +++ b/game/plugin/skills/fishing/src/org/apollo/game/plugin/skills/fishing/FishingSpot.kt @@ -22,7 +22,7 @@ enum class FishingSpot(val npc: Int, private val first: Option, private val seco NET_HARPOON( npc = 313, - first = Option.of(tool = FishingTool.BIG_NET, primary = MACKEREL, secondary = COD), + first = Option.of(tool = FishingTool.BIG_NET, primary = MACKEREL, secondary = COD, junk = arrayOf(SEAWEED, CASKET)), second = Option.of(tool = FishingTool.HARPOON, primary = BASS, secondary = SHARK) ), @@ -77,14 +77,19 @@ enum class FishingSpot(val npc: Int, private val first: Option, private val seco /** * A [FishingSpot] [Option] that can provide a two different types of fish. */ - private data class Pair(override val tool: FishingTool, val primary: Fish, val secondary: Fish) : Option() { + private class Pair(override val tool: FishingTool, val primary: Fish, val secondary: Fish, vararg val junk: Fish) : Option() { override val level = Math.min(primary.level, secondary.level) override fun sample(level: Int): Fish { - return if (level < secondary.level || rand(100) < WEIGHTING) { - primary - } else { - secondary + if (junk.isNotEmpty() && rand(100) < JUNK_WEIGHTING) { + val valid = junk.filter { level >= it.level } + if (valid.isNotEmpty()) { + return valid[rand(valid.size)] + } + } + return when { + level < secondary.level || rand(100) < WEIGHTING -> primary + else -> secondary } } @@ -93,6 +98,11 @@ enum class FishingSpot(val npc: Int, private val first: Option, private val seco * The weighting factor that causes the lower-level fish to be returned more frequently. */ private const val WEIGHTING = 70 + + /** + * The weighting factor that causes a junk item to be fished more frequently. + */ + private const val JUNK_WEIGHTING = 5 } } @@ -106,6 +116,13 @@ enum class FishingSpot(val npc: Int, private val first: Option, private val seco else -> Pair(tool, secondary, primary) } } + + fun of(tool: FishingTool, primary: Fish, secondary: Fish, junk: Array): Option { + return when { + primary.level < secondary.level -> Pair(tool, primary, secondary, *junk) + else -> Pair(tool, secondary, primary, *junk) + } + } } } From 6b50c96c918ed4fbf7f944544b4e8b662860d8fc Mon Sep 17 00:00:00 2001 From: = Date: Fri, 26 Apr 2019 13:17:41 -0400 Subject: [PATCH 3/5] Move semicolon --- .../fishing/src/org/apollo/game/plugin/skills/fishing/Fish.kt | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/game/plugin/skills/fishing/src/org/apollo/game/plugin/skills/fishing/Fish.kt b/game/plugin/skills/fishing/src/org/apollo/game/plugin/skills/fishing/Fish.kt index 7f921f87d..52db2d8b7 100644 --- a/game/plugin/skills/fishing/src/org/apollo/game/plugin/skills/fishing/Fish.kt +++ b/game/plugin/skills/fishing/src/org/apollo/game/plugin/skills/fishing/Fish.kt @@ -25,8 +25,7 @@ enum class Fish(val id: Int, val level: Int, val experience: Double, catchSuffix * Junk 'fish' */ SEAWEED(id = 401, level = 16, experience = 1.0), - CASKET(id = 405, level = 16, experience = 1.0) - ; + CASKET(id = 405, level = 16, experience = 1.0); /** * The name of this fish, formatted so it can be inserted into a message. From d88914c77bab939ab5ef76957c801c72ea5955bd Mon Sep 17 00:00:00 2001 From: = Date: Fri, 26 Apr 2019 13:19:38 -0400 Subject: [PATCH 4/5] Replace variadic value in Pair --- .../game/plugin/skills/fishing/FishingSpot.kt | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/game/plugin/skills/fishing/src/org/apollo/game/plugin/skills/fishing/FishingSpot.kt b/game/plugin/skills/fishing/src/org/apollo/game/plugin/skills/fishing/FishingSpot.kt index d48880f8b..049fbf1ca 100644 --- a/game/plugin/skills/fishing/src/org/apollo/game/plugin/skills/fishing/FishingSpot.kt +++ b/game/plugin/skills/fishing/src/org/apollo/game/plugin/skills/fishing/FishingSpot.kt @@ -77,7 +77,7 @@ enum class FishingSpot(val npc: Int, private val first: Option, private val seco /** * A [FishingSpot] [Option] that can provide a two different types of fish. */ - private class Pair(override val tool: FishingTool, val primary: Fish, val secondary: Fish, vararg val junk: Fish) : Option() { + private data class Pair(override val tool: FishingTool, val primary: Fish, val secondary: Fish, val junk: Array) : Option() { override val level = Math.min(primary.level, secondary.level) override fun sample(level: Int): Fish { @@ -111,16 +111,18 @@ enum class FishingSpot(val npc: Int, private val first: Option, private val seco fun of(tool: FishingTool, primary: Fish): Option = Single(tool, primary) fun of(tool: FishingTool, primary: Fish, secondary: Fish): Option { - return when { - primary.level < secondary.level -> Pair(tool, primary, secondary) - else -> Pair(tool, secondary, primary) + return if (primary.level < secondary.level) { + Pair(tool, primary, secondary, emptyArray()) + } else { + Pair(tool, secondary, primary, emptyArray()) } } fun of(tool: FishingTool, primary: Fish, secondary: Fish, junk: Array): Option { - return when { - primary.level < secondary.level -> Pair(tool, primary, secondary, *junk) - else -> Pair(tool, secondary, primary, *junk) + return if (primary.level < secondary.level) { + Pair(tool, primary, secondary, junk) + } else { + Pair(tool, secondary, primary, junk) } } } From 77b55d7934ac4f066f5803dd07be820fbf5e315e Mon Sep 17 00:00:00 2001 From: = Date: Fri, 26 Apr 2019 13:20:30 -0400 Subject: [PATCH 5/5] Replace `when` with `if` --- .../org/apollo/game/plugin/skills/fishing/FishingSpot.kt | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/game/plugin/skills/fishing/src/org/apollo/game/plugin/skills/fishing/FishingSpot.kt b/game/plugin/skills/fishing/src/org/apollo/game/plugin/skills/fishing/FishingSpot.kt index 049fbf1ca..5bbd5e4f9 100644 --- a/game/plugin/skills/fishing/src/org/apollo/game/plugin/skills/fishing/FishingSpot.kt +++ b/game/plugin/skills/fishing/src/org/apollo/game/plugin/skills/fishing/FishingSpot.kt @@ -87,9 +87,10 @@ enum class FishingSpot(val npc: Int, private val first: Option, private val seco return valid[rand(valid.size)] } } - return when { - level < secondary.level || rand(100) < WEIGHTING -> primary - else -> secondary + return if (level < secondary.level || rand(100) < WEIGHTING) { + primary + } else { + secondary } }