Search in sources :

Example 11 with Card

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;
}
Also used : Action(com.badlogic.gdx.scenes.scene2d.Action) ChangeStatAction(com.janfic.games.computercombat.model.animations.ChangeStatAnim.ChangeStatAction) SoftwareActor(com.janfic.games.computercombat.actors.SoftwareActor) ArrayList(java.util.ArrayList) List(java.util.List) ArrayList(java.util.ArrayList) Card(com.janfic.games.computercombat.model.Card) ChangeStatAction(com.janfic.games.computercombat.model.animations.ChangeStatAnim.ChangeStatAction)

Example 12 with Card

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

Example 13 with Card

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;
}
Also used : MoveAnimation(com.janfic.games.computercombat.model.moves.MoveAnimation) ChangeStatAnim(com.janfic.games.computercombat.model.animations.ChangeStatAnim) ArrayList(java.util.ArrayList) MoveResult(com.janfic.games.computercombat.model.moves.MoveResult) Card(com.janfic.games.computercombat.model.Card)

Example 14 with Card

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;
}
Also used : MoveAnimation(com.janfic.games.computercombat.model.moves.MoveAnimation) ArrayList(java.util.ArrayList) DestroyCardAnimation(com.janfic.games.computercombat.model.animations.DestroyCardAnimation) MoveResult(com.janfic.games.computercombat.model.moves.MoveResult) Card(com.janfic.games.computercombat.model.Card)

Example 15 with Card

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;
}
Also used : MoveResult(com.janfic.games.computercombat.model.moves.MoveResult) Card(com.janfic.games.computercombat.model.Card)

Aggregations

Card (com.janfic.games.computercombat.model.Card)42 ArrayList (java.util.ArrayList)28 List (java.util.List)12 MoveResult (com.janfic.games.computercombat.model.moves.MoveResult)11 MoveAnimation (com.janfic.games.computercombat.model.moves.MoveAnimation)10 Action (com.badlogic.gdx.scenes.scene2d.Action)9 SoftwareActor (com.janfic.games.computercombat.actors.SoftwareActor)8 SQLIntegrityConstraintViolationException (java.sql.SQLIntegrityConstraintViolationException)7 Component (com.janfic.games.computercombat.model.Component)6 ResultSet (java.sql.ResultSet)6 Statement (java.sql.Statement)6 HashMap (java.util.HashMap)6 InputEvent (com.badlogic.gdx.scenes.scene2d.InputEvent)5 Deck (com.janfic.games.computercombat.model.Deck)5 UseAbilityMove (com.janfic.games.computercombat.model.moves.UseAbilityMove)5 ClickListener (com.badlogic.gdx.scenes.scene2d.utils.ClickListener)4 CollectionCard (com.janfic.games.computercombat.actors.CollectionCard)4 Collection (com.janfic.games.computercombat.model.Collection)4 Table (com.badlogic.gdx.scenes.scene2d.ui.Table)3 ComputerActor (com.janfic.games.computercombat.actors.ComputerActor)3