mirror of
https://github.com/magefree/mage.git
synced 2025-12-23 12:02:01 -08:00
Fixed tags cost and MageObjectReference usage (#11500)
* Fix costs tag clearing while permanent still on the battlefield * Improved version of game.getPermanentOrLKIBattlefield with MageObjectReference * Improve documentation
This commit is contained in:
parent
aea49d3c2b
commit
f3e310cfd3
4 changed files with 32 additions and 7 deletions
|
|
@ -172,11 +172,7 @@ public class MageObjectReference implements Comparable<MageObjectReference>, Ser
|
||||||
}
|
}
|
||||||
|
|
||||||
public Permanent getPermanentOrLKIBattlefield(Game game) {
|
public Permanent getPermanentOrLKIBattlefield(Game game) {
|
||||||
Permanent permanent = game.getPermanentOrLKIBattlefield(sourceId);
|
return game.getPermanentOrLKIBattlefield(this);
|
||||||
if (permanent != null && permanent.getZoneChangeCounter(game) == zoneChangeCounter) {
|
|
||||||
return permanent;
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public Card getCard(Game game) {
|
public Card getCard(Game game) {
|
||||||
|
|
|
||||||
|
|
@ -112,8 +112,27 @@ public interface Game extends MageItem, Serializable, Copyable<Game> {
|
||||||
*/
|
*/
|
||||||
Permanent getPermanent(UUID permanentId);
|
Permanent getPermanent(UUID permanentId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Given the UUID of a permanent, this method returns the permanent. If the current game state does not contain
|
||||||
|
* a permanent with the given UUID, this method checks the last known information on the battlefield to look for it.
|
||||||
|
* <br>
|
||||||
|
* Warning: if the permanent has left the battlefield and then returned, this information might be wrong.
|
||||||
|
* Prefer usage of a MageObjectReference instead of only the UUID.
|
||||||
|
*
|
||||||
|
* @param permanentId - The UUID of the permanent
|
||||||
|
* @return permanent or permanent's LKI
|
||||||
|
*/
|
||||||
Permanent getPermanentOrLKIBattlefield(UUID permanentId);
|
Permanent getPermanentOrLKIBattlefield(UUID permanentId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Given a MageObjectReference to a permanent, this method returns the permanent. If the current game state does not
|
||||||
|
* contain that permanent, this method checks the last known information on the battlefield.
|
||||||
|
*
|
||||||
|
* @param permanentRef - A MOR to the permanent
|
||||||
|
* @return permanent or permanent's LKI
|
||||||
|
*/
|
||||||
|
Permanent getPermanentOrLKIBattlefield(MageObjectReference permanentRef);
|
||||||
|
|
||||||
Permanent getPermanentEntering(UUID permanentId);
|
Permanent getPermanentEntering(UUID permanentId);
|
||||||
|
|
||||||
Map<UUID, Permanent> getPermanentsEntering();
|
Map<UUID, Permanent> getPermanentsEntering();
|
||||||
|
|
|
||||||
|
|
@ -717,6 +717,16 @@ public abstract class GameImpl implements Game {
|
||||||
return permanent;
|
return permanent;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Permanent getPermanentOrLKIBattlefield(MageObjectReference permanentRef) {
|
||||||
|
UUID id = permanentRef.getSourceId();
|
||||||
|
Permanent permanent = state.getPermanent(id);
|
||||||
|
if (permanent == null || state.getZoneChangeCounter(id) != permanentRef.getZoneChangeCounter()) {
|
||||||
|
permanent = (Permanent) this.getLastKnownInformation(id, Zone.BATTLEFIELD, permanentRef.getZoneChangeCounter());
|
||||||
|
}
|
||||||
|
return permanent;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Permanent getPermanentEntering(UUID permanentId) {
|
public Permanent getPermanentEntering(UUID permanentId) {
|
||||||
return permanentsEntering.get(permanentId);
|
return permanentsEntering.get(permanentId);
|
||||||
|
|
|
||||||
|
|
@ -1374,8 +1374,8 @@ public class GameState implements Serializable, Copyable<GameState> {
|
||||||
*/
|
*/
|
||||||
public void cleanupPermanentCostsTags(Game game){
|
public void cleanupPermanentCostsTags(Game game){
|
||||||
getPermanentCostsTags().entrySet().removeIf(entry ->
|
getPermanentCostsTags().entrySet().removeIf(entry ->
|
||||||
!(entry.getKey().zoneCounterIsCurrent(game))
|
!(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
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addWatcher(Watcher watcher) {
|
public void addWatcher(Watcher watcher) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue