Search in sources :

Example 1 with CardToFrontAnimation

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

the class CardToFrontAbility method doAbility.

@Override
public List<MoveResult> doAbility(MatchState state, Move move) {
    List<MoveResult> results = new ArrayList<>();
    UseAbilityMove useAbilityMove = (UseAbilityMove) move;
    MoveAnimation consume = Ability.consumeCardProgress(state, move);
    List<Card> toFront = new ArrayList<>();
    toFront.addAll(useAbilityMove.getSelectedSoftwares());
    for (Card card : useAbilityMove.getSelectedSoftwares()) {
        int cardIndex = state.activeEntities.get(card.getOwnerUID()).indexOf(card);
        Card newStateCard = state.activeEntities.get(card.getOwnerUID()).get(cardIndex);
        state.activeEntities.get(card.getOwnerUID()).remove(cardIndex);
        state.activeEntities.get(card.getOwnerUID()).add(0, newStateCard);
    }
    state.currentPlayerMove = state.getOtherProfile(state.currentPlayerMove);
    List<MoveAnimation> animations = new ArrayList<>();
    animations.add(consume);
    animations.add(new CardToFrontAnimation(toFront));
    MoveResult result = new MoveResult(move, MatchState.record(state), animations);
    results.add(result);
    return results;
}
Also used : MoveAnimation(com.janfic.games.computercombat.model.moves.MoveAnimation) 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) CardToFrontAnimation(com.janfic.games.computercombat.model.animations.CardToFrontAnimation)

Aggregations

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