use of mage.watchers.common.AttackedLastTurnWatcher in project mage by magefree.
the class CantAttackIfAttackedLastTurnEffect method canAttack.
@Override
public boolean canAttack(Permanent attacker, UUID defenderId, Ability source, Game game, boolean canUseChooseDialogs) {
AttackedLastTurnWatcher watcher = game.getState().getWatcher(AttackedLastTurnWatcher.class);
if (watcher != null) {
Set<MageObjectReference> attackingCreatures = watcher.getAttackedLastTurnCreatures(attacker.getControllerId());
MageObjectReference mor = new MageObjectReference(attacker, game);
return !attackingCreatures.contains(mor);
}
return true;
}
use of mage.watchers.common.AttackedLastTurnWatcher in project mage by magefree.
the class DontUntapIfAttackedLastTurnEnchantedEffect method applies.
@Override
public boolean applies(GameEvent event, Ability source, Game game) {
if (game.getTurn().getStepType() == PhaseStep.UNTAP) {
Permanent enchantment = game.getPermanent(source.getSourceId());
if (enchantment != null && enchantment.getAttachedTo() != null && event.getTargetId().equals(enchantment.getAttachedTo())) {
Permanent permanent = game.getPermanent(enchantment.getAttachedTo());
if (permanent != null && permanent.isControlledBy(game.getActivePlayerId())) {
AttackedLastTurnWatcher watcher = game.getState().getWatcher(AttackedLastTurnWatcher.class);
if (watcher != null) {
Set<MageObjectReference> attackingCreatures = watcher.getAttackedLastTurnCreatures(permanent.getControllerId());
MageObjectReference mor = new MageObjectReference(permanent, game);
if (attackingCreatures.contains(mor)) {
return true;
}
}
}
}
}
return false;
}
use of mage.watchers.common.AttackedLastTurnWatcher in project mage by magefree.
the class DontUntapIfAttackedLastTurnSourceEffect method applies.
@Override
public boolean applies(GameEvent event, Ability source, Game game) {
if (game.getTurn().getStepType() == PhaseStep.UNTAP && event.getTargetId().equals(source.getSourceId())) {
Permanent permanent = game.getPermanent(source.getSourceId());
if (permanent != null && permanent.isControlledBy(game.getActivePlayerId())) {
AttackedLastTurnWatcher watcher = game.getState().getWatcher(AttackedLastTurnWatcher.class);
if (watcher != null) {
Set<MageObjectReference> attackingCreatures = watcher.getAttackedLastTurnCreatures(permanent.getControllerId());
MageObjectReference mor = new MageObjectReference(permanent, game);
if (attackingCreatures.contains(mor)) {
return true;
}
}
}
}
return false;
}
use of mage.watchers.common.AttackedLastTurnWatcher in project mage by magefree.
the class CantAttackIfAttackedLastTurnAllEffect method canAttack.
@Override
public boolean canAttack(Permanent attacker, UUID defenderId, Ability source, Game game, boolean canUseChooseDialogs) {
AttackedLastTurnWatcher watcher = game.getState().getWatcher(AttackedLastTurnWatcher.class);
if (watcher != null) {
Set<MageObjectReference> attackingCreatures = watcher.getAttackedLastTurnCreatures(attacker.getControllerId());
MageObjectReference mor = new MageObjectReference(attacker, game);
return !attackingCreatures.contains(mor);
}
return true;
}
Aggregations