Search in sources :

Example 1 with TransformCardAnimation

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

the class TransformCardAbility method doAbility.

@Override
public List<MoveResult> doAbility(MatchState state, Move move) {
    List<MoveResult> results = new ArrayList<>();
    List<MoveAnimation> animations = new ArrayList<>();
    MoveAnimation consumeProgress = Ability.consumeCardProgress(state, move);
    List<Card> old = new ArrayList<>();
    List<Card> newC = new ArrayList<>();
    for (CardFilter filter : oldCards) {
        for (String uid : state.activeEntities.keySet()) {
            for (int i = 0; i < state.activeEntities.get(uid).size(); i++) {
                Card oldCard = state.activeEntities.get(uid).get(i);
                if (filter.filter(oldCard, state, move)) {
                    Card newCard = SQLAPI.getSingleton().getCardById(newCards.get(oldCards.indexOf(filter)), oldCard.getOwnerUID());
                    newCard.generateMatchID();
                    state.activeEntities.get(uid).set(i, newCard);
                    old.add(oldCard);
                    newC.add(newCard);
                }
            }
        }
    }
    if (consumeProgress != null) {
        animations.add(consumeProgress);
    }
    animations.add(new TransformCardAnimation(old, newC));
    state.currentPlayerMove = state.getOtherProfile(state.currentPlayerMove);
    MoveResult result = new MoveResult(move, MatchState.record(state), animations);
    results.add(result);
    return results;
}
Also used : CardFilter(com.janfic.games.computercombat.util.CardFilter) MoveAnimation(com.janfic.games.computercombat.model.moves.MoveAnimation) ArrayList(java.util.ArrayList) TransformCardAnimation(com.janfic.games.computercombat.model.animations.TransformCardAnimation) MoveResult(com.janfic.games.computercombat.model.moves.MoveResult) Card(com.janfic.games.computercombat.model.Card)

Aggregations

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