mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-19 12:18:00 +00:00
Improve texts for combat in both log and window
This commit is contained in:
@@ -99,6 +99,8 @@ public class InputAttack extends InputBase {
|
|||||||
public final void selectButtonOK() {
|
public final void selectButtonOK() {
|
||||||
// Propaganda costs could have been paid here.
|
// Propaganda costs could have been paid here.
|
||||||
setCurrentDefender(null); // remove highlights
|
setCurrentDefender(null); // remove highlights
|
||||||
|
|
||||||
|
game.getPhaseHandler().setCombat(!game.getCombat().getAttackers().isEmpty());
|
||||||
game.getPhaseHandler().setPlayersPriorityPermission(false);
|
game.getPhaseHandler().setPlayersPriorityPermission(false);
|
||||||
Singletons.getModel().getMatch().getInput().updateObservers();
|
Singletons.getModel().getMatch().getInput().updateObservers();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -265,17 +265,19 @@ public class ComputerUtilBlock {
|
|||||||
return blockers;
|
return blockers;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* <p>
|
|
||||||
* sortPotentialAttackers.
|
public final static List<List<Card>> sortAttackerByDefender(Combat combat) {
|
||||||
* </p>
|
List<GameEntity> defenders = combat.getDefenders();
|
||||||
*
|
final ArrayList<List<Card>> attackers = new ArrayList<List<Card>>(defenders.size());
|
||||||
* @param combat
|
for (GameEntity defender : defenders) {
|
||||||
* a {@link forge.game.phase.Combat} object.
|
attackers.add(combat.getAttackersOf(defender));
|
||||||
* @return a {@link forge.CardList} object.
|
}
|
||||||
*/
|
return attackers;
|
||||||
|
}
|
||||||
|
|
||||||
public static List<Card> sortPotentialAttackers(final Player ai, final Combat combat) {
|
public static List<Card> sortPotentialAttackers(final Player ai, final Combat combat) {
|
||||||
final List<List<Card>> attackerLists = combat.sortAttackerByDefender();
|
final List<List<Card>> attackerLists = sortAttackerByDefender(combat);
|
||||||
final List<Card> sortedAttackers = new ArrayList<Card>();
|
final List<Card> sortedAttackers = new ArrayList<Card>();
|
||||||
final List<Card> firstAttacker = attackerLists.get(0);
|
final List<Card> firstAttacker = attackerLists.get(0);
|
||||||
|
|
||||||
|
|||||||
@@ -229,27 +229,15 @@ public class Combat {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* <p>
|
|
||||||
* sortAttackerByDefender.
|
|
||||||
* </p>
|
|
||||||
*
|
|
||||||
* @return an array of {@link forge.CardList} objects.
|
|
||||||
*/
|
|
||||||
public final List<List<Card>> sortAttackerByDefender() {
|
|
||||||
int size = this.defenders.size();
|
|
||||||
final ArrayList<List<Card>> attackers = new ArrayList<List<Card>>(size);
|
|
||||||
for (int i = 0; i < size; i++) {
|
|
||||||
attackers.add(getAttackersByDefenderSlot(i));
|
|
||||||
}
|
|
||||||
return attackers;
|
|
||||||
}
|
|
||||||
|
|
||||||
public final List<Card> getAttackersByDefenderSlot(int slot) {
|
public final List<Card> getAttackersByDefenderSlot(int slot) {
|
||||||
GameEntity entity = this.defenders.get(slot);
|
GameEntity entity = this.defenders.get(slot);
|
||||||
return this.defenderMap.get(entity);
|
return this.defenderMap.get(entity);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public final List<Card> getAttackersOf(GameEntity defender) {
|
||||||
|
return defenderMap.get(defender);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>
|
* <p>
|
||||||
* isAttacking.
|
* isAttacking.
|
||||||
|
|||||||
@@ -59,6 +59,7 @@ import forge.gui.GuiDialog;
|
|||||||
import forge.gui.framework.EDocID;
|
import forge.gui.framework.EDocID;
|
||||||
import forge.gui.framework.SDisplayUtil;
|
import forge.gui.framework.SDisplayUtil;
|
||||||
import forge.gui.match.controllers.CCombat;
|
import forge.gui.match.controllers.CCombat;
|
||||||
|
import forge.util.Lang;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -977,22 +978,18 @@ public class CombatUtil {
|
|||||||
// Loop through Defenders
|
// Loop through Defenders
|
||||||
// Append Defending Player/Planeswalker
|
// Append Defending Player/Planeswalker
|
||||||
final Combat combat = game.getCombat();
|
final Combat combat = game.getCombat();
|
||||||
final List<GameEntity> defenders = combat.getDefenders();
|
|
||||||
final List<List<Card>> attackers = combat.sortAttackerByDefender();
|
|
||||||
|
|
||||||
// Not a big fan of the triple nested loop here
|
// Not a big fan of the triple nested loop here
|
||||||
for (int def = 0; def < defenders.size(); def++) {
|
for (GameEntity defender : combat.getDefenders()) {
|
||||||
List<Card> attacker = attackers.get(def);
|
List<Card> attackers = combat.getAttackersOf(defender);
|
||||||
if ((attacker == null) || (attacker.size() == 0)) {
|
if (attackers == null || attackers.isEmpty()) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
if ( sb.length() > 0 ) sb.append("\n");
|
||||||
|
|
||||||
sb.append(combat.getAttackingPlayer()).append(" declared ");
|
sb.append(combat.getAttackingPlayer()).append(" declared ").append(Lang.joinHomogenous(attackers));
|
||||||
for (final Card atk : attacker) {
|
sb.append(" to attack ").append(defender.toString()).append(".");
|
||||||
sb.append(atk).append(" ");
|
|
||||||
}
|
|
||||||
|
|
||||||
sb.append("attacking ").append(defenders.get(def).toString()).append(".");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return sb.toString();
|
return sb.toString();
|
||||||
@@ -1007,35 +1004,34 @@ public class CombatUtil {
|
|||||||
public static String getCombatBlockForLog(GameState game) {
|
public static String getCombatBlockForLog(GameState game) {
|
||||||
final StringBuilder sb = new StringBuilder();
|
final StringBuilder sb = new StringBuilder();
|
||||||
|
|
||||||
List<Card> defend = null;
|
|
||||||
|
|
||||||
// Loop through Defenders
|
// Loop through Defenders
|
||||||
// Append Defending Player/Planeswalker
|
// Append Defending Player/Planeswalker
|
||||||
final Combat combat = game.getCombat();
|
final Combat combat = game.getCombat();
|
||||||
final List<GameEntity> defenders = combat.getDefenders();
|
List<Card> blockers = null;
|
||||||
final List<List<Card>> attackers = combat.sortAttackerByDefender();
|
|
||||||
|
|
||||||
// Not a big fan of the triple nested loop here
|
|
||||||
for (int def = 0; def < defenders.size(); def++) {
|
|
||||||
final List<Card> list = attackers.get(def);
|
|
||||||
|
|
||||||
for (final Card attacker : list) {
|
|
||||||
|
|
||||||
|
|
||||||
defend = game.getCombat().getBlockers(attacker);
|
for (GameEntity defender : combat.getDefenders()) {
|
||||||
sb.append(combat.getDefenderByAttacker(attacker)).append(" assigned ");
|
List<Card> attackers = combat.getAttackersOf(defender);
|
||||||
|
if (attackers == null || attackers.isEmpty()) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if ( sb.length() > 0 ) sb.append("\n");
|
||||||
|
|
||||||
if (!defend.isEmpty()) {
|
String controllerName = defender instanceof Card ? ((Card)defender).getController().getName() : defender.getName();
|
||||||
// loop through blockers
|
boolean firstAttacker = true;
|
||||||
for (final Card blocker : defend) {
|
for (final Card attacker : attackers) {
|
||||||
sb.append(blocker).append(" ");
|
if ( !firstAttacker ) sb.append("\n");
|
||||||
}
|
|
||||||
|
blockers = game.getCombat().getBlockers(attacker);
|
||||||
|
if ( blockers.isEmpty() ) {
|
||||||
|
sb.append(controllerName).append(" didn't block ");
|
||||||
} else {
|
} else {
|
||||||
sb.append("<nothing> ");
|
sb.append(controllerName).append(" assigned ").append(Lang.joinHomogenous(blockers)).append(" to block ");
|
||||||
}
|
}
|
||||||
|
|
||||||
sb.append("to block ").append(attacker).append(". ");
|
sb.append(attacker).append(".");
|
||||||
} // loop through attackers
|
firstAttacker = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return sb.toString();
|
return sb.toString();
|
||||||
|
|||||||
@@ -7,8 +7,10 @@ import forge.Command;
|
|||||||
import forge.GameEntity;
|
import forge.GameEntity;
|
||||||
import forge.game.GameState;
|
import forge.game.GameState;
|
||||||
import forge.game.phase.Combat;
|
import forge.game.phase.Combat;
|
||||||
|
import forge.game.player.Player;
|
||||||
import forge.gui.framework.ICDoc;
|
import forge.gui.framework.ICDoc;
|
||||||
import forge.gui.match.views.VCombat;
|
import forge.gui.match.views.VCombat;
|
||||||
|
import forge.util.Lang;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Controls the combat panel in the match UI.
|
* Controls the combat panel in the match UI.
|
||||||
@@ -57,37 +59,34 @@ public enum CCombat implements ICDoc {
|
|||||||
private static String getCombatDescription(Combat combat) {
|
private static String getCombatDescription(Combat combat) {
|
||||||
final StringBuilder display = new StringBuilder();
|
final StringBuilder display = new StringBuilder();
|
||||||
|
|
||||||
// Loop through Defenders
|
|
||||||
// Append Defending Player/Planeswalker
|
|
||||||
final List<GameEntity> defenders = combat.getDefenders();
|
|
||||||
final List<List<Card>> attackers = combat.sortAttackerByDefender();
|
|
||||||
|
|
||||||
// Not a big fan of the triple nested loop here
|
// Not a big fan of the triple nested loop here
|
||||||
for (int def = 0; def < defenders.size(); def++) {
|
for (GameEntity defender : combat.getDefenders()) {
|
||||||
List<Card> atk = attackers.get(def);
|
List<Card> atk = combat.getAttackersOf(defender);
|
||||||
if ((atk == null) || (atk.size() == 0)) {
|
if (atk == null || atk.isEmpty()) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (def > 0) {
|
if (display.length() > 0) {
|
||||||
display.append("\n");
|
display.append("\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
display.append("Defender - ");
|
if (defender instanceof Card) {
|
||||||
display.append(defenders.get(def).toString());
|
Player controller = ((Card) defender).getController();
|
||||||
display.append("\n");
|
display.append(Lang.getPossesive(controller.getName())).append(" ");
|
||||||
|
}
|
||||||
|
|
||||||
|
display.append(defender.getName()).append(" is attacked by:\n");
|
||||||
|
|
||||||
for (final Card c : atk) {
|
for (final Card c : atk) {
|
||||||
// loop through attackers
|
// loop through attackers
|
||||||
display.append("-> ");
|
display.append(" > ");
|
||||||
display.append(combatantToString(c)).append("\n");
|
display.append(combatantToString(c)).append("\n");
|
||||||
|
|
||||||
List<Card> blockers = combat.getBlockers(c);
|
List<Card> blockers = combat.getBlockers(c);
|
||||||
|
|
||||||
// loop through blockers
|
// loop through blockers
|
||||||
for (final Card element : blockers) {
|
for (final Card element : blockers) {
|
||||||
display.append(" [ ");
|
display.append(" < ").append(combatantToString(element)).append("\n");
|
||||||
display.append(combatantToString(element)).append("\n");
|
|
||||||
}
|
}
|
||||||
} // loop through attackers
|
} // loop through attackers
|
||||||
}
|
}
|
||||||
@@ -108,9 +107,10 @@ public enum CCombat implements ICDoc {
|
|||||||
|
|
||||||
final String name = (c.isFaceDown()) ? "Morph" : c.getName();
|
final String name = (c.isFaceDown()) ? "Morph" : c.getName();
|
||||||
|
|
||||||
|
sb.append("( ").append(c.getNetAttack()).append(" / ").append(c.getNetDefense()).append(" ) ... ");
|
||||||
sb.append(name);
|
sb.append(name);
|
||||||
sb.append(" (").append(c.getUniqueNumber()).append(") ");
|
sb.append(" [").append(c.getUniqueNumber()).append("] ");
|
||||||
sb.append(c.getNetAttack()).append("/").append(c.getNetDefense());
|
|
||||||
|
|
||||||
return sb.toString();
|
return sb.toString();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -42,4 +42,13 @@ public class Lang {
|
|||||||
}
|
}
|
||||||
return sb.toString();
|
return sb.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* TODO: Write javadoc for this method.
|
||||||
|
* @param name
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public static String getPossesive(String name) {
|
||||||
|
return name.endsWith("s") ? name + "'" : name + "'s";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user