Search in sources :

Example 6 with MoveAnimation

use of com.janfic.games.computercombat.model.moves.MoveAnimation 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 7 with MoveAnimation

use of com.janfic.games.computercombat.model.moves.MoveAnimation 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 8 with MoveAnimation

use of com.janfic.games.computercombat.model.moves.MoveAnimation 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 9 with MoveAnimation

use of com.janfic.games.computercombat.model.moves.MoveAnimation 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;
}
Also used : Player(com.janfic.games.computercombat.model.Player) MoveAnimation(com.janfic.games.computercombat.model.moves.MoveAnimation) ArrayList(java.util.ArrayList) Deck(com.janfic.games.computercombat.model.Deck) ConsumeProgressAnimation(com.janfic.games.computercombat.model.animations.ConsumeProgressAnimation) Card(com.janfic.games.computercombat.model.Card) DrawAnimation(com.janfic.games.computercombat.model.animations.DrawAnimation) UseAbilityMove(com.janfic.games.computercombat.model.moves.UseAbilityMove) MoveResult(com.janfic.games.computercombat.model.moves.MoveResult)

Example 10 with MoveAnimation

use of com.janfic.games.computercombat.model.moves.MoveAnimation 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;
}
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) Component(com.janfic.games.computercombat.model.Component) ConsumeProgressAnimation(com.janfic.games.computercombat.model.animations.ConsumeProgressAnimation) SwitchAnimation(com.janfic.games.computercombat.model.animations.SwitchAnimation) Card(com.janfic.games.computercombat.model.Card)

Aggregations

MoveAnimation (com.janfic.games.computercombat.model.moves.MoveAnimation)15 MoveResult (com.janfic.games.computercombat.model.moves.MoveResult)15 ArrayList (java.util.ArrayList)14 Card (com.janfic.games.computercombat.model.Card)11 UseAbilityMove (com.janfic.games.computercombat.model.moves.UseAbilityMove)6 Component (com.janfic.games.computercombat.model.Component)5 ConsumeProgressAnimation (com.janfic.games.computercombat.model.animations.ConsumeProgressAnimation)5 Ability (com.janfic.games.computercombat.model.Ability)2 Player (com.janfic.games.computercombat.model.Player)2 CollectAnimation (com.janfic.games.computercombat.model.animations.CollectAnimation)2 ReceiveDamageAnimation (com.janfic.games.computercombat.model.animations.ReceiveDamageAnimation)2 SpawnAnimation (com.janfic.games.computercombat.model.animations.SpawnAnimation)2 List (java.util.List)2 Deck (com.janfic.games.computercombat.model.Deck)1 GameRules (com.janfic.games.computercombat.model.GameRules)1 AttackAnimation (com.janfic.games.computercombat.model.animations.AttackAnimation)1 CardToFrontAnimation (com.janfic.games.computercombat.model.animations.CardToFrontAnimation)1 CascadeAnimation (com.janfic.games.computercombat.model.animations.CascadeAnimation)1 ChangeStatAnim (com.janfic.games.computercombat.model.animations.ChangeStatAnim)1 DestroyCardAnimation (com.janfic.games.computercombat.model.animations.DestroyCardAnimation)1