use of com.janfic.games.computercombat.model.animations.ConsumeProgressAnimation in project computercombat by janfic.
the class MultiAbility method doAbility.
@Override
public List<MoveResult> doAbility(MatchState state, Move move) {
List<MoveResult> results = new ArrayList<>();
for (int i = 0; i < abilities.size(); i++) {
Ability ability = abilities.get(i);
List<MoveResult> abilityResults = ability.doAbility(state, move);
if (i != 0) {
for (MoveResult abilityResult : abilityResults) {
int index = -1;
for (MoveAnimation animation : abilityResult.getAnimations()) {
if (animation instanceof ConsumeProgressAnimation) {
index = abilityResult.getAnimations().indexOf(animation);
break;
}
}
if (index >= 0) {
abilityResult.getAnimations().remove(index);
}
}
}
results.addAll(abilityResults);
if (i < abilities.size() - 1) {
for (Player player : state.players) {
if (player.getUID().equals(move.getPlayerUID())) {
state.currentPlayerMove = player.getUID();
}
}
}
}
return results;
}
use of com.janfic.games.computercombat.model.animations.ConsumeProgressAnimation in project computercombat by janfic.
the class Ability method consumeCardProgress.
public static MoveAnimation consumeCardProgress(MatchState newState, Move move) {
UseAbilityMove useAbilityMove = (UseAbilityMove) move;
int index = newState.activeEntities.get(useAbilityMove.getPlayerUID()).indexOf(useAbilityMove.getCard());
if (index != -1) {
newState.activeEntities.get(useAbilityMove.getPlayerUID()).get(index).setProgress(0);
List<Card> used = new ArrayList<>();
used.add(useAbilityMove.getCard());
return new ConsumeProgressAnimation(useAbilityMove.getPlayerUID(), used);
} else {
return null;
}
}
use of com.janfic.games.computercombat.model.animations.ConsumeProgressAnimation in project computercombat by janfic.
the class DrawAbility method doAbility.
@Override
public List<MoveResult> doAbility(MatchState state, Move move) {
List<MoveResult> r = new ArrayList<>();
UseAbilityMove abilityMove = (UseAbilityMove) move;
List<Card> cards = state.activeEntities.get(move.getPlayerUID());
Deck deck = state.decks.get(move.getPlayerUID());
List<Card> drawnCards = new ArrayList<>();
if (cards.size() < 4) {
if (this.cards == null) {
if (deck.size() > 0) {
Card s = deck.draw();
s.setOwnerUID(move.getPlayerUID());
cards.add(s);
drawnCards.add(s);
}
} else {
for (StateAnalyzer<Integer> card : this.cards) {
Card s = SQLAPI.getSingleton().getCardById(card.analyze(state, move), move.getPlayerUID());
s.setOwnerUID(move.getPlayerUID());
s.generateMatchID();
cards.add(s);
drawnCards.add(s);
}
}
}
List<MoveAnimation> animations = new ArrayList<>();
if (abilityMove.getCard().getID() == 0) {
state.computers.get(move.getPlayerUID()).setProgress(0);
} else {
for (Card card : state.activeEntities.get(move.getPlayerUID())) {
if (card.equals(abilityMove.getCard())) {
card.setProgress(0);
}
}
}
List<Card> drained = new ArrayList<>();
drained.add(((UseAbilityMove) (move)).getCard());
ConsumeProgressAnimation drainAnimation = new ConsumeProgressAnimation(move.getPlayerUID(), drained);
DrawAnimation drawAnimation = new DrawAnimation(move.getPlayerUID(), drawnCards);
for (Player player : state.players) {
if (player.getUID().equals(move.getPlayerUID())) {
state.currentPlayerMove = state.getOtherProfile(player.getUID());
}
}
animations.add(drainAnimation);
animations.add(drawAnimation);
MoveResult result = new MoveResult(move, MatchState.record(state), animations);
r.add(result);
return r;
}
use of com.janfic.games.computercombat.model.animations.ConsumeProgressAnimation in project computercombat by janfic.
the class SwitchComponentsAbility method doAbility.
@Override
public List<MoveResult> doAbility(MatchState state, Move move) {
List<MoveResult> results = new ArrayList<>();
UseAbilityMove useAbility = (UseAbilityMove) move;
Component[][] newBoard = state.componentBoard;
Component a = useAbility.getSelectedComponents().get(0);
Component b = useAbility.getSelectedComponents().get(1);
Component bb = newBoard[b.getX()][b.getY()];
Component ba = newBoard[a.getX()][a.getY()];
bb.invalidate();
ba.invalidate();
ba.invalidateNeighbors();
bb.invalidateNeighbors();
List<Card> drained = new ArrayList<>();
drained.add(((UseAbilityMove) (move)).getCard());
List<MoveAnimation> anims = new ArrayList<>();
anims.add(new ConsumeProgressAnimation(move.getPlayerUID(), drained));
anims.add(new SwitchAnimation(bb, ba));
MoveResult r = new MoveResult(move, MatchState.record(state), anims);
List<MoveResult> collectCheckResults = state.results(move);
results.add(r);
results.addAll(collectCheckResults);
return results;
}
use of com.janfic.games.computercombat.model.animations.ConsumeProgressAnimation 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