Package mage.game.events

Examples of mage.game.events.GameEvent


    private void removeConditional(ManaType manaType, Ability ability, Game game) {
        for (ConditionalMana mana : getConditionalMana()) {
            if (mana.get(manaType) > 0 && mana.apply(ability, game, mana.getManaProducerId())) {
                mana.set(manaType, mana.get(manaType) - 1);
                game.fireEvent(new GameEvent(GameEvent.EventType.MANA_PAYED, ability.getId(), mana.getManaProducerId(), ability.getControllerId(), 0, mana.getFlag()));
                break;
            }
        }
    }
View Full Code Here


        return type;
    }

    public void beginStep(Game game, UUID activePlayerId) {
        stepPart = StepPart.PRE;
        game.fireEvent(new GameEvent(preStepEvent, null, null, activePlayerId));
    }
View Full Code Here

        }
    }

    public void endStep(Game game, UUID activePlayerId) {
        stepPart = StepPart.POST;
        game.fireEvent(new GameEvent(postStepEvent, null, null, activePlayerId));
    }
View Full Code Here

        stepPart = StepPart.POST;
        game.fireEvent(new GameEvent(postStepEvent, null, null, activePlayerId));
    }

    public boolean skipStep(Game game, UUID activePlayerId) {
        return game.replaceEvent(new GameEvent(stepEvent, null, null, activePlayerId));
    }
View Full Code Here

    @Override
    public boolean addAttachment(UUID permanentId, Game game) {
        if (!this.attachments.contains(permanentId)) {
            Permanent aura = game.getPermanent(permanentId);
            if (aura != null) {
                if (!game.replaceEvent(new GameEvent(GameEvent.EventType.ENCHANT_PLAYER, playerId, permanentId, aura.getControllerId()))) {
                    this.attachments.add(permanentId);
                    aura.attachTo(playerId, game);
                    game.fireEvent(new GameEvent(GameEvent.EventType.ENCHANTED_PLAYER, playerId, permanentId, aura.getControllerId()));
                    return true;
                }
            }
        }
        return false;
View Full Code Here

    @Override
    public boolean removeAttachment(UUID permanentId, Game game) {
        if (this.attachments.contains(permanentId)) {
            Permanent aura = game.getPermanent(permanentId);
            if (aura != null) {
                if (!game.replaceEvent(new GameEvent(GameEvent.EventType.UNATTACH, playerId, permanentId, aura.getControllerId()))) {
                    this.attachments.remove(permanentId);
                    aura.attachTo(null, game);
                }
                game.fireEvent(new GameEvent(GameEvent.EventType.UNATTACHED, playerId, permanentId, aura.getControllerId()));
                return true;
            }
        }
        return false;
    }
View Full Code Here

                if (ability.getSourceId().equals(getCastSourceIdWithoutMana())) {
                    noMana = true;
                }
                setCastSourceIdWithoutMana(null);
                if (spell.activate(game, noMana)) {
                    GameEvent event = GameEvent.getEvent(GameEvent.EventType.SPELL_CAST, spell.getSpellAbility().getId(), spell.getSpellAbility().getSourceId(), playerId);
                    event.setZone(fromZone);
                    game.fireEvent(event);
                    game.informPlayers(new StringBuilder(name).append(spell.getActivatedMessage(game)).toString());
                    game.removeBookmark(bookmark);
                    resetStoredBookmark(game);
                    return true;
View Full Code Here

    @Override
    public int loseLife(int amount, Game game) {
        if (!canLoseLife) {
            return 0;
        }
        GameEvent event = new GameEvent(GameEvent.EventType.LOSE_LIFE, playerId, playerId, playerId, amount, false);
        if (!game.replaceEvent(event)) {
            this.life -= event.getAmount();
            game.informPlayers(new StringBuilder(this.getName()).append(" loses ").append(event.getAmount()).append(" life").toString());
            game.fireEvent(GameEvent.getEvent(GameEvent.EventType.LOST_LIFE, playerId, playerId, playerId, amount));
            return amount;
        }
        return 0;
    }
View Full Code Here

    @Override
    public int gainLife(int amount, Game game) {
        if (!canGainLife  || amount == 0) {
            return 0;
        }
        GameEvent event = new GameEvent(GameEvent.EventType.GAIN_LIFE, playerId, playerId, playerId, amount, false);
        if (!game.replaceEvent(event)) {
            this.life += event.getAmount();
            game.informPlayers(new StringBuilder(this.getName()).append(" gains ").append(event.getAmount()).append(" life").toString());
            game.fireEvent(GameEvent.getEvent(GameEvent.EventType.GAINED_LIFE, playerId, playerId, playerId, event.getAmount()));
            return event.getAmount();
        }
        return 0;
    }
View Full Code Here


    @SuppressWarnings({"null", "ConstantConditions"})
    private int doDamage(int damage, UUID sourceId, Game game, boolean combatDamage, boolean preventable, ArrayList<UUID> appliedEffects) {
        if (damage > 0 && canDamage(game.getObject(sourceId), game)) {
            GameEvent event = new DamagePlayerEvent(playerId, sourceId, playerId, damage, preventable, combatDamage);
            event.setAppliedEffects(appliedEffects);
            if (!game.replaceEvent(event)) {
                int actualDamage = event.getAmount();
                if (actualDamage > 0) {
                    Permanent source = game.getPermanent(sourceId);
                    if(source == null){
                        MageObject lastKnownInformation = game.getLastKnownInformation(sourceId, Zone.BATTLEFIELD);
                        if(lastKnownInformation != null &&  lastKnownInformation instanceof Permanent){
                            source = (Permanent) lastKnownInformation;
                        }
                    }
                    if (source != null && (source.getAbilities().containsKey(InfectAbility.getInstance().getId()))) {
                        addCounters(CounterType.POISON.createInstance(actualDamage), game);
                    } else {
                        GameEvent damageToLifeLossEvent = new GameEvent(EventType.DAMAGE_CAUSES_LIFE_LOSS, playerId, sourceId, playerId, actualDamage, combatDamage);
                        if (!game.replaceEvent(damageToLifeLossEvent)) {
                            this.loseLife(damageToLifeLossEvent.getAmount(), game);
                        }
                    }
                    if (source != null && source.getAbilities().containsKey(LifelinkAbility.getInstance().getId())) {
                        Player player = game.getPlayer(source.getControllerId());
                        player.gainLife(actualDamage, game);
View Full Code Here

TOP

Related Classes of mage.game.events.GameEvent

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.