mirror of
https://github.com/correl/mage.git
synced 2024-11-15 19:19:33 +00:00
Added new method to add an attacker later to combat.
This commit is contained in:
parent
82bb03ba86
commit
88e5ddb807
1 changed files with 26 additions and 0 deletions
|
@ -122,6 +122,32 @@ public class Combat implements Serializable, Copyable<Combat> {
|
||||||
this.attackerId = playerId;
|
this.attackerId = playerId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add an additional attacker to the combat (e.g. token of Geist of Saint Traft)
|
||||||
|
* This method doesn't trigger ATTACKER_DECLARED event (as intended).
|
||||||
|
*
|
||||||
|
* @param creatureId - creature that shall be added to the combat
|
||||||
|
* @param game
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public boolean addAttackingCreature(UUID creatureId, Game game) {
|
||||||
|
Player player = game.getPlayer(attackerId);
|
||||||
|
if (defenders.size() == 1) {
|
||||||
|
declareAttacker(creatureId, defenders.iterator().next(), game);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
TargetDefender target = new TargetDefender(defenders, creatureId);
|
||||||
|
target.setRequired(true);
|
||||||
|
player.chooseTarget(Outcome.Damage, target, null, game);
|
||||||
|
if (target.getFirstTarget() != null) {
|
||||||
|
declareAttacker(creatureId, target.getFirstTarget(), game);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
public void selectAttackers(Game game) {
|
public void selectAttackers(Game game) {
|
||||||
if (!game.replaceEvent(GameEvent.getEvent(GameEvent.EventType.DECLARING_ATTACKERS, attackerId, attackerId))) {
|
if (!game.replaceEvent(GameEvent.getEvent(GameEvent.EventType.DECLARING_ATTACKERS, attackerId, attackerId))) {
|
||||||
Player player = game.getPlayer(attackerId);
|
Player player = game.getPlayer(attackerId);
|
||||||
|
|
Loading…
Reference in a new issue