Inform players of combat damage assignment order in log

This commit is contained in:
Alex W. Jackson 2022-09-21 20:17:58 -04:00
parent 493a9d2c6c
commit ecd43c07e2

View file

@ -655,6 +655,9 @@ public class CombatGroup implements Serializable, Copyable<CombatGroup> {
blockerList.remove(blockerId);
}
}
if (!game.isSimulation() && blockerOrder.size() > 1) {
logDamageAssignmentOrder("Creatures blocking ", attackers, blockerOrder, game);
}
}
public void pickAttackerOrder(UUID playerId, Game game) {
@ -681,6 +684,37 @@ public class CombatGroup implements Serializable, Copyable<CombatGroup> {
attackerList.remove(attackerId);
}
}
if (!game.isSimulation() && attackerOrder.size() > 1) {
logDamageAssignmentOrder("Creatures blocked by ", blockers, attackerOrder, game);
}
}
private void logDamageAssignmentOrder(String prefix, List<UUID> assignedFor, List<UUID> assignedOrder, Game game) {
StringBuilder sb = new StringBuilder(prefix);
boolean first = true;
for (UUID id : assignedFor) {
Permanent perm = game.getPermanent(id);
if (perm != null) {
if (!first) {
sb.append(", ");
}
sb.append(perm.getLogName());
first = false;
}
}
sb.append(" are ordered: ");
first = true;
for (UUID id : assignedOrder) {
Permanent perm = game.getPermanent(id);
if (perm != null) {
if (!first) {
sb.append(", ");
}
sb.append(perm.getLogName());
first = false;
}
}
game.informPlayers(sb.toString());
}
public int totalAttackerDamage(Game game) {