Search in sources :

Example 41 with Card

use of com.janfic.games.computercombat.model.Card in project computercombat by janfic.

the class ChargeAbilitiesHeuristicAnalyzer method getMaxCharges.

public int getMaxCharges(MoveResult result) {
    int totalCharge = 0;
    String currentUID = result.getMove().getPlayerUID();
    String opponentUID = result.getState().getOtherProfile(currentUID);
    for (Card card : result.getState().activeEntities.get(opponentUID)) {
        totalCharge += card.getRunRequirements();
    }
    totalCharge += result.getState().computers.get(opponentUID).getRunProgress();
    return totalCharge;
}
Also used : Card(com.janfic.games.computercombat.model.Card)

Example 42 with Card

use of com.janfic.games.computercombat.model.Card in project computercombat by janfic.

the class ChargedAbilitiesHeuristicAnalyzer method analyze.

@Override
public float analyze(List<MoveResult> results) {
    MatchState oldState = results.get(0).getState();
    Map<String, List<Card>> activeEntities = oldState.activeEntities;
    String playerUid = results.get(0).getMove().getPlayerUID();
    List<Card> activeCards = activeEntities.get(playerUid);
    Integer oldRunProgress = 0;
    Integer totalRunRequirements = 0;
    for (Card activeCard : activeCards) {
        oldRunProgress += activeCard.getRunProgress();
        totalRunRequirements += activeCard.getRunRequirements();
    }
    MatchState endState = results.get(results.size() - 1).getState();
    Map<String, List<Card>> newActiveEntities = endState.activeEntities;
    List<Card> newActiveCards = newActiveEntities.get(playerUid);
    Integer newRunProgress = 0;
    for (Card newActiveCard : newActiveCards) {
        newRunProgress += newActiveCard.getRunProgress();
    }
    return Math.max(0, (newRunProgress - oldRunProgress) / Math.max(totalRunRequirements, 1));
}
Also used : MatchState(com.janfic.games.computercombat.model.match.MatchState) List(java.util.List) 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