Skip to content
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

Open
wants to merge 5 commits into
base: kotlin-experiments
Choose a base branch
from
Open

Fishing Seaweed & Caskets #425

wants to merge 5 commits into from

Conversation

Tomm0017
Copy link

@Tomm0017 Tomm0017 commented Apr 25, 2019

Addresses Issue #364 where fishing seaweed & caskets from big nets is requested

@codecov-io
Copy link

codecov-io commented Apr 25, 2019

Codecov Report

Merging #425 into kotlin-experiments will increase coverage by <.01%.
The diff coverage is 46.66%.

Impacted file tree graph

@@                   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
Impacted Files Coverage Δ Complexity Δ
.../src/org/apollo/game/plugin/skills/fishing/Fish.kt 89.47% <100%> (+1.23%) 2 <0> (ø) ⬇️
...g/apollo/game/plugin/skills/fishing/FishingSpot.kt 64.28% <33.33%> (-10%) 4 <0> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update cd06a69...77b55d7. Read the comment docs.

*/
SEAWEED(id = 401, level = 16, experience = 1.0),
CASKET(id = 405, level = 16, experience = 1.0)
;
Copy link
Contributor

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() {
Copy link
Contributor

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?

Copy link
Contributor

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.

Copy link
Author

@Tomm0017 Tomm0017 Apr 26, 2019

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 {
Copy link
Contributor

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 {
Copy link
Contributor

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.

@garyttierney
Copy link
Contributor

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) {
Copy link
Contributor

@garyttierney garyttierney Apr 26, 2019

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-).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants