Search in sources :

Example 1 with DestroyCardAnimation

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

the class DestroyCardAbility method doAbility.

@Override
public List<MoveResult> doAbility(MatchState state, Move move) {
    List<MoveResult> results = new ArrayList<>();
    List<MoveAnimation> animations = new ArrayList<>();
    List<Card> removed = new ArrayList<>();
    for (Card card : destroyed) {
        for (Card c : state.activeEntities.get(card.getOwnerUID())) {
            if (c.equals(card)) {
                removed.add(c);
                List<Card> destroy = new ArrayList<>();
                destroy.add(c);
                animations.add(new DestroyCardAnimation(c.getOwnerUID(), destroy));
            }
        }
    }
    for (Card card : removed) {
        state.activeEntities.get(card.getOwnerUID()).remove(card);
    }
    MoveResult result = new MoveResult(move, MatchState.record(state), animations);
    results.add(result);
    return results;
}
Also used : MoveAnimation(com.janfic.games.computercombat.model.moves.MoveAnimation) ArrayList(java.util.ArrayList) DestroyCardAnimation(com.janfic.games.computercombat.model.animations.DestroyCardAnimation) MoveResult(com.janfic.games.computercombat.model.moves.MoveResult) Card(com.janfic.games.computercombat.model.Card)

Aggregations

Card (com.janfic.games.computercombat.model.Card)1 DestroyCardAnimation (com.janfic.games.computercombat.model.animations.DestroyCardAnimation)1 MoveAnimation (com.janfic.games.computercombat.model.moves.MoveAnimation)1 MoveResult (com.janfic.games.computercombat.model.moves.MoveResult)1 ArrayList (java.util.ArrayList)1