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;
}
Aggregations