mirror of
https://github.com/correl/mage.git
synced 2024-12-26 19:16:54 +00:00
[ZNR] fixed Kargan Intimidator issues (#7046)
This commit is contained in:
parent
9baaa8d214
commit
42d6faf646
1 changed files with 18 additions and 6 deletions
|
@ -36,7 +36,6 @@ public class Modes extends LinkedHashMap<UUID, Mode> {
|
||||||
private boolean isRandom = false;
|
private boolean isRandom = false;
|
||||||
private String chooseText = null;
|
private String chooseText = null;
|
||||||
private boolean resetEachTurn = false;
|
private boolean resetEachTurn = false;
|
||||||
private int turnNum = 0;
|
|
||||||
|
|
||||||
public Modes() {
|
public Modes() {
|
||||||
this.currentMode = new Mode();
|
this.currentMode = new Mode();
|
||||||
|
@ -70,7 +69,6 @@ public class Modes extends LinkedHashMap<UUID, Mode> {
|
||||||
this.isRandom = modes.isRandom;
|
this.isRandom = modes.isRandom;
|
||||||
this.chooseText = modes.chooseText;
|
this.chooseText = modes.chooseText;
|
||||||
this.resetEachTurn = modes.resetEachTurn;
|
this.resetEachTurn = modes.resetEachTurn;
|
||||||
this.turnNum = modes.turnNum;
|
|
||||||
if (modes.getSelectedModes().isEmpty()) {
|
if (modes.getSelectedModes().isEmpty()) {
|
||||||
this.currentMode = values().iterator().next();
|
this.currentMode = values().iterator().next();
|
||||||
} else {
|
} else {
|
||||||
|
@ -218,9 +216,9 @@ public class Modes extends LinkedHashMap<UUID, Mode> {
|
||||||
|
|
||||||
public boolean choose(Game game, Ability source) {
|
public boolean choose(Game game, Ability source) {
|
||||||
if (this.isResetEachTurn()) {
|
if (this.isResetEachTurn()) {
|
||||||
if (this.turnNum != game.getTurnNum()) {
|
if (this.getTurnNum(game, source) != game.getTurnNum()) {
|
||||||
this.clearAlreadySelectedModes(source, game);
|
this.clearAlreadySelectedModes(source, game);
|
||||||
this.turnNum = game.getTurnNum();
|
this.setTurnNum(game, source);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (this.size() > 1) {
|
if (this.size() > 1) {
|
||||||
|
@ -338,7 +336,7 @@ public class Modes extends LinkedHashMap<UUID, Mode> {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void clearAlreadySelectedModes(Ability source, Game game) {
|
private void clearAlreadySelectedModes(Ability source, Game game) {
|
||||||
for (UUID modeId : getSelectedModes()) {
|
for (UUID modeId : getAlreadySelectedModes(source, game)) {
|
||||||
String key = getKey(source, game, modeId);
|
String key = getKey(source, game, modeId);
|
||||||
game.getState().setValue(key, false);
|
game.getState().setValue(key, false);
|
||||||
}
|
}
|
||||||
|
@ -380,7 +378,7 @@ public class Modes extends LinkedHashMap<UUID, Mode> {
|
||||||
Set<UUID> onceSelectedModes = new HashSet<>();
|
Set<UUID> onceSelectedModes = new HashSet<>();
|
||||||
for (UUID modeId : this.keySet()) {
|
for (UUID modeId : this.keySet()) {
|
||||||
Object exist = game.getState().getValue(getKey(source, game, modeId));
|
Object exist = game.getState().getValue(getKey(source, game, modeId));
|
||||||
if (exist != null) {
|
if (exist == Boolean.TRUE) {
|
||||||
onceSelectedModes.add(modeId);
|
onceSelectedModes.add(modeId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -392,6 +390,20 @@ public class Modes extends LinkedHashMap<UUID, Mode> {
|
||||||
return source.getSourceId().toString() + game.getState().getZoneChangeCounter(source.getSourceId()) + modeId.toString();
|
return source.getSourceId().toString() + game.getState().getZoneChangeCounter(source.getSourceId()) + modeId.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static int getTurnNum(Game game, Ability source) {
|
||||||
|
String key = source.getSourceId().toString() + game.getState().getZoneChangeCounter(source.getSourceId()) + "turnNum";
|
||||||
|
Object object = game.getState().getValue(key);
|
||||||
|
if (object instanceof Integer) {
|
||||||
|
return (Integer) object;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void setTurnNum(Game game, Ability source) {
|
||||||
|
String key = source.getSourceId().toString() + game.getState().getZoneChangeCounter(source.getSourceId()) + "turnNum";
|
||||||
|
game.getState().setValue(key, game.getTurnNum());
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns all (still) available modes of the ability
|
* Returns all (still) available modes of the ability
|
||||||
*
|
*
|
||||||
|
|
Loading…
Reference in a new issue