Package mage.counters

Examples of mage.counters.Counter


        GameEvent countersEvent = GameEvent.getEvent(GameEvent.EventType.ADD_COUNTERS, objectId, controllerId, counter.getName(), counter.getCount());
        countersEvent.setAppliedEffects(appliedEffects);
        if (!game.replaceEvent(countersEvent)) {
            int amount = countersEvent.getAmount();
            for (int i = 0; i < amount; i++) {
                Counter eventCounter = counter.copy();
                eventCounter.remove(eventCounter.getCount() - 1);
                GameEvent event = GameEvent.getEvent(GameEvent.EventType.ADD_COUNTER, objectId, controllerId, counter.getName(), 1);
                event.setAppliedEffects(appliedEffects);
                if (!game.replaceEvent(event)) {
                    counters.addCounter(eventCounter);
                    game.fireEvent(GameEvent.getEvent(GameEvent.EventType.COUNTER_ADDED, objectId, controllerId, counter.getName(), 1));
View Full Code Here


                    Player player = game.getPlayer(chosen);
                    if (player != null) {
                        if (player.getCounters().size() > 0) {
                            if (player.getCounters().size() == 1) {
                                for (Counter counter : player.getCounters().values()) {
                                    Counter newCounter = new Counter(counter.getName());
                                    player.addCounters(newCounter, game);
                                }
                            } else {
                                Choice choice = new ChoiceImpl(true);
                                Set<String> choices = new HashSet<>();
                                for (Counter counter : player.getCounters().values()) {
                                    choices.add(counter.getName());
                                }
                                choice.setChoices(choices);
                                choice.setMessage("Choose a counter to proliferate (" + player.getName() + ")");
                                controller.choose(Outcome.Benefit, choice, game);
                                for (Counter counter : player.getCounters().values()) {
                                    if (counter.getName().equals(choice.getChoice())) {
                                        Counter newCounter = new Counter(counter.getName());
                                        player.addCounters(newCounter, game);
                                        break;
                                    }
                                }
                            }
View Full Code Here

                    String command = action.getAction();
                    command = command.substring(command.indexOf("addCounters:") + 12);
                    String[] groups = command.split(";");
                    for (Permanent permanent : game.getBattlefield().getAllActivePermanents()) {
                        if (permanent.getName().equals(groups[0])) {
                            Counter counter = new Counter(groups[1], Integer.parseInt(groups[2]));
                            permanent.addCounters(counter, game);
                            break;
                        }
                    }
                }
View Full Code Here

        GameEvent countersEvent = GameEvent.getEvent(GameEvent.EventType.ADD_COUNTERS, objectId, ownerId, counter.getName(), counter.getCount());
        countersEvent.setAppliedEffects(appliedEffects);
        if (!game.replaceEvent(countersEvent)) {
            int amount = countersEvent.getAmount();
            for (int i = 0; i < amount; i++) {
                Counter eventCounter = counter.copy();
                eventCounter.remove(amount - 1);
                GameEvent event = GameEvent.getEvent(GameEvent.EventType.ADD_COUNTER, objectId, ownerId, counter.getName(), 1);
                event.setAppliedEffects(appliedEffects);
                if (!game.replaceEvent(event)) {
                    counters.addCounter(eventCounter);
                    game.fireEvent(GameEvent.getEvent(GameEvent.EventType.COUNTER_ADDED, objectId, ownerId, counter.getName(), 1));
View Full Code Here

    @Override
    public void addCounters(Counter counter, Game game) {
        int amount = counter.getCount();
        for (int i = 0; i < amount; i++) {
            Counter eventCounter = counter.copy();
            eventCounter.remove(amount - 1);
            if (!game.replaceEvent(GameEvent.getEvent(GameEvent.EventType.ADD_COUNTER, playerId, playerId, counter.getName(), counter.getCount()))) {
                counters.addCounter(eventCounter);
                game.fireEvent(GameEvent.getEvent(EventType.COUNTER_ADDED, playerId, playerId, counter.getName(), counter.getCount()));
            }
        }
View Full Code Here

    public boolean apply(Game game, Ability source) {
        if (putOnCard) {
            Card card = game.getCard(source.getSourceId());
            if (card != null) {
                if (counter != null) {
                    Counter newCounter = counter.copy();
                    int countersToAdd = amount.calculate(game, source, this);
                    if (countersToAdd > 0 && newCounter.getCount() == 1) {
                        countersToAdd--;
                    }
                    newCounter.add(countersToAdd);
                    card.addCounters(newCounter, game);
                    if (informPlayers) {
                        Player player = game.getPlayer(source.getControllerId());
                        if (player != null) {
                            game.informPlayers(new StringBuilder(player.getName()).append(" puts ").append(newCounter.getCount()).append(" ").append(newCounter.getName().toLowerCase()).append(" counter on ").append(card.getLogName()).toString());
                        }
                    }
                }
                return true;
            }
        } else {
            Permanent permanent = game.getPermanent(source.getSourceId());
            if (permanent != null) {
                if (counter != null) {
                    Counter newCounter = counter.copy();
                    int countersToAdd = amount.calculate(game, source, this);
                    if (countersToAdd > 0 && newCounter.getCount() == 1) {
                        countersToAdd--;
                    }
                    newCounter.add(countersToAdd);
                    int before = permanent.getCounters().getCount(newCounter.getName());
                    permanent.addCounters(newCounter, game);
                    int amountAdded = permanent.getCounters().getCount(newCounter.getName()) - before;
                    if (informPlayers) {
                        Player player = game.getPlayer(source.getControllerId());
                        if (player != null) {
                            game.informPlayers(player.getName()+" puts "+amountAdded+" "+newCounter.getName().toLowerCase()+" counter on "+permanent.getLogName());
                        }
                    }
                }
                return true;
            }
View Full Code Here

    public boolean apply(Game game, Ability source) {
        Permanent permanent = game.getPermanent(source.getSourceId());
        if (permanent != null && permanent.getAttachedTo() != null) {
            Permanent attachedTo = game.getPermanent(permanent.getAttachedTo());
            if (attachedTo != null && counter != null) {
                Counter newCounter = counter.copy();
                newCounter.add(amount.calculate(game, source, this));
                attachedTo.addCounters(newCounter, game);
            }
            return true;
        }
        return false;
View Full Code Here

            int affectedTargets = 0;
            for (UUID uuid : targetPointer.getTargets(game, source)) {
                Permanent permanent = game.getPermanent(uuid);
                if (permanent != null) {
                    if (counter != null) {
                        Counter newCounter = counter.copy();
                        newCounter.add(amount.calculate(game, source, this));
                        int before = permanent.getCounters().getCount(counter.getName());
                        permanent.addCounters(newCounter, game);
                        int numberAdded = permanent.getCounters().getCount(counter.getName()) - before;
                        affectedTargets ++;
                        game.informPlayers(sourceObject.getLogName() +": "+ controller.getName()+ " puts " +
                                numberAdded + " " + counter.getName().toLowerCase() + " counter on " + permanent.getLogName());
                    }
                } else {
                    Player player = game.getPlayer(uuid);
                    if (player != null) {
                        Counter newCounter = counter.copy();
                        newCounter.add(amount.calculate(game, source, this));
                        player.addCounters(newCounter, game);
                        affectedTargets ++;
                        game.informPlayers(new StringBuilder(sourceObject.getLogName()).append(": ")
                                .append(controller.getName()).append(" puts ")
                                .append(counter.getCount()).append(" ").append(counter.getName().toLowerCase())
View Full Code Here

        return new RemoveVariableCountersSourceCost(this);
    }

    @Override
    public Cost getFixedCostsFromAnnouncedValue(int xValue) {
        return new RemoveCountersSourceCost(new Counter(counterName, xValue));
    }
View Full Code Here

    @Override
    public boolean apply(Game game, Ability source) {
        Permanent permanent = game.getPermanent(source.getSourceId());
        if (permanent != null) {
            Counter counter;
            if(permanent.getCardType().contains(CardType.CREATURE)){
                counter = CounterType.P1P1.createInstance(amount.calculate(game, source, this));
            }
            else{
                counter = CounterType.CHARGE.createInstance(amount.calculate(game, source, this));
            }
            if (counter != null) {
              
                permanent.addCounters(counter, game);
               
                Player player = game.getPlayer(source.getControllerId());
                if (player != null) {
                    game.informPlayers(player.getName()+ " puts " + counter.getCount() + " " + counter.getName() + " counter on " + permanent.getName());
                }
            }
        }
        return true;
    }
View Full Code Here

TOP

Related Classes of mage.counters.Counter

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.