forked from External/mage
[PIP] Implement Rad Counters mechanic (#12087)
This commit is contained in:
parent
11373fd75d
commit
9d7bf27d38
14 changed files with 420 additions and 176 deletions
|
|
@ -17,6 +17,7 @@ import mage.game.combat.Combat;
|
|||
import mage.game.combat.CombatGroup;
|
||||
import mage.game.command.Command;
|
||||
import mage.game.command.CommandObject;
|
||||
import mage.game.command.Emblem;
|
||||
import mage.game.command.Plane;
|
||||
import mage.game.events.*;
|
||||
import mage.game.permanent.Battlefield;
|
||||
|
|
@ -85,6 +86,7 @@ public class GameState implements Serializable, Copyable<GameState> {
|
|||
private boolean isPlaneChase;
|
||||
private List<String> seenPlanes = new ArrayList<>();
|
||||
private List<Designation> designations = new ArrayList<>();
|
||||
private List<Emblem> inherentEmblems = new ArrayList<>();
|
||||
private Exile exile;
|
||||
private Battlefield battlefield;
|
||||
private int turnNum = 1;
|
||||
|
|
@ -157,6 +159,7 @@ public class GameState implements Serializable, Copyable<GameState> {
|
|||
this.isPlaneChase = state.isPlaneChase;
|
||||
this.seenPlanes.addAll(state.seenPlanes);
|
||||
this.designations.addAll(state.designations);
|
||||
this.inherentEmblems = CardUtil.deepCopyObject(state.inherentEmblems);
|
||||
this.exile = state.exile.copy();
|
||||
this.battlefield = state.battlefield.copy();
|
||||
this.turnNum = state.turnNum;
|
||||
|
|
@ -204,6 +207,7 @@ public class GameState implements Serializable, Copyable<GameState> {
|
|||
exile.clear();
|
||||
command.clear();
|
||||
designations.clear();
|
||||
inherentEmblems.clear();
|
||||
seenPlanes.clear();
|
||||
isPlaneChase = false;
|
||||
revealed.clear();
|
||||
|
|
@ -245,6 +249,7 @@ public class GameState implements Serializable, Copyable<GameState> {
|
|||
this.isPlaneChase = state.isPlaneChase;
|
||||
this.seenPlanes = state.seenPlanes;
|
||||
this.designations = state.designations;
|
||||
this.inherentEmblems = state.inherentEmblems;
|
||||
this.exile = state.exile;
|
||||
this.battlefield = state.battlefield;
|
||||
this.turnNum = state.turnNum;
|
||||
|
|
@ -506,6 +511,10 @@ public class GameState implements Serializable, Copyable<GameState> {
|
|||
return designations;
|
||||
}
|
||||
|
||||
public List<Emblem> getInherentEmblems() {
|
||||
return inherentEmblems;
|
||||
}
|
||||
|
||||
public Plane getCurrentPlane() {
|
||||
if (command != null && command.size() > 0) {
|
||||
for (CommandObject cobject : command) {
|
||||
|
|
@ -1135,6 +1144,25 @@ public class GameState implements Serializable, Copyable<GameState> {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Inherent triggers (Rad counters) in the rules have no source.
|
||||
* However to fit better with the engine, we make a fake emblem source,
|
||||
* which is not displayed in any game zone. That allows the trigger to
|
||||
* have a source, which helps with a bunch of situation like hosting,
|
||||
* rather than having a trigger.
|
||||
* <p>
|
||||
* Should not be used except in very specific situations
|
||||
*/
|
||||
public void addInherentEmblem(Emblem emblem, UUID controllerId) {
|
||||
getInherentEmblems().add(emblem);
|
||||
emblem.setControllerId(controllerId);
|
||||
for (Ability ability : emblem.getInitAbilities()) {
|
||||
ability.setControllerId(controllerId);
|
||||
ability.setSourceId(emblem.getId());
|
||||
addAbility(ability, null, emblem);
|
||||
}
|
||||
}
|
||||
|
||||
public void addDesignation(Designation designation, Game game, UUID controllerId) {
|
||||
getDesignations().add(designation);
|
||||
for (Ability ability : designation.getInitAbilities()) {
|
||||
|
|
@ -1414,7 +1442,7 @@ public class GameState implements Serializable, Copyable<GameState> {
|
|||
/**
|
||||
* Store the tags of source ability using the MOR as a reference
|
||||
*/
|
||||
void storePermanentCostsTags(MageObjectReference permanentMOR, Ability source){
|
||||
void storePermanentCostsTags(MageObjectReference permanentMOR, Ability source) {
|
||||
if (source.getCostsTagMap() != null) {
|
||||
permanentCostsTags.put(permanentMOR, CardUtil.deepCopyObject(source.getCostsTagMap()));
|
||||
}
|
||||
|
|
@ -1424,9 +1452,9 @@ public class GameState implements Serializable, Copyable<GameState> {
|
|||
* Removes the cost tags if the corresponding permanent is no longer on the battlefield.
|
||||
* Only use if the stack is empty and nothing can refer to them anymore (such as at EOT, the current behavior)
|
||||
*/
|
||||
public void cleanupPermanentCostsTags(Game game){
|
||||
public void cleanupPermanentCostsTags(Game game) {
|
||||
getPermanentCostsTags().entrySet().removeIf(entry ->
|
||||
!(entry.getKey().getZoneChangeCounter() == game.getState().getZoneChangeCounter(entry.getKey().getSourceId())-1)
|
||||
!(entry.getKey().getZoneChangeCounter() == game.getState().getZoneChangeCounter(entry.getKey().getSourceId()) - 1)
|
||||
); // The stored MOR is the stack-moment MOR so need to subtract one from the permanent's ZCC for the check
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue