-
Notifications
You must be signed in to change notification settings - Fork 783
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
[BLB] Implement Season of Gathering and Pawprints mechanic #12617
Conversation
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.
Overall this looks good to me! I'll let another dev take a look before merging. Thanks for the test cases.
@@ -19,6 +19,7 @@ public class Mode implements Serializable { | |||
protected final Effects effects; | |||
protected String flavorWord; | |||
protected Cost cost = null; | |||
protected int pawPrintValue = -1; |
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.
please add comment on usage of "magic number"
@@ -119,4 +121,17 @@ public Mode withCost(Cost cost) { | |||
public Cost getCost() { | |||
return cost; | |||
} | |||
|
|||
public void setPawPrintValue(int pawPrintValue) { |
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.
what's the point of having separate "set" and "with" methods? I would just have the "with" method, the return can be ignored if not needed
@@ -53,6 +55,7 @@ public Modes() { | |||
this.put(currentMode.getId(), currentMode); | |||
this.minModes = 1; | |||
this.maxModes = 1; | |||
this.maxPawPrints = -1; |
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.
comment here as well
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.
-1 logic smells bed. Must be 0 by default. And other code checks must use > 0.
Mode mode = get(modeId); | ||
|
||
if (mode.getPawPrintValue() < 0 && this.getMaxPawPrints() >= 0){ | ||
throw new RuntimeException("Selected mode has no pawprint value, but this Modes object requires pawprint modes!"); |
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.
don't throw RuntimeException, use something like IllegalStateException
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.
Looks like it’s verify check and can be added to card constructor time instead runtime. As example: modes.addMode - after new mode added make sure modes amount with paw equal to total modes amount or zero.
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.
For info:
- verify check -- can be called from card constructor (by card, ability, effect or other data setup). There are some verify tests that call constructor for all cards and tokens. So such errors will be catches by tests as fast as possible.
- runtime check -- can be called from real game only.
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.
To clarify, are you asking for both here? I moved the runtime check pointed to in this thread to a check in addMode() to catch it earlier.
/** | ||
* @author jimga150 | ||
*/ | ||
public enum ControlledCreaturesGreatestPower implements DynamicValue { |
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.
GreatestPowerAmongControlledCreaturesValue already exists
(and is a good example of stream, mapToInt, sum as a cleaner style)
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.
Require some code style and check logic changes. See related comments.
@@ -2217,6 +2217,10 @@ public Mode chooseMode(Modes modes, Ability source, Game game) { | |||
continue AvailableMode; | |||
} | |||
} | |||
if (modes.getMaxPawPrints() >= 0 && modes.getSelectedPawPrints() + mode.getPawPrintValue() > modes.getMaxPawPrints()){ |
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.
must put paw checks inside getAvailableModes, not outside.
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.
chooseMode
is where the max modes check is, so it seemed symmetrical to place the max pawprints check here too. should the max modes check move to getAvailableModes
too?
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.
Try to add paw check to getMaxMode. getAvailableModes must use paw check too, not getMaxMode.
@@ -2572,6 +2572,11 @@ public Mode chooseMode(Modes modes, Ability source, Game game) { | |||
} | |||
} | |||
|
|||
if (modes.getMaxPawPrints() >= 0 && modes.getSelectedPawPrints() + mode.getPawPrintValue() > modes.getMaxPawPrints()){ |
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.
same
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.
Linking for my reference #12617 (comment)
Mage.Server.Plugins/Mage.Player.Human/src/mage/player/human/HumanPlayer.java
Show resolved
Hide resolved
@@ -2082,6 +2082,10 @@ public Mode chooseMode(Modes modes, Ability source, Game game) { | |||
int needMode = Integer.parseInt(modesSet.get(0)); | |||
int i = 1; | |||
for (Mode mode : modes.getAvailableModes(source, game)) { | |||
if (modes.getMaxPawPrints() >= 0 && modes.getSelectedPawPrints() + mode.getPawPrintValue() > modes.getMaxPawPrints()){ |
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.
same
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.
Linking for my reference #12617 (comment)
@@ -32,9 +32,11 @@ public class Modes extends LinkedHashMap<UUID, Mode> implements Copyable<Modes> | |||
private final List<UUID> selectedModes = new ArrayList<>(); // all selected modes (this + duplicate), use getSelectedModes all the time to keep modes order | |||
private final Map<UUID, Mode> selectedDuplicateModes = new LinkedHashMap<>(); // for 2x selects: additional selected modes | |||
private final Map<UUID, UUID> selectedDuplicateToOriginalModeRefs = new LinkedHashMap<>(); // for 2x selects: stores ref from duplicate to original mode | |||
private int selectedPawPrints = 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.
It’s dynamic value from selected modes, no need to store it inside.
@@ -53,6 +55,7 @@ public Modes() { | |||
this.put(currentMode.getId(), currentMode); | |||
this.minModes = 1; | |||
this.maxModes = 1; | |||
this.maxPawPrints = -1; |
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.
-1 logic smells bed. Must be 0 by default. And other code checks must use > 0.
Mode mode = get(modeId); | ||
|
||
if (mode.getPawPrintValue() < 0 && this.getMaxPawPrints() >= 0){ | ||
throw new RuntimeException("Selected mode has no pawprint value, but this Modes object requires pawprint modes!"); |
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.
Looks like it’s verify check and can be added to card constructor time instead runtime. As example: modes.addMode - after new mode added make sure modes amount with paw equal to total modes amount or zero.
Is there a way to retrigger travis builds? this one looks like it was a transient error |
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.
minor followup correction needed, otherwise I think this is ready to go
String message = "Choose mode (selected " + modes.getSelectedModes().size() + " of " + modes.getMaxModes(game, source) | ||
+ ", min " + modes.getMinModes() + ")"; | ||
String message; | ||
if (modes.getMaxPawPrints() < 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.
should this be modes.getMaxPawPrints() == 0
now?
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.
yeah, missed this and another check when converting the pattern to 0 -> non-pawprints
} | ||
} | ||
|
||
// done button for "for up" choices only | ||
boolean canEndChoice = modes.getSelectedModes().size() >= modes.getMinModes() || modes.isMayChooseNone(); | ||
boolean canEndChoice = (modes.getSelectedModes().size() >= modes.getMinModes() && modes.getMaxPawPrints() < 0) || | ||
(modes.getSelectedPawPrints() >= modes.getMaxPawPrints() && modes.getMaxPawPrints() >= 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.
I think this needs to be updated now that max paw prints = 0 indicates no pawprints
#11853
My current implementation requires pawprint cards to also set a min and max number of modes according to what logically could be chosen (0 and 5, for this and what will be the other four bloomburrow "Season of" cards).
In playtesting, the maxModes being set to 5 isnt required, since i added switches to check against the pawprint count instead of the mode count, but for some reason if i don't set the maxModes to 5 (default is 1), my tests all fail like this:
Which suggests that for some reason, the choice/target ingesting code is getting clogged. I'm not sure why, since i haven't had any luck trying to use breakpoints in maven run configurations.