forked from External/mage
update conditional mode selection to handle different amounts of additional modes
This commit is contained in:
parent
f5b96b0907
commit
33d7d15b99
2 changed files with 15 additions and 8 deletions
|
|
@ -38,6 +38,7 @@ public class Modes extends LinkedHashMap<UUID, Mode> implements Copyable<Modes>
|
|||
private int maxPawPrints;
|
||||
private Filter maxModesFilter; // calculates the max number of available modes
|
||||
private Condition moreCondition; // allows multiple modes choose (example: choose one... if condition, you may choose both)
|
||||
private int moreLimit = Integer.MAX_VALUE; // if multiple modes are allowed, this limits how many additional modes may be chosen (usually doesn't need to change)
|
||||
|
||||
private boolean limitUsageByOnce = false; // limit mode selection to once per game
|
||||
private boolean limitUsageResetOnNewTurn = false; // reset once per game limit on new turn, example: Galadriel, Light of Valinor
|
||||
|
|
@ -73,6 +74,7 @@ public class Modes extends LinkedHashMap<UUID, Mode> implements Copyable<Modes>
|
|||
this.maxPawPrints = modes.maxPawPrints;
|
||||
this.maxModesFilter = modes.maxModesFilter; // can't change so no copy needed
|
||||
this.moreCondition = modes.moreCondition;
|
||||
this.moreLimit = modes.moreLimit;
|
||||
|
||||
this.limitUsageByOnce = modes.limitUsageByOnce;
|
||||
this.limitUsageResetOnNewTurn = modes.limitUsageResetOnNewTurn;
|
||||
|
|
@ -197,7 +199,7 @@ public class Modes extends LinkedHashMap<UUID, Mode> implements Copyable<Modes>
|
|||
return count;
|
||||
}
|
||||
|
||||
public int getSelectedPawPrints(){
|
||||
public int getSelectedPawPrints() {
|
||||
return this.selectedModes.stream()
|
||||
.mapToInt(modeID -> get(modeID).getPawPrintValue())
|
||||
.sum();
|
||||
|
|
@ -241,9 +243,9 @@ public class Modes extends LinkedHashMap<UUID, Mode> implements Copyable<Modes>
|
|||
return realMaxModes;
|
||||
}
|
||||
|
||||
// use case: make two modes chooseable (all cards that use this currently go from one to two)
|
||||
// use case: make more modes chooseable
|
||||
if (moreCondition != null && moreCondition.apply(game, source)) {
|
||||
realMaxModes = 2;
|
||||
realMaxModes = this.moreLimit;
|
||||
}
|
||||
|
||||
// use case: limit max modes by opponents (example: choose one or more... each mode must target a different player)
|
||||
|
|
@ -292,10 +294,10 @@ public class Modes extends LinkedHashMap<UUID, Mode> implements Copyable<Modes>
|
|||
}
|
||||
|
||||
public void addMode(Mode mode) {
|
||||
if (this.maxPawPrints > 0 && mode.getPawPrintValue() == 0){
|
||||
if (this.maxPawPrints > 0 && mode.getPawPrintValue() == 0) {
|
||||
throw new IllegalArgumentException("Mode must have nonzero pawprints value in a pawprints mode set.");
|
||||
}
|
||||
if (this.maxPawPrints == 0 && mode.getPawPrintValue() > 0){
|
||||
if (this.maxPawPrints == 0 && mode.getPawPrintValue() > 0) {
|
||||
throw new IllegalArgumentException("Cannot add pawprints mode to non-pawprints mode set.");
|
||||
}
|
||||
this.put(mode.getId(), mode);
|
||||
|
|
@ -305,6 +307,10 @@ public class Modes extends LinkedHashMap<UUID, Mode> implements Copyable<Modes>
|
|||
this.moreCondition = moreCondition;
|
||||
}
|
||||
|
||||
public void setMoreLimit(int moreLimit) {
|
||||
this.moreLimit = moreLimit;
|
||||
}
|
||||
|
||||
private boolean isAlreadySelectedModesOutdated(Game game, Ability source) {
|
||||
return this.isLimitUsageResetOnNewTurn()
|
||||
&& getOnceTurnNum(game, source) != game.getTurnNum();
|
||||
|
|
@ -552,7 +558,7 @@ public class Modes extends LinkedHashMap<UUID, Mode> implements Copyable<Modes>
|
|||
if (isLimitUsageByOnce() && nonAvailableModes.contains(mode.getId())) {
|
||||
continue;
|
||||
}
|
||||
if (getMaxPawPrints() > 0 && getSelectedPawPrints() + mode.getPawPrintValue() > getMaxPawPrints()){
|
||||
if (getMaxPawPrints() > 0 && getSelectedPawPrints() + mode.getPawPrintValue() > getMaxPawPrints()) {
|
||||
continue;
|
||||
}
|
||||
availableModes.add(mode);
|
||||
|
|
@ -574,7 +580,7 @@ public class Modes extends LinkedHashMap<UUID, Mode> implements Copyable<Modes>
|
|||
}
|
||||
sb.append("choose ");
|
||||
}
|
||||
if (this.getMaxPawPrints() > 0){
|
||||
if (this.getMaxPawPrints() > 0) {
|
||||
sb.append("up to ").append(CardUtil.numberToText(this.getMaxPawPrints())).append(" {P} worth of modes");
|
||||
} else if (this.getMinModes() == 0 && this.getMaxModes(null, null) == 1) {
|
||||
sb.append("up to one");
|
||||
|
|
@ -620,7 +626,7 @@ public class Modes extends LinkedHashMap<UUID, Mode> implements Copyable<Modes>
|
|||
sb.append(mode.getCost().getText());
|
||||
sb.append(" — ");
|
||||
} else if (mode.getPawPrintValue() > 0) {
|
||||
for (int i = 0; i < mode.getPawPrintValue(); ++i){
|
||||
for (int i = 0; i < mode.getPawPrintValue(); ++i) {
|
||||
sb.append("{P}");
|
||||
}
|
||||
sb.append(" — ");
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue