[UNF] "Name Sticker" Goblin, [WHO] Coward // Killer, [WHO] Thijarian Witness (#11392)

* Add [WHO] Coward // Killer

* Add MTGO version of [UNF] "Name Sticker" Goblin

* Implement [WHO] Thijarian Witness

* Add NameStickerGoblinTest

* Fix Thijarian Witness, add tests (may need additional tests). Also adds a simple toString for MageObjectReference

* Don't spam the java garbage collector, add another test

* Replace non-ASCII characters in card text

* improve MOR toString

* Thijarian Witness fixed better, add AttackingBlockingWatcher in common

* cleanup from xenohedron's review

* Fix test, add warning not to use AttackingBlockingWatcher for static effects

* rename AttackingBlockingWatcher to AttackingBlockingDelayedWatcher to make it more obvious how it should be used, minor documentation changes
Simplify and rename Thijarian Witness Predicate

* add null checks
This commit is contained in:
ssk97 2023-11-18 21:38:21 -08:00 committed by GitHub
parent 50d5b7ce9b
commit 38adbb4ae5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
10 changed files with 615 additions and 10 deletions

View file

@ -100,6 +100,10 @@ public class MageObjectReference implements Comparable<MageObjectReference>, Ser
}
}
@Override
public String toString(){
return "("+zoneChangeCounter+"|"+sourceId.toString().substring(0,3)+")";
}
public UUID getSourceId() {
return sourceId;
}

View file

@ -0,0 +1,70 @@
package mage.watchers.common;
import mage.constants.WatcherScope;
import mage.game.Game;
import mage.game.events.GameEvent;
import mage.watchers.Watcher;
import java.util.HashSet;
import java.util.Set;
import java.util.UUID;
/**
* Stores attacking/blocking combat information but is only updated
* 1) as damage is dealt (combat damage or otherwise)
* 2) as a spell or ability starts resolving
* 3) Land playing or special action taken (just in case that then causes a static effect to kill)
* Thus the information is available after any involved creatures die
* and all dying creatures can see all other creatures that were in combat at that time
* WARNING: This information is NOT to be used for static effects since the information will always be outdated.
* Use game.getCombat() directly or one of the other combat watchers instead
* @author notgreat
*/
public class AttackingBlockingDelayedWatcher extends Watcher {
private Set<UUID> attackers = new HashSet<>();
private Set<UUID> blockers = new HashSet<>();
public AttackingBlockingDelayedWatcher() {
super(WatcherScope.GAME);
}
@Override
public void watch(GameEvent event, Game game) {
switch (event.getType()) {
case LAND_PLAYED:
case TAKEN_SPECIAL_ACTION:
case RESOLVING_ABILITY:
case DAMAGED_BATCH_FOR_PERMANENTS:
//Note: getAttackers and getBlockers make a new Set, so this is safe to do
attackers = game.getCombat().getAttackers();
blockers = game.getCombat().getBlockers();
}
}
@Override
public void reset() {
super.reset();
attackers.clear();
blockers.clear();
}
public boolean checkAttacker(UUID attacker) {
return attackers.contains(attacker);
}
public boolean checkBlocker(UUID blocker) {
return blockers.contains(blocker);
}
public long countBlockers() {
return blockers.size();
}
public long countAttackers() {
return attackers.size();
}
public static AttackingBlockingDelayedWatcher getWatcher(Game game) {
return game.getState().getWatcher(AttackingBlockingDelayedWatcher.class);
}
}