Search in sources :

Example 1 with ReceiveDamageAnimation

use of com.janfic.games.computercombat.model.animations.ReceiveDamageAnimation in project computercombat by janfic.

the class FocusedDamageAbility method doAbility.

@Override
public List<MoveResult> doAbility(MatchState state, Move move) {
    List<MoveResult> moveResults = new ArrayList<>();
    UseAbilityMove abilityMove = (UseAbilityMove) move;
    List<Card> destroyed = new ArrayList<>();
    List<MoveAnimation> animation = new ArrayList<>();
    MoveAnimation consume = Ability.consumeCardProgress(state, move);
    animation.add(consume);
    int index = state.activeEntities.get(abilityMove.getCard().getOwnerUID()).indexOf(abilityMove.getCard());
    state.activeEntities.get(abilityMove.getPlayerUID()).get(index).setProgress(0);
    for (Card selectedSoftware : abilityMove.getSelectedSoftwares()) {
        for (String playerUID : state.activeEntities.keySet()) {
            for (Card card : state.activeEntities.get(playerUID)) {
                if (card.equals(selectedSoftware)) {
                    int damage = amount.analyze(state, move);
                    card.recieveDamage(damage);
                    animation.add(new ReceiveDamageAnimation(selectedSoftware, damage, card.getOwnerUID()));
                    if (card.isDead()) {
                        destroyed.add(card);
                    }
                }
            }
        }
    }
    state.currentPlayerMove = state.getOtherProfile(state.currentPlayerMove);
    MoveResult result = new MoveResult(move, MatchState.record(state), animation);
    moveResults.add(result);
    if (destroyed.isEmpty() == false) {
        DestroyCardAbility destroyAbility = new DestroyCardAbility(destroyed);
        List<MoveResult> r = destroyAbility.doAbility(state, move);
        moveResults.addAll(r);
    }
    return moveResults;
}
Also used : MoveAnimation(com.janfic.games.computercombat.model.moves.MoveAnimation) ReceiveDamageAnimation(com.janfic.games.computercombat.model.animations.ReceiveDamageAnimation) UseAbilityMove(com.janfic.games.computercombat.model.moves.UseAbilityMove) ArrayList(java.util.ArrayList) MoveResult(com.janfic.games.computercombat.model.moves.MoveResult) Card(com.janfic.games.computercombat.model.Card)

Example 2 with ReceiveDamageAnimation

use of com.janfic.games.computercombat.model.animations.ReceiveDamageAnimation in project computercombat by janfic.

the class DamageAllAbility method doAbility.

@Override
public List<MoveResult> doAbility(MatchState state, Move move) {
    List<MoveResult> results = new ArrayList<>();
    UseAbilityMove abilityMove = (UseAbilityMove) move;
    List<Card> destroyed = new ArrayList<>();
    List<MoveAnimation> animation = new ArrayList<>();
    int index = state.activeEntities.get(abilityMove.getCard().getOwnerUID()).indexOf(abilityMove.getCard());
    state.activeEntities.get(abilityMove.getPlayerUID()).get(index).setProgress(0);
    for (Card card : state.getAllCards()) {
        if (filter == null || filter.filter(card, state, move)) {
            int damage = amount.analyze(state, move);
            animation.add(new ReceiveDamageAnimation(card, damage, card.getOwnerUID()));
            card.recieveDamage(damage);
            if (card.isDead()) {
                destroyed.add(card);
            }
        }
    }
    state.currentPlayerMove = state.getOtherProfile(state.currentPlayerMove);
    MoveResult result = new MoveResult(move, MatchState.record(state), animation);
    results.add(result);
    if (destroyed.isEmpty() == false) {
        DestroyCardAbility destroyAbility = new DestroyCardAbility(destroyed);
        List<MoveResult> r = destroyAbility.doAbility(state, move);
        results.addAll(r);
    }
    List<Card> drained = new ArrayList<>();
    drained.add(((UseAbilityMove) (move)).getCard());
    results.get(0).getAnimations().add(0, new ConsumeProgressAnimation(move.getPlayerUID(), drained));
    return results;
}
Also used : MoveAnimation(com.janfic.games.computercombat.model.moves.MoveAnimation) ReceiveDamageAnimation(com.janfic.games.computercombat.model.animations.ReceiveDamageAnimation) UseAbilityMove(com.janfic.games.computercombat.model.moves.UseAbilityMove) ArrayList(java.util.ArrayList) MoveResult(com.janfic.games.computercombat.model.moves.MoveResult) ConsumeProgressAnimation(com.janfic.games.computercombat.model.animations.ConsumeProgressAnimation) Card(com.janfic.games.computercombat.model.Card)

Aggregations

Card (com.janfic.games.computercombat.model.Card)2 ReceiveDamageAnimation (com.janfic.games.computercombat.model.animations.ReceiveDamageAnimation)2 MoveAnimation (com.janfic.games.computercombat.model.moves.MoveAnimation)2 MoveResult (com.janfic.games.computercombat.model.moves.MoveResult)2 UseAbilityMove (com.janfic.games.computercombat.model.moves.UseAbilityMove)2 ArrayList (java.util.ArrayList)2 ConsumeProgressAnimation (com.janfic.games.computercombat.model.animations.ConsumeProgressAnimation)1