@Override public boolean hasSourceObjectAbility(Game game, MageObject source, GameEvent event) { MageObject object = source; // for singleton abilities like Flying we can't rely on abilities' source because it's only once // in continuous effects // so will use the sourceId of the object itself that came as a parameter if it is not null if (object == null) { object = game.getPermanentEntering(getSourceId()); if (object == null) { object = game.getObject(getSourceId()); } } if (object != null) { if (object instanceof Permanent) { if (!((Permanent) object).getAbilities(game).contains(this)) { return false; } return ((Permanent) object).isPhasedIn(); } else if (!object.getAbilities().contains(this)) { // check if it's an ability that is temporary gained to a card Abilities<Ability> otherAbilities = game.getState().getAllOtherAbilities(this.getSourceId()); if (otherAbilities == null || !otherAbilities.contains(this)) { return false; } } } return true; }
public void setAbilities(Abilities Abilities) { if (Abilities == null) { throw new DaoException( "To-one property 'AbilityId' has not-null constraint; cannot set to-one to null"); } synchronized (this) { this.Abilities = Abilities; AbilityId = Abilities.getId(); Abilities__resolvedKey = AbilityId; } }
public void play() throws GameActionException { MapLocation dest = Abilities.ClosestPastr(rc, rc.getLocation(), ENEMY); if (dest != null) { Deque<Move> path = Navigation.pathAStar(rc, dest); while (Navigation.attackMoveOnPath(rc, path, INFO.type.attackRadiusMaxSquared, ENEMY)) { Tactics.killNearbyEnemies(rc, INFO); } } Tactics.killNearbyEnemies(rc, INFO); if (rc.isActive()) { wanderingDirection = Navigation.wonder(rc, rand, wanderingDirection); } else { rc.yield(); } }