-
Notifications
You must be signed in to change notification settings - Fork 141
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fishing Seaweed & Caskets #425
base: kotlin-experiments
Are you sure you want to change the base?
Conversation
Codecov Report
@@ Coverage Diff @@
## kotlin-experiments #425 +/- ##
========================================================
+ Coverage 23.23% 23.23% +<.01%
Complexity 811 811
========================================================
Files 643 643
Lines 11123 11132 +9
Branches 1632 1636 +4
========================================================
+ Hits 2584 2587 +3
- Misses 8251 8256 +5
- Partials 288 289 +1
Continue to review full report at Codecov.
|
*/ | ||
SEAWEED(id = 401, level = 16, experience = 1.0), | ||
CASKET(id = 405, level = 16, experience = 1.0) | ||
; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Move this semicolon back to the previous line.
@@ -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() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why did you remove the data
modifier?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's also no reason for junk
to be variadic. This constructor isn't a user facing API.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The data
modifier was removed as you can't have variadic values in a data
class. I'll fix this though, thanks!
@@ -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<Fish>): Option { | |||
return when { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Write this as if-else
instead
return valid[rand(valid.size)] | ||
} | ||
} | ||
return when { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be if-else
instead of when
.
Some style issues, otherwise LGTM |
override val level = Math.min(primary.level, secondary.level) | ||
|
||
override fun sample(level: Int): Fish { | ||
if (junk.isNotEmpty() && rand(100) < JUNK_WEIGHTING) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, we need a unit test for this, but I'm not quite sure how we go about stubbing the randomness in this case (cc @Major-).
Addresses Issue #364 where fishing seaweed & caskets from big nets is requested