mirror of
https://github.com/magefree/mage.git
synced 2026-01-24 12:19:59 -08:00
[ACR] Implement Ratonhnhaketon
This commit is contained in:
parent
0e36541cf8
commit
8f9f317c19
6 changed files with 255 additions and 127 deletions
|
|
@ -0,0 +1,34 @@
|
|||
package mage.abilities.condition.common;
|
||||
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.condition.Condition;
|
||||
import mage.abilities.hint.ConditionHint;
|
||||
import mage.abilities.hint.Hint;
|
||||
import mage.game.Game;
|
||||
import mage.watchers.common.DealtDamageThisGameWatcher;
|
||||
|
||||
/**
|
||||
* requires DealtDamageThisGameWatcher
|
||||
*
|
||||
* @author TheElk801
|
||||
*/
|
||||
public enum SourceHasntDealtDamageThisGameCondition implements Condition {
|
||||
instance;
|
||||
private static final Hint hint = new ConditionHint(
|
||||
instance, "This creature hasn't dealt damage yet this game"
|
||||
);
|
||||
|
||||
public static Hint getHint() {
|
||||
return hint;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
return DealtDamageThisGameWatcher.checkCreature(game, source);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "{this} hasn't dealt damage yet";
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,52 @@
|
|||
package mage.watchers.common;
|
||||
|
||||
import mage.MageObjectReference;
|
||||
import mage.abilities.Ability;
|
||||
import mage.constants.WatcherScope;
|
||||
import mage.game.Game;
|
||||
import mage.game.events.GameEvent;
|
||||
import mage.game.permanent.Permanent;
|
||||
import mage.watchers.Watcher;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* @author TheElk801
|
||||
*/
|
||||
public class DealtDamageThisGameWatcher extends Watcher {
|
||||
|
||||
private final Set<MageObjectReference> damagers = new HashSet<>();
|
||||
|
||||
public DealtDamageThisGameWatcher() {
|
||||
super(WatcherScope.GAME);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void watch(GameEvent event, Game game) {
|
||||
switch (event.getType()) {
|
||||
case BEGINNING_PHASE_PRE:
|
||||
// keep the stored values from getting too big, especially since it doesn't reset between games
|
||||
damagers.removeIf(mor -> !mor.zoneCounterIsCurrent(game));
|
||||
return;
|
||||
case DAMAGED_PERMANENT:
|
||||
case DAMAGED_PLAYER:
|
||||
break;
|
||||
default:
|
||||
return;
|
||||
}
|
||||
Permanent permanent = game.getPermanent(event.getSourceId());
|
||||
if (permanent != null) {
|
||||
damagers.add(new MageObjectReference(permanent, game));
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean checkCreature(Game game, Ability source) {
|
||||
return game
|
||||
.getState()
|
||||
.getWatcher(DealtDamageThisGameWatcher.class)
|
||||
.damagers
|
||||
.stream()
|
||||
.noneMatch(mor -> mor.refersTo(source.getSourcePermanentOrLKI(game), game));
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue