Package mage.game.events

Examples of mage.game.events.DamagePlayerEvent


  }

  @Override
  public int damage(int damage, UUID sourceId, Game game, boolean combatDamage, boolean preventable) {
    if (damage > 0 && canDamage(game.getObject(sourceId))) {
      GameEvent event = new DamagePlayerEvent(playerId, sourceId, playerId, damage, preventable, combatDamage);
      if (!game.replaceEvent(event)) {
        int actualDamage = event.getAmount();
        if (actualDamage > 0) {
          actualDamage = this.loseLife(actualDamage, game);
          Permanent source = game.getPermanent(sourceId);
          if (source != null && source.getAbilities().containsKey(LifelinkAbility.getInstance().getId())) {
            Player player = game.getPlayer(source.getControllerId());
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){
View Full Code Here

        return true;
    }

    @Override
    public boolean replaceEvent(GameEvent event, Ability source, Game game) {
        DamagePlayerEvent damageEvent = (DamagePlayerEvent) event;
        int actualDamage = damageEvent.getAmount();
        if (actualDamage > 0) {
            Player player = game.getPlayer(damageEvent.getPlayerId());
            Permanent damageSource = game.getPermanent(damageEvent.getSourceId());
            player.addCounters(CounterType.POISON.createInstance(actualDamage), game);
            if (damageSource != null && damageSource.getAbilities().containsKey(LifelinkAbility.getInstance().getId())) {
                Player controlPlayer = game.getPlayer(damageSource.getControllerId());
                controlPlayer.gainLife(actualDamage, game);
            }
            game.fireEvent(new DamagedPlayerEvent(damageEvent.getPlayerId(), damageEvent.getSourceId(), damageEvent.getPlayerId(), actualDamage, damageEvent.isCombatDamage()));
        }
        return true;
    }
View Full Code Here

    }

    @Override
    public boolean applies(GameEvent event, Ability source, Game game) {
        if (event.getType() == GameEvent.EventType.DAMAGE_PLAYER && event instanceof DamagePlayerEvent) {
            DamagePlayerEvent damageEvent = (DamagePlayerEvent) event;
            if (damageEvent.isCombatDamage()) {
                Permanent permanent = game.getPermanent(event.getSourceId());
                if (permanent != null && permanent.hasSubtype("Zombie")) {
                    return true;
                }
            }
View Full Code Here

        super(effect);
    }

    @Override
    public boolean replaceEvent(GameEvent event, Ability source, Game game) {
        DamagePlayerEvent damageEvent = (DamagePlayerEvent) event;
        Player damagedPlayer = game.getPlayer(damageEvent.getTargetId());

        if (damageEvent.isCombatDamage()) {
            Permanent p = game.getPermanent(source.getSourceId());
            if (p != null) {
                p.addCounters(CounterType.P1P1.createInstance(damageEvent.getAmount()), game);
                if (damagedPlayer != null) {
                    cards = damagedPlayer.getLibrary().getTopCards(game, damageEvent.getAmount());
                }
                for (Card card : cards) {
                    card.moveToZone(Zone.GRAVEYARD, source.getSourceId(), game, false);
                }
            }
View Full Code Here

    @Override
    public boolean applies(GameEvent event, Ability source, Game game) {
        if (event.getType() == GameEvent.EventType.DAMAGE_PLAYER
                && event.getSourceId().equals(source.getSourceId())) {
            DamagePlayerEvent damageEvent = (DamagePlayerEvent) event;
            if (damageEvent.isCombatDamage()) {
                return true;
            }
        }
        return false;
    }
View Full Code Here

        super(effect);
    }

    @Override
    public boolean replaceEvent(GameEvent event, Ability source, Game game) {
        DamagePlayerEvent damageEvent = (DamagePlayerEvent) event;
        Permanent p = game.getPermanent(source.getSourceId());
        if (p != null) {
            p.damage(damageEvent.getAmount(), event.getSourceId(), game, damageEvent.isCombatDamage(), damageEvent.isPreventable());
            return true;
        }
        return true;
    }
View Full Code Here

        super(effect);
    }

    @Override
    public boolean replaceEvent(GameEvent event, Ability source, Game game) {
        DamagePlayerEvent damageEvent = (DamagePlayerEvent) event;
    Permanent equipment = game.getPermanent(source.getSourceId());
    if(equipment != null){
            Permanent p = game.getPermanent(equipment.getAttachedTo());
      if (p != null) {
        p.damage(damageEvent.getAmount(), event.getSourceId(), game, damageEvent.isCombatDamage(), damageEvent.isPreventable());
        return true;
      }
    }
        return true;
    }
View Full Code Here

        super(effect);
    }

    @Override
    public boolean replaceEvent(GameEvent event, Ability source, Game game) {
        DamagePlayerEvent damageEvent = (DamagePlayerEvent) event;
        Permanent p = game.getPermanent(source.getSourceId());
        if (p != null) {
            p.damage(damageEvent.getAmount(), event.getSourceId(), game, damageEvent.isCombatDamage(), damageEvent.isPreventable());
            return true;
        }
        return true;
    }
View Full Code Here

TOP

Related Classes of mage.game.events.DamagePlayerEvent

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.