use of mage.watchers.common.PlayerDamagedBySourceWatcher in project mage by magefree.
the class GiltspireAvengerTarget method possibleTargets.
@Override
public Set<UUID> possibleTargets(UUID sourceId, UUID sourceControllerId, Game game) {
Set<UUID> availablePossibleTargets = super.possibleTargets(sourceId, sourceControllerId, game);
Set<UUID> possibleTargets = new HashSet<>();
PlayerDamagedBySourceWatcher watcher = game.getState().getWatcher(PlayerDamagedBySourceWatcher.class, sourceControllerId);
for (UUID targetId : availablePossibleTargets) {
Permanent permanent = game.getPermanent(targetId);
if (permanent != null && watcher != null && watcher.hasSourceDoneDamage(targetId, game)) {
possibleTargets.add(targetId);
}
}
return possibleTargets;
}
use of mage.watchers.common.PlayerDamagedBySourceWatcher in project mage by magefree.
the class GiltspireAvengerTarget method canChoose.
@Override
public boolean canChoose(UUID sourceId, UUID sourceControllerId, Game game) {
int remainingTargets = this.minNumberOfTargets - targets.size();
if (remainingTargets == 0) {
return true;
}
int count = 0;
MageObject targetSource = game.getObject(sourceId);
PlayerDamagedBySourceWatcher watcher = game.getState().getWatcher(PlayerDamagedBySourceWatcher.class, sourceControllerId);
for (Permanent permanent : game.getBattlefield().getActivePermanents(filter, sourceControllerId, sourceId, game)) {
if (!targets.containsKey(permanent.getId()) && permanent.canBeTargetedBy(targetSource, sourceControllerId, game) && watcher != null && watcher.hasSourceDoneDamage(permanent.getId(), game)) {
count++;
if (count >= remainingTargets) {
return true;
}
}
}
return false;
}
use of mage.watchers.common.PlayerDamagedBySourceWatcher in project mage by magefree.
the class DamagedPlayerThisTurnPredicate method apply.
@Override
public boolean apply(ObjectSourcePlayer<Controllable> input, Game game) {
Controllable object = input.getObject();
UUID playerId = input.getPlayerId();
switch(controller) {
case YOU:
PlayerDamagedBySourceWatcher watcher = game.getState().getWatcher(PlayerDamagedBySourceWatcher.class, playerId);
if (watcher != null) {
return watcher.hasSourceDoneDamage(object.getId(), game);
}
break;
case OPPONENT:
for (UUID opponentId : game.getOpponents(playerId)) {
watcher = game.getState().getWatcher(PlayerDamagedBySourceWatcher.class, opponentId);
if (watcher != null) {
return watcher.hasSourceDoneDamage(object.getId(), game);
}
}
break;
case NOT_YOU:
for (UUID notYouId : game.getState().getPlayersInRange(playerId, game)) {
if (!notYouId.equals(playerId)) {
watcher = game.getState().getWatcher(PlayerDamagedBySourceWatcher.class, notYouId);
if (watcher != null) {
return watcher.hasSourceDoneDamage(object.getId(), game);
}
}
}
break;
case ANY:
for (UUID anyId : game.getState().getPlayersInRange(playerId, game)) {
watcher = game.getState().getWatcher(PlayerDamagedBySourceWatcher.class, anyId);
if (watcher != null) {
return watcher.hasSourceDoneDamage(object.getId(), game);
}
}
return true;
}
return false;
}
use of mage.watchers.common.PlayerDamagedBySourceWatcher in project mage by magefree.
the class ReciprocateTarget method canChoose.
@Override
public boolean canChoose(UUID sourceId, UUID sourceControllerId, Game game) {
int remainingTargets = this.minNumberOfTargets - targets.size();
if (remainingTargets == 0) {
return true;
}
int count = 0;
MageObject targetSource = game.getObject(sourceId);
if (targetSource != null) {
PlayerDamagedBySourceWatcher watcher = game.getState().getWatcher(PlayerDamagedBySourceWatcher.class, sourceControllerId);
for (Permanent permanent : game.getBattlefield().getActivePermanents(filter, sourceControllerId, sourceId, game)) {
if (!targets.containsKey(permanent.getId()) && permanent.canBeTargetedBy(targetSource, sourceControllerId, game) && watcher != null && watcher.hasSourceDoneDamage(permanent.getId(), game)) {
count++;
if (count >= remainingTargets) {
return true;
}
}
}
}
return false;
}
use of mage.watchers.common.PlayerDamagedBySourceWatcher in project mage by magefree.
the class ReciprocateTarget method possibleTargets.
@Override
public Set<UUID> possibleTargets(UUID sourceId, UUID sourceControllerId, Game game) {
Set<UUID> availablePossibleTargets = super.possibleTargets(sourceId, sourceControllerId, game);
Set<UUID> possibleTargets = new HashSet<>();
PlayerDamagedBySourceWatcher watcher = game.getState().getWatcher(PlayerDamagedBySourceWatcher.class, sourceControllerId);
for (UUID targetId : availablePossibleTargets) {
Permanent permanent = game.getPermanent(targetId);
if (permanent != null && watcher != null && watcher.hasSourceDoneDamage(targetId, game)) {
possibleTargets.add(targetId);
}
}
return possibleTargets;
}
Aggregations