implemented Damage Assignment Order

This commit is contained in:
BetaSteward 2011-06-16 23:02:24 -04:00
parent 7b511c5e7a
commit f1558a255a
8 changed files with 52 additions and 3 deletions

View file

@ -61,7 +61,7 @@ public class Combat implements Serializable, Copyable<Combat> {
protected List<CombatGroup> groups = new ArrayList<CombatGroup>();
protected Set<UUID> defenders = new HashSet<UUID>();
protected UUID attackerId;
protected UUID attackerId; //the player that is attacking
public Combat() {}
@ -346,7 +346,9 @@ public class Combat implements Serializable, Copyable<Combat> {
}
public void damageAssignmentOrder(Game game) {
//TODO: set damage assignment order
for (CombatGroup group: groups) {
group.pickBlockerOrder(attackerId, game);
}
}
@Override

View file

@ -34,6 +34,8 @@ import java.util.*;
import mage.abilities.keyword.DoubleStrikeAbility;
import mage.abilities.keyword.FirstStrikeAbility;
import mage.abilities.keyword.TrampleAbility;
import mage.cards.Cards;
import mage.cards.CardsImpl;
import mage.game.Game;
import mage.game.events.GameEvent;
import mage.game.permanent.Permanent;
@ -271,6 +273,29 @@ public class CombatGroup implements Serializable, Copyable<CombatGroup> {
}
}
public void pickBlockerOrder(UUID playerId, Game game) {
if (blockers.isEmpty())
return;
Player player = game.getPlayer(playerId);
List<UUID> blockerList = new ArrayList<UUID>(blockers);
blockerOrder.clear();
while (true) {
if (blockerList.size() == 1) {
blockerOrder.add(blockerList.get(0));
break;
}
else {
Cards blockerCards = new CardsImpl();
for (UUID blockerId: blockerList) {
blockerCards.add(game.getCard(blockerId));
}
UUID blockerId = player.chooseBlockerOrder(blockerCards, game);
blockerOrder.add(blockerId);
blockerList.remove(blockerId);
}
}
}
public int totalAttackerDamage(Game game) {
int total = 0;
for (UUID attackerId: attackers) {

View file

@ -158,6 +158,7 @@ public interface Player extends MageItem, Copyable<Player> {
public abstract TriggeredAbility chooseTriggeredAbility(TriggeredAbilities abilities, Game game);
public abstract void selectAttackers(Game game);
public abstract void selectBlockers(Game game);
public abstract UUID chooseBlockerOrder(Cards blockers, Game game);
public abstract void assignDamage(int damage, List<UUID> targets, UUID sourceId, Game game);
public abstract int getAmount(int min, int max, String message, Game game);
public abstract void sideboard(Match match, Deck deck);