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