Search in sources :

Example 1 with Match

use of pl.themolka.arcade.match.Match in project Arcade2 by ShootGame.

the class Point method heartbeat.

public void heartbeat(long ticks) {
    if (this.isPermanent() && this.isCompleted()) {
        return;
    }
    Match match = this.game.getMatch();
    Multimap<Participator, GamePlayer> competitors = ArrayListMultimap.create();
    for (GamePlayer player : this.getPlayers()) {
        if (this.canCapture(player) && this.canDominate(player)) {
            Participator competitor = match.findWinnerByPlayer(player);
            if (competitor != null && (competitor.equals(player) || this.canCapture(competitor))) {
                competitors.put(competitor, player);
            }
        }
    }
    Multimap<Participator, GamePlayer> dominators = this.getDominatorStrategy().getDominators(competitors);
    if (dominators == null) {
        dominators = DominatorStrategy.EMPTY_DOMINATORS;
    }
    List<Participator> canCapture = new ArrayList<>();
    for (Participator competitor : dominators.keySet()) {
        if (this.canCapture(competitor)) {
            canCapture.add(competitor);
        }
    }
    // Heartbeat the current state.
    Participator oldOwner = this.getOwner();
    this.getState().heartbeat(ticks, match, competitors, dominators, canCapture, oldOwner);
    Participator newOwner = this.getOwner();
    double pointReward = this.getPointReward();
    if (oldOwner != null && newOwner != null && oldOwner.equals(newOwner) && pointReward != Score.ZERO) {
        // Give reward points for owning the point.
        this.heartbeatReward(oldOwner, pointReward);
    }
}
Also used : Participator(pl.themolka.arcade.game.Participator) GamePlayer(pl.themolka.arcade.game.GamePlayer) ArrayList(java.util.ArrayList) Match(pl.themolka.arcade.match.Match)

Aggregations

ArrayList (java.util.ArrayList)1 GamePlayer (pl.themolka.arcade.game.GamePlayer)1 Participator (pl.themolka.arcade.game.Participator)1 Match (pl.themolka.arcade.match.Match)1