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