Package mage.watchers.common

Examples of mage.watchers.common.PlayerDamagedBySourceWatcher


        Controllable object = input.getObject();
        UUID playerId = input.getPlayerId();

        switch (controller) {
            case YOU:
                PlayerDamagedBySourceWatcher watcher = (PlayerDamagedBySourceWatcher) game.getState().getWatchers().get("PlayerDamagedBySource",playerId);
                if (watcher != null ) {
                    return watcher.hasSourceDoneDamage(object.getId(), game);
                }
                break;
            case OPPONENT:
                for (UUID opponentId : game.getOpponents(playerId)) {
                    watcher = (PlayerDamagedBySourceWatcher) game.getState().getWatchers().get("PlayerDamagedBySource",opponentId);
                    if (watcher != null ) {
                        return watcher.hasSourceDoneDamage(object.getId(), game);
                    }
                }
                break;
            case NOT_YOU:
                Player you = game.getPlayer(playerId);
                if (you != null) {
                    for (UUID notYouId : you.getInRange()) {
                        if (!notYouId.equals(playerId)) {
                            watcher = (PlayerDamagedBySourceWatcher) game.getState().getWatchers().get("PlayerDamagedBySource",notYouId);
                            if (watcher != null ) {
                                return watcher.hasSourceDoneDamage(object.getId(), game);
                            }
                        }
                    }
                }
                break;
            case ANY:
                you = game.getPlayer(playerId);
                if (you != null) {
                    for (UUID anyId : you.getInRange()) {
                        watcher = (PlayerDamagedBySourceWatcher) game.getState().getWatchers().get("PlayerDamagedBySource",anyId);
                        if (watcher != null ) {
                            return watcher.hasSourceDoneDamage(object.getId(), game);
                        }
                    }
                }
                return true;
        }
View Full Code Here


    }

    @Override
    public boolean apply(Game game, Ability source) {
        for (UUID opponentId: game.getOpponents(source.getControllerId())) {
            PlayerDamagedBySourceWatcher watcher = (PlayerDamagedBySourceWatcher) game.getState().getWatchers().get("PlayerDamagedBySource", opponentId);
            if (watcher != null) {
                return watcher.hasSourceDoneDamage(source.getSourceId(), game);
            }
        }
        return false;
    }
View Full Code Here

            saveState(false);
        } while (!mulliganPlayers.isEmpty());

        // add watchers
        for (UUID playerId : state.getPlayerList(startingPlayerId)) {
            state.getWatchers().add(new PlayerDamagedBySourceWatcher(playerId));
        }
        state.getWatchers().add(new MorbidWatcher());
        state.getWatchers().add(new CastSpellLastTurnWatcher());
        state.getWatchers().add(new SoulbondWatcher());
        state.getWatchers().add(new PlayerLostLifeWatcher());
View Full Code Here

    @Override
    public boolean apply(Game game, Ability source) {
        int xValue = source.getManaCostsToPay().getX();
        for (Permanent permanent: game.getBattlefield().getActivePermanents(new FilterNonlandPermanent(), source.getControllerId(), source.getSourceId(), game)) {
            if (permanent.getManaCost().convertedManaCost() == xValue) {
                PlayerDamagedBySourceWatcher watcher = (PlayerDamagedBySourceWatcher) game.getState().getWatchers().get("PlayerDamagedBySource", permanent.getControllerId());
                if (watcher != null && watcher.hasSourceDoneDamage(source.getSourceId(), game)) {
                    permanent.destroy(source.getSourceId(), game, false);
                }
            }
        }
        return true;
View Full Code Here

class WickedAkubaPredicate implements ObjectSourcePlayerPredicate<ObjectSourcePlayer<Player>> {

    @Override
    public boolean apply(ObjectSourcePlayer<Player> input, Game game) {
        PlayerDamagedBySourceWatcher watcher = (PlayerDamagedBySourceWatcher) game.getState().getWatchers().get("PlayerDamagedBySource", input.getObject().getId());
        if (watcher != null) {
            return watcher.hasSourceDoneDamage(input.getSourceId(), game);
        }

        return false;
    }
View Full Code Here

        super(target);
    }

    @Override
    public boolean canTarget(UUID id, Ability source, Game game) {
        PlayerDamagedBySourceWatcher watcher = (PlayerDamagedBySourceWatcher) game.getState().getWatchers().get("PlayerDamagedBySource",source.getControllerId());
        if (watcher != null && watcher.hasSourceDoneDamage(id, game)) {
            return super.canTarget(id, source, game);
        }
        return false;
    }
View Full Code Here

    @Override
    public Set<UUID> possibleTargets(UUID sourceId, UUID sourceControllerId, Game game) {
        Set<UUID> availablePossibleTargets = super.possibleTargets(sourceId, sourceControllerId, game);
        Set<UUID> possibleTargets = new HashSet<UUID>();
        PlayerDamagedBySourceWatcher watcher = (PlayerDamagedBySourceWatcher) game.getState().getWatchers().get("PlayerDamagedBySource", sourceControllerId);
        for (UUID targetId : availablePossibleTargets) {
            Permanent permanent = game.getPermanent(targetId);
            if(permanent != null && watcher != null && watcher.hasSourceDoneDamage(targetId, game)){
                possibleTargets.add(targetId);
            }
        }
        return possibleTargets;
    }
View Full Code Here

        if (remainingTargets == 0) {
            return true;
        }
        int count = 0;
        MageObject targetSource = game.getObject(sourceId);
        PlayerDamagedBySourceWatcher watcher = (PlayerDamagedBySourceWatcher) game.getState().getWatchers().get("PlayerDamagedBySource", 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;
                        }
                }
View Full Code Here

        super(target);
    }

    @Override
    public boolean canTarget(UUID id, Ability source, Game game) {
        PlayerDamagedBySourceWatcher watcher = (PlayerDamagedBySourceWatcher) game.getState().getWatchers().get("PlayerDamagedBySource",source.getControllerId());
        if (watcher != null && watcher.hasSourceDoneDamage(id, game)) {
            return super.canTarget(id, source, game);
        }
        return false;
    }
View Full Code Here

    @Override
    public Set<UUID> possibleTargets(UUID sourceId, UUID sourceControllerId, Game game) {
        Set<UUID> availablePossibleTargets = super.possibleTargets(sourceId, sourceControllerId, game);
        Set<UUID> possibleTargets = new HashSet<UUID>();
        PlayerDamagedBySourceWatcher watcher = (PlayerDamagedBySourceWatcher) game.getState().getWatchers().get("PlayerDamagedBySource", sourceControllerId);
        for (UUID targetId : availablePossibleTargets) {
            Permanent permanent = game.getPermanent(targetId);
            if(permanent != null && watcher != null && watcher.hasSourceDoneDamage(targetId, game)){
                possibleTargets.add(targetId);
            }
        }
        return possibleTargets;
    }
View Full Code Here

TOP

Related Classes of mage.watchers.common.PlayerDamagedBySourceWatcher

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.