use of com.janfic.games.computercombat.model.Card in project computercombat by janfic.
the class ReceiveDamageAnimation method animate.
@Override
public List<List<Action>> animate(String currentPlayerUID, String playerUID, MatchScreen screen, float animationSpeed) {
List<List<Action>> animations = new ArrayList<>();
List<Action> changeColorActions = new ArrayList<>();
SoftwareActor softwareActor = screen.getSoftwareActorByMatchID(reciever.getOwnerUID(), reciever.getMatchID());
Card a = softwareActor.getSoftware();
int armorDecrease = a.getArmor() > 0 ? Math.min(a.getArmor(), damage) : 0;
int healthDecrease = a.getHealth() <= damage - armorDecrease ? a.getHealth() : damage - armorDecrease;
Action attackedAction = Actions.sequence(Actions.delay(0.5f * animationSpeed), Actions.color(Color.RED), Actions.color(Color.WHITE, 0.4f * animationSpeed), new ChangeStatAction(0.5f * animationSpeed, "armor", -armorDecrease), new ChangeStatAction(0.5f * animationSpeed, "health", -healthDecrease));
attackedAction.setActor(softwareActor);
changeColorActions.add(attackedAction);
animations.add(changeColorActions);
return animations;
}
use of com.janfic.games.computercombat.model.Card 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;
}
use of com.janfic.games.computercombat.model.Card in project computercombat by janfic.
the class ChangeDefenseAbility method doAbility.
@Override
public List<MoveResult> doAbility(MatchState state, Move move) {
List<MoveResult> results = new ArrayList<>();
String currentUID = move.getPlayerUID();
String opponentUID = state.getOtherProfile(state.currentPlayerMove);
List<MoveAnimation> animation = new ArrayList<>();
MoveAnimation consume = Ability.consumeCardProgress(state, move);
animation.add(consume);
for (Card card : state.getAllCards()) {
if (cardFilter.filter(card, state, move)) {
int amount = this.amount.analyze(state, move);
card.changeArmor(amount);
animation.add(new ChangeStatAnim("armor", amount, card, card.getOwnerUID()));
}
}
state.currentPlayerMove = state.getOtherProfile(state.currentPlayerMove);
MoveResult result = new MoveResult(move, MatchState.record(state), animation);
results.add(result);
return results;
}
use of com.janfic.games.computercombat.model.Card in project computercombat by janfic.
the class DestroyCardAbility method doAbility.
@Override
public List<MoveResult> doAbility(MatchState state, Move move) {
List<MoveResult> results = new ArrayList<>();
List<MoveAnimation> animations = new ArrayList<>();
List<Card> removed = new ArrayList<>();
for (Card card : destroyed) {
for (Card c : state.activeEntities.get(card.getOwnerUID())) {
if (c.equals(card)) {
removed.add(c);
List<Card> destroy = new ArrayList<>();
destroy.add(c);
animations.add(new DestroyCardAnimation(c.getOwnerUID(), destroy));
}
}
}
for (Card card : removed) {
state.activeEntities.get(card.getOwnerUID()).remove(card);
}
MoveResult result = new MoveResult(move, MatchState.record(state), animations);
results.add(result);
return results;
}
use of com.janfic.games.computercombat.model.Card in project computercombat by janfic.
the class CompletelyChargeAbilitiesHeuristicAnalyzer method analyze.
@Override
public float analyze(List<MoveResult> results) {
float r = 0;
MoveResult before = results.get(0);
MoveResult end = results.get(results.size() - 1);
String currentUID = before.getMove().getPlayerUID();
List<Card> cards = end.getState().activeEntities.get(currentUID);
List<Card> beforeCards = before.getState().activeEntities.get(currentUID);
for (Card card : cards) {
if (card.getRunProgress() == card.getRunRequirements()) {
// this is fully charged. was it charged before?
before.getState().activeEntities.get(currentUID);
for (Card beforeCard : beforeCards) {
if (beforeCard.getMatchID() == card.getMatchID() && beforeCard.getRunProgress() < beforeCard.getRunRequirements()) {
r = 1;
break;
}
}
}
}
return r;
}
Aggregations