mirror of
https://github.com/correl/mage.git
synced 2025-03-30 09:08:36 -09:00
implemented Damage Assignment Order
This commit is contained in:
parent
7b511c5e7a
commit
f1558a255a
8 changed files with 52 additions and 3 deletions
Mage.Common/src/mage/view
Mage.Server.Plugins
Mage.Player.AI/src/main/java/mage/player/ai
Mage.Player.Human/src/mage/player/human
Mage.Server/plugins
Mage/src/mage
|
@ -61,7 +61,7 @@ public class CombatGroupView implements Serializable {
|
|||
if (attacker != null)
|
||||
attackers.put(id, new PermanentView(attacker, game.getCard(attacker.getId())));
|
||||
}
|
||||
for (UUID id: combatGroup.getBlockers()) {
|
||||
for (UUID id: combatGroup.getBlockerOrder()) {
|
||||
Permanent blocker = game.getPermanent(id);
|
||||
if (blocker != null)
|
||||
blockers.put(id, new PermanentView(blocker, game.getCard(blocker.getId())));
|
||||
|
|
|
@ -880,6 +880,12 @@ public class ComputerPlayer<T extends ComputerPlayer<T>> extends PlayerImpl<T> i
|
|||
return min;
|
||||
}
|
||||
|
||||
@Override
|
||||
public UUID chooseBlockerOrder(Cards blockers, Game game) {
|
||||
//TODO: improve this
|
||||
return blockers.iterator().next();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected List<Permanent> getAvailableManaProducers(Game game) {
|
||||
// logger.debug("getAvailableManaProducers");
|
||||
|
|
|
@ -458,6 +458,21 @@ public class HumanPlayer extends PlayerImpl<HumanPlayer> {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public UUID chooseBlockerOrder(Cards blockers, Game game) {
|
||||
while (!abort) {
|
||||
game.fireSelectTargetEvent(playerId, "Pick blocker", blockers, true);
|
||||
waitForResponse();
|
||||
if (response.getUUID() != null) {
|
||||
for (Card card: blockers.getCards(game)) {
|
||||
if (card.getId().equals(response.getUUID()))
|
||||
return card.getId();
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
protected void selectCombatGroup(UUID blockerId, Game game) {
|
||||
TargetAttackingCreature target = new TargetAttackingCreature();
|
||||
game.fireSelectTargetEvent(playerId, "Select attacker to block", target.possibleTargets(null, playerId, game), target.isRequired(), null);
|
||||
|
|
Binary file not shown.
Binary file not shown.
|
@ -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
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Add table
Reference in a new issue