mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-18 11:48:02 +00:00
GameLog: add method takes 2 arguments, because entry type is reported by enum
ViewWinLose: writes "You" (won or lost) in title if there was only one human in game
This commit is contained in:
2
.gitattributes
vendored
2
.gitattributes
vendored
@@ -13758,9 +13758,9 @@ src/main/java/forge/Constant.java svneol=native#text/plain
|
||||
src/main/java/forge/CounterType.java svneol=native#text/plain
|
||||
src/main/java/forge/FThreads.java -text
|
||||
src/main/java/forge/GameEntity.java -text
|
||||
src/main/java/forge/GameEventType.java -text
|
||||
src/main/java/forge/GameLog.java -text
|
||||
src/main/java/forge/GameLogEntry.java -text
|
||||
src/main/java/forge/GameLogLevel.java -text
|
||||
src/main/java/forge/ImageCache.java svneol=native#text/plain
|
||||
src/main/java/forge/ImageLoader.java -text
|
||||
src/main/java/forge/Singletons.java svneol=native#text/plain
|
||||
|
||||
@@ -3168,8 +3168,7 @@ public class Card extends GameEntity implements Comparable<Card> {
|
||||
*/
|
||||
public final void equipCard(final Card c) {
|
||||
if (c.hasKeyword("CARDNAME can't be equipped.")) {
|
||||
getGame().getGameLog().add("ResolveStack", "Trying to equip " + c.getName()
|
||||
+ " but it can't be equipped.", GameLogLevel.STACK);
|
||||
getGame().getGameLog().add(GameEventType.STACK_RESOLVE, "Trying to equip " + c.getName() + " but it can't be equipped.");
|
||||
return;
|
||||
}
|
||||
if (this.hasStartOfKeyword("CantEquip")) {
|
||||
@@ -3178,8 +3177,7 @@ public class Card extends GameEntity implements Comparable<Card> {
|
||||
final String[] k = parse.split(" ", 2);
|
||||
final String[] restrictions = k[1].split(",");
|
||||
if (c.isValid(restrictions, this.getController(), this)) {
|
||||
getGame().getGameLog().add("ResolveStack", "Trying to equip " + c.getName()
|
||||
+ " but it can't be equipped.", GameLogLevel.STACK);
|
||||
getGame().getGameLog().add(GameEventType.STACK_RESOLVE, "Trying to equip " + c.getName() + " but it can't be equipped.");
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -3371,8 +3369,8 @@ public class Card extends GameEntity implements Comparable<Card> {
|
||||
*/
|
||||
public final void enchantEntity(final GameEntity entity) {
|
||||
if (entity.hasKeyword("CARDNAME can't be enchanted.")) {
|
||||
getGame().getGameLog().add("ResolveStack", "Trying to enchant " + entity.getName()
|
||||
+ " but it can't be enchanted.", GameLogLevel.STACK);
|
||||
getGame().getGameLog().add(GameEventType.STACK_RESOLVE, "Trying to enchant " + entity.getName()
|
||||
+ " but it can't be enchanted.");
|
||||
return;
|
||||
}
|
||||
this.addEnchanting(entity);
|
||||
@@ -7460,7 +7458,7 @@ public class Card extends GameEntity implements Comparable<Card> {
|
||||
game.getEvents().post(new CardDamagedEvent());
|
||||
}
|
||||
|
||||
getGame().getGameLog().add("Damage", String.format("Dealing %d damage to %s. %s", damageToAdd, this.getName(), additionalLog), GameLogLevel.DAMAGE);
|
||||
getGame().getGameLog().add(GameEventType.DAMAGE, String.format("Dealing %d damage to %s. %s", damageToAdd, this.getName(), additionalLog));
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package forge;
|
||||
|
||||
public enum GameLogLevel {
|
||||
public enum GameEventType {
|
||||
GAME_OUTCOME("Game outcome"),
|
||||
MATCH_RESULTS("Match result"),
|
||||
TURN("Turn"),
|
||||
@@ -9,13 +9,15 @@ public enum GameLogLevel {
|
||||
COMBAT("Combat"),
|
||||
EFFECT_REPLACED("Replacement Effect"),
|
||||
LAND("Land"),
|
||||
STACK("Stack"),
|
||||
STACK_RESOLVE("Resolve stack"),
|
||||
STACK_ADD("Add to stack"),
|
||||
DAMAGE("Damage"),
|
||||
DAMAGE_POISON("Poison"),
|
||||
MANA("Mana"),
|
||||
PHASE("Phase");
|
||||
|
||||
private final String caption;
|
||||
private GameLogLevel(String name) {
|
||||
private GameEventType(String name) {
|
||||
this.caption = name;
|
||||
}
|
||||
|
||||
@@ -28,8 +28,10 @@ import com.google.common.eventbus.Subscribe;
|
||||
import forge.game.GameOutcome;
|
||||
import forge.game.event.DuelOutcomeEvent;
|
||||
import forge.game.event.Event;
|
||||
import forge.game.phase.Combat;
|
||||
import forge.game.player.LobbyPlayer;
|
||||
import forge.game.player.PlayerStatistics;
|
||||
import forge.util.Lang;
|
||||
import forge.util.MyObservable;
|
||||
|
||||
|
||||
@@ -60,6 +62,63 @@ public class GameLog extends MyObservable {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds the.
|
||||
*
|
||||
* @param type the type
|
||||
* @param message the message
|
||||
* @param type the level
|
||||
*/
|
||||
public void add(final GameEventType type, final String message) {
|
||||
log.add(new GameLogEntry(type, message));
|
||||
this.updateObservers();
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the log text.
|
||||
*
|
||||
* @return the log text
|
||||
*/
|
||||
public String getLogText() {
|
||||
return getLogText(null);
|
||||
}
|
||||
|
||||
public String getLogText(final GameEventType logLevel) {
|
||||
List<GameLogEntry> filteredAndReversed = getLogEntries(logLevel);
|
||||
return StringUtils.join(filteredAndReversed, "\r\n");
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the log entries below a certain level as a list.
|
||||
*
|
||||
* @param logLevel the log level
|
||||
* @return the log text
|
||||
*/
|
||||
public List<GameLogEntry> getLogEntries(final GameEventType logLevel) { // null to fetch all
|
||||
final List<GameLogEntry> result = new ArrayList<GameLogEntry>();
|
||||
|
||||
for (int i = log.size() - 1; i >= 0; i--) {
|
||||
GameLogEntry le = log.get(i);
|
||||
if(logLevel == null || le.type.compareTo(logLevel) <= 0 )
|
||||
result.add(le);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public List<GameLogEntry> getLogEntriesExact(final GameEventType logLevel) { // null to fetch all
|
||||
final List<GameLogEntry> result = new ArrayList<GameLogEntry>();
|
||||
|
||||
for (int i = log.size() - 1; i >= 0; i--) {
|
||||
GameLogEntry le = log.get(i);
|
||||
if(logLevel == null || le.type.compareTo(logLevel) == 0 )
|
||||
result.add(le);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
// Special methods
|
||||
|
||||
@Subscribe
|
||||
public void receiveGameEvent(Event ev) {
|
||||
if(ev instanceof DuelOutcomeEvent) {
|
||||
@@ -67,6 +126,7 @@ public class GameLog extends MyObservable {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Generates and adds
|
||||
*/
|
||||
@@ -81,11 +141,11 @@ public class GameLog extends MyObservable {
|
||||
String whoHas = p.getKey().equals(human) ? "You have" : p.getKey().getName() + " has";
|
||||
String outcome = String.format("%s %s", whoHas, p.getValue().getOutcome().toString());
|
||||
outcomes.add(outcome);
|
||||
this.add("Final", outcome, GameLogLevel.GAME_OUTCOME);
|
||||
this.add(GameEventType.GAME_OUTCOME, outcome);
|
||||
}
|
||||
|
||||
final String statsSummary = generateSummary(history);
|
||||
this.add("Final", statsSummary, GameLogLevel.MATCH_RESULTS);
|
||||
this.add(GameEventType.MATCH_RESULTS, statsSummary);
|
||||
}
|
||||
|
||||
private static String generateSummary(List<GameOutcome> gamesPlayed) {
|
||||
@@ -112,59 +172,76 @@ public class GameLog extends MyObservable {
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Adds the.
|
||||
*
|
||||
* @param type the type
|
||||
* @param message the message
|
||||
* @param level the level
|
||||
*/
|
||||
public void add(final String type, final String message, final GameLogLevel level) {
|
||||
log.add(new GameLogEntry(type, message, level));
|
||||
this.updateObservers();
|
||||
|
||||
public void addCombatAttackers(Combat combat) {
|
||||
this.add(GameEventType.COMBAT, describeAttack(combat));
|
||||
}
|
||||
public void addCombatBlockers(Combat combat) {
|
||||
this.add(GameEventType.COMBAT, describeBlock(combat));
|
||||
}
|
||||
// Special methods
|
||||
|
||||
|
||||
private static String describeAttack(final Combat combat) {
|
||||
final StringBuilder sb = new StringBuilder();
|
||||
|
||||
// Loop through Defenders
|
||||
// Append Defending Player/Planeswalker
|
||||
|
||||
|
||||
|
||||
// Not a big fan of the triple nested loop here
|
||||
for (GameEntity defender : combat.getDefenders()) {
|
||||
List<Card> attackers = combat.getAttackersOf(defender);
|
||||
if (attackers == null || attackers.isEmpty()) {
|
||||
continue;
|
||||
}
|
||||
if ( sb.length() > 0 ) sb.append("\n");
|
||||
|
||||
sb.append(combat.getAttackingPlayer()).append(" declared ").append(Lang.joinHomogenous(attackers));
|
||||
sb.append(" to attack ").append(defender.toString()).append(".");
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the log text.
|
||||
*
|
||||
* @return the log text
|
||||
*/
|
||||
public String getLogText() {
|
||||
return getLogText(null);
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
|
||||
public String getLogText(final GameLogLevel logLevel) {
|
||||
List<GameLogEntry> filteredAndReversed = getLogEntries(logLevel);
|
||||
return StringUtils.join(filteredAndReversed, "\r\n");
|
||||
private static String describeBlock(final Combat combat) {
|
||||
final StringBuilder sb = new StringBuilder();
|
||||
|
||||
// Loop through Defenders
|
||||
// Append Defending Player/Planeswalker
|
||||
|
||||
List<Card> blockers = null;
|
||||
|
||||
|
||||
for (GameEntity defender : combat.getDefenders()) {
|
||||
List<Card> attackers = combat.getAttackersOf(defender);
|
||||
if (attackers == null || attackers.isEmpty()) {
|
||||
continue;
|
||||
}
|
||||
if ( sb.length() > 0 ) sb.append("\n");
|
||||
|
||||
String controllerName = defender instanceof Card ? ((Card)defender).getController().getName() : defender.getName();
|
||||
boolean firstAttacker = true;
|
||||
for (final Card attacker : attackers) {
|
||||
if ( !firstAttacker ) sb.append("\n");
|
||||
|
||||
blockers = combat.getBlockers(attacker);
|
||||
if ( blockers.isEmpty() ) {
|
||||
sb.append(controllerName).append(" didn't block ");
|
||||
} else {
|
||||
sb.append(controllerName).append(" assigned ").append(Lang.joinHomogenous(blockers)).append(" to block ");
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the log entries below a certain level as a list.
|
||||
*
|
||||
* @param logLevel the log level
|
||||
* @return the log text
|
||||
*/
|
||||
public List<GameLogEntry> getLogEntries(final GameLogLevel logLevel) { // null to fetch all
|
||||
final List<GameLogEntry> result = new ArrayList<GameLogEntry>();
|
||||
|
||||
for (int i = log.size() - 1; i >= 0; i--) {
|
||||
GameLogEntry le = log.get(i);
|
||||
if(logLevel == null || le.level.compareTo(logLevel) <= 0 )
|
||||
result.add(le);
|
||||
sb.append(attacker).append(".");
|
||||
firstAttacker = false;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public List<GameLogEntry> getLogEntriesExact(final GameLogLevel logLevel) { // null to fetch all
|
||||
final List<GameLogEntry> result = new ArrayList<GameLogEntry>();
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
|
||||
for (int i = log.size() - 1; i >= 0; i--) {
|
||||
GameLogEntry le = log.get(i);
|
||||
if(logLevel == null || le.level.compareTo(logLevel) == 0 )
|
||||
result.add(le);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
} // end class GameLog
|
||||
|
||||
@@ -1,22 +1,18 @@
|
||||
package forge;
|
||||
|
||||
public class GameLogEntry {
|
||||
public final String type;
|
||||
public final String message;
|
||||
public final GameLogLevel level;
|
||||
public final GameEventType type;
|
||||
// might add here date and some other fields
|
||||
|
||||
GameLogEntry(final String typeIn, final String messageIn, final GameLogLevel levelIn) {
|
||||
type = typeIn;
|
||||
GameLogEntry(final GameEventType type0, final String messageIn) {
|
||||
type = type0;
|
||||
message = messageIn;
|
||||
level = levelIn;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see java.lang.Object#toString()
|
||||
*/
|
||||
@Override
|
||||
public String toString() {
|
||||
// TODO Auto-generated method stub
|
||||
return type + ": " + message;
|
||||
return type.getCaption() + ": " + message;
|
||||
}
|
||||
}
|
||||
@@ -35,7 +35,7 @@ import forge.Command;
|
||||
import forge.Constant;
|
||||
import forge.CounterType;
|
||||
import forge.GameEntity;
|
||||
import forge.GameLogLevel;
|
||||
import forge.GameEventType;
|
||||
import forge.card.ColorSet;
|
||||
import forge.card.MagicColor;
|
||||
import forge.card.ability.AbilityFactory;
|
||||
@@ -205,10 +205,8 @@ public class CardFactoryUtil {
|
||||
@Override
|
||||
public void resolve() {
|
||||
if (sourceCard.turnFaceUp()) {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append(this.getActivatingPlayer()).append(" has unmorphed ");
|
||||
sb.append(sourceCard.getName());
|
||||
sourceCard.getGame().getGameLog().add("ResolveStack", sb.toString(), GameLogLevel.STACK);
|
||||
String sb = this.getActivatingPlayer() + " has unmorphed " + sourceCard.getName();
|
||||
sourceCard.getGame().getGameLog().add(GameEventType.STACK_RESOLVE, sb);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -430,11 +428,8 @@ public class CardFactoryUtil {
|
||||
int counters = AbilityUtils.calculateAmount(c, timeCounters, this);
|
||||
c.addCounter(CounterType.TIME, counters, true);
|
||||
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append(this.getActivatingPlayer()).append(" has suspended ");
|
||||
sb.append(c.getName()).append("with ");
|
||||
sb.append(counters).append(" time counters on it.");
|
||||
game.getGameLog().add("ResolveStack", sb.toString(), GameLogLevel.STACK);
|
||||
String sb = String.format("%s has suspended %s with %d time counters on it.", this.getActivatingPlayer(), c.getName(), counters);
|
||||
game.getGameLog().add(GameEventType.STACK_RESOLVE, sb);
|
||||
}
|
||||
};
|
||||
final StringBuilder sbDesc = new StringBuilder();
|
||||
|
||||
@@ -24,7 +24,7 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import forge.Card;
|
||||
import forge.GameLogLevel;
|
||||
import forge.GameEventType;
|
||||
import forge.card.ability.AbilityFactory;
|
||||
import forge.card.ability.AbilityUtils;
|
||||
import forge.card.spellability.SpellAbility;
|
||||
@@ -150,7 +150,7 @@ public class ReplacementHandler {
|
||||
ReplacementResult res = this.executeReplacement(runParams, chosenRE, decider, game);
|
||||
if (res != ReplacementResult.NotReplaced) {
|
||||
chosenRE.setHasRun(false);
|
||||
game.getGameLog().add("ReplacementEffect", chosenRE.toString(), GameLogLevel.EFFECT_REPLACED);
|
||||
game.getGameLog().add(GameEventType.EFFECT_REPLACED, chosenRE.toString());
|
||||
return res;
|
||||
} else {
|
||||
if (possibleReplacers.size() == 0) {
|
||||
|
||||
@@ -19,7 +19,7 @@ import com.google.common.collect.Lists;
|
||||
import forge.Card;
|
||||
import forge.CardLists;
|
||||
import forge.CardPredicates;
|
||||
import forge.GameLogLevel;
|
||||
import forge.GameEventType;
|
||||
import forge.card.trigger.Trigger;
|
||||
import forge.card.trigger.TriggerHandler;
|
||||
import forge.card.trigger.TriggerType;
|
||||
@@ -314,10 +314,10 @@ public class GameNew {
|
||||
Predicate<Card> goodForAnte = Predicates.not(CardPredicates.Presets.BASIC_LANDS);
|
||||
Card ante = Aggregates.random(Iterables.filter(lib, goodForAnte));
|
||||
if (ante == null) {
|
||||
game.getGameLog().add("Ante", "Only basic lands found. Will ante one of them", GameLogLevel.ANTE);
|
||||
game.getGameLog().add(GameEventType.ANTE, "Only basic lands found. Will ante one of them");
|
||||
ante = Aggregates.random(lib);
|
||||
}
|
||||
game.getGameLog().add("Ante", p + " anted " + ante, GameLogLevel.ANTE);
|
||||
game.getGameLog().add(GameEventType.ANTE, p + " anted " + ante);
|
||||
game.getAction().moveTo(ZoneType.Ante, ante);
|
||||
msg.append(p.getName()).append(" ante: ").append(ante).append(nl);
|
||||
}
|
||||
|
||||
@@ -59,7 +59,6 @@ import forge.gui.GuiDialog;
|
||||
import forge.gui.framework.EDocID;
|
||||
import forge.gui.framework.SDisplayUtil;
|
||||
import forge.gui.match.controllers.CCombat;
|
||||
import forge.util.Lang;
|
||||
|
||||
|
||||
/**
|
||||
@@ -965,77 +964,6 @@ public class CombatUtil {
|
||||
} // canAttack()
|
||||
|
||||
|
||||
/**
|
||||
* gets a string for the GameLog regarding attackers.
|
||||
*
|
||||
* @return a String
|
||||
*/
|
||||
public static String getCombatAttackForLog(final Combat combat) {
|
||||
final StringBuilder sb = new StringBuilder();
|
||||
|
||||
// Loop through Defenders
|
||||
// Append Defending Player/Planeswalker
|
||||
|
||||
|
||||
|
||||
// Not a big fan of the triple nested loop here
|
||||
for (GameEntity defender : combat.getDefenders()) {
|
||||
List<Card> attackers = combat.getAttackersOf(defender);
|
||||
if (attackers == null || attackers.isEmpty()) {
|
||||
continue;
|
||||
}
|
||||
if ( sb.length() > 0 ) sb.append("\n");
|
||||
|
||||
sb.append(combat.getAttackingPlayer()).append(" declared ").append(Lang.joinHomogenous(attackers));
|
||||
sb.append(" to attack ").append(defender.toString()).append(".");
|
||||
}
|
||||
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* gets a string for the GameLog regarding assigned blockers.
|
||||
* @param game
|
||||
*
|
||||
* @return a String
|
||||
*/
|
||||
public static String getCombatBlockForLog(final Combat combat) {
|
||||
final StringBuilder sb = new StringBuilder();
|
||||
|
||||
// Loop through Defenders
|
||||
// Append Defending Player/Planeswalker
|
||||
|
||||
List<Card> blockers = null;
|
||||
|
||||
|
||||
for (GameEntity defender : combat.getDefenders()) {
|
||||
List<Card> attackers = combat.getAttackersOf(defender);
|
||||
if (attackers == null || attackers.isEmpty()) {
|
||||
continue;
|
||||
}
|
||||
if ( sb.length() > 0 ) sb.append("\n");
|
||||
|
||||
String controllerName = defender instanceof Card ? ((Card)defender).getController().getName() : defender.getName();
|
||||
boolean firstAttacker = true;
|
||||
for (final Card attacker : attackers) {
|
||||
if ( !firstAttacker ) sb.append("\n");
|
||||
|
||||
blockers = combat.getBlockers(attacker);
|
||||
if ( blockers.isEmpty() ) {
|
||||
sb.append(controllerName).append(" didn't block ");
|
||||
} else {
|
||||
sb.append(controllerName).append(" assigned ").append(Lang.joinHomogenous(blockers)).append(" to block ");
|
||||
}
|
||||
|
||||
sb.append(attacker).append(".");
|
||||
firstAttacker = false;
|
||||
}
|
||||
}
|
||||
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* showCombat.
|
||||
|
||||
@@ -26,7 +26,7 @@ import com.esotericsoftware.minlog.Log;
|
||||
|
||||
import forge.Card;
|
||||
import forge.FThreads;
|
||||
import forge.GameLogLevel;
|
||||
import forge.GameEventType;
|
||||
import forge.Singletons;
|
||||
import forge.card.trigger.TriggerType;
|
||||
import forge.game.GameState;
|
||||
@@ -39,6 +39,7 @@ import forge.gui.framework.SDisplayUtil;
|
||||
import forge.gui.match.CMatchUI;
|
||||
import forge.gui.match.nonsingleton.VField;
|
||||
import forge.properties.ForgePreferences.FPref;
|
||||
import forge.util.Lang;
|
||||
import forge.util.MyObservable;
|
||||
|
||||
|
||||
@@ -486,10 +487,10 @@ public class PhaseHandler extends MyObservable implements java.io.Serializable {
|
||||
default: // no action
|
||||
}
|
||||
|
||||
StringBuilder sb = new StringBuilder();
|
||||
String phaseType = "";
|
||||
if (this.bRepeat) { // for when Cleanup needs to repeat itself
|
||||
this.bRepeat = false;
|
||||
sb.append("Repeat Phase");
|
||||
phaseType = "Repeat ";
|
||||
} else {
|
||||
// If the phase that's ending has a stack of additional phases
|
||||
// Take the LIFO one and move to that instead of the normal one
|
||||
@@ -501,23 +502,20 @@ public class PhaseHandler extends MyObservable implements java.io.Serializable {
|
||||
this.extraPhases.remove(phase);
|
||||
}
|
||||
this.phase = nextPhase;
|
||||
sb.append("Additional Phase");
|
||||
phaseType = "Additional ";
|
||||
} else {
|
||||
this.phase = phase.getNextPhase();
|
||||
sb.append("Phase");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
// **** Anything BELOW Here is actually in the next phase. Maybe move
|
||||
// this to handleBeginPhase
|
||||
if (this.phase == PhaseType.UNTAP) {
|
||||
this.turn++;
|
||||
game.getGameLog().add("Turn", "Turn " + this.turn + " (" + this.getPlayerTurn() + ")", GameLogLevel.TURN);
|
||||
game.getGameLog().add(GameEventType.TURN, "Turn " + this.turn + " (" + this.getPlayerTurn() + ")");
|
||||
}
|
||||
|
||||
game.getGameLog().add(sb.toString(), this.getPlayerTurn() + " " + this.getPhase().Name, GameLogLevel.PHASE);
|
||||
game.getGameLog().add(GameEventType.PHASE, phaseType + Lang.getPossesive(this.getPlayerTurn().getName()) + " " + this.getPhase().Name);
|
||||
PhaseUtil.visuallyActivatePhase(this.getPlayerTurn(), this.getPhase());
|
||||
|
||||
// When consecutively skipping phases (like in combat) this section
|
||||
|
||||
@@ -26,7 +26,6 @@ import com.google.common.base.Predicate;
|
||||
import forge.Card;
|
||||
import forge.CardLists;
|
||||
import forge.CardPredicates.Presets;
|
||||
import forge.GameLogLevel;
|
||||
import forge.card.cost.Cost;
|
||||
import forge.card.mana.ManaCost;
|
||||
import forge.card.spellability.Ability;
|
||||
@@ -176,7 +175,7 @@ public class PhaseUtil {
|
||||
|
||||
}
|
||||
|
||||
game.getGameLog().add("Combat", CombatUtil.getCombatAttackForLog(game.getCombat()), GameLogLevel.COMBAT);
|
||||
game.getGameLog().addCombatAttackers(game.getCombat());
|
||||
|
||||
final HashMap<String, Object> runParams = new HashMap<String, Object>();
|
||||
runParams.put("Attackers", list);
|
||||
@@ -272,7 +271,7 @@ public class PhaseUtil {
|
||||
|
||||
game.getStack().unfreezeStack();
|
||||
|
||||
game.getGameLog().add("Combat", CombatUtil.getCombatBlockForLog(game.getCombat()), GameLogLevel.COMBAT);
|
||||
game.getGameLog().addCombatBlockers(game.getCombat());
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@ import forge.CardLists;
|
||||
import forge.CardPredicates.Presets;
|
||||
import forge.CounterType;
|
||||
import forge.FThreads;
|
||||
import forge.GameLogLevel;
|
||||
import forge.GameEventType;
|
||||
import forge.card.ability.AbilityUtils;
|
||||
import forge.card.ability.ApiType;
|
||||
import forge.card.ability.effects.CharmEffect;
|
||||
@@ -356,7 +356,7 @@ public class HumanPlay {
|
||||
|
||||
if (false == source.canReceiveCounters(counterType)) {
|
||||
String message = String.format("Won't be able to pay upkeep for %s but it can't have %s counters put on it.", source, counterType.getName());
|
||||
p.getGame().getGameLog().add("ResolveStack", message, GameLogLevel.STACK);
|
||||
p.getGame().getGameLog().add(GameEventType.STACK_RESOLVE, message);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -39,7 +39,7 @@ import forge.Constant.Preferences;
|
||||
import forge.CounterType;
|
||||
import forge.FThreads;
|
||||
import forge.GameEntity;
|
||||
import forge.GameLogLevel;
|
||||
import forge.GameEventType;
|
||||
import forge.Singletons;
|
||||
import forge.card.MagicColor;
|
||||
import forge.card.ability.AbilityFactory;
|
||||
@@ -680,8 +680,7 @@ public class Player extends GameEntity implements Comparable<Player> {
|
||||
runParams.put("IsCombatDamage", isCombat);
|
||||
game.getTriggerHandler().runTrigger(TriggerType.DamageDone, runParams, false);
|
||||
|
||||
game.getGameLog().add("Damage", String.format("Dealing %d damage to %s. %s",
|
||||
damageToDo, this.getName(), additionalLog), GameLogLevel.DAMAGE);
|
||||
game.getGameLog().add(GameEventType.DAMAGE, String.format("Dealing %d damage to %s. %s", damageToDo, this.getName(), additionalLog));
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -1029,7 +1028,7 @@ public class Player extends GameEntity implements Comparable<Player> {
|
||||
this.poisonCounters += num;
|
||||
|
||||
game.getEvents().post(new PoisonCounterEvent(this, source, num));
|
||||
game.getGameLog().add("Poison", this + " receives a poison counter from " + source, GameLogLevel.DAMAGE);
|
||||
game.getGameLog().add(GameEventType.DAMAGE_POISON, this + " receives a poison counter from " + source);
|
||||
|
||||
this.updateObservers();
|
||||
}
|
||||
@@ -1236,30 +1235,6 @@ public class Player extends GameEntity implements Comparable<Player> {
|
||||
public boolean canMulligan() {
|
||||
return !getZone(ZoneType.Hand).isEmpty();
|
||||
}
|
||||
/**
|
||||
*
|
||||
* TODO Write javadoc for this method.
|
||||
*
|
||||
* @param player
|
||||
* a Player object
|
||||
* @param playerRating
|
||||
* a GamePlayerRating object
|
||||
* @return an int
|
||||
*/
|
||||
public void doMulligan() {
|
||||
final List<Card> hand = new ArrayList<Card>(getCardsIn(ZoneType.Hand));
|
||||
for (final Card c : hand) {
|
||||
game.getAction().moveToLibrary(c);
|
||||
}
|
||||
shuffle();
|
||||
drawCards(hand.size() - 1);
|
||||
|
||||
game.getEvents().post(new MulliganEvent(this)); // quest listener may interfere here
|
||||
final int newHand = getCardsIn(ZoneType.Hand).size();
|
||||
game.getGameLog().add("Mulligan", this + " has mulliganed down to " + newHand + " cards.", GameLogLevel.MULLIGAN);
|
||||
stats.notifyHasMulliganed();
|
||||
stats.notifyOpeningHandSize(newHand);
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>
|
||||
@@ -1800,7 +1775,7 @@ public class Player extends GameEntity implements Comparable<Player> {
|
||||
game.getAction().checkStateEffects();
|
||||
|
||||
// add to log
|
||||
game.getGameLog().add("Land", this + " played " + land, GameLogLevel.LAND);
|
||||
game.getGameLog().add(GameEventType.LAND, this + " played " + land);
|
||||
|
||||
// play a sound
|
||||
game.getEvents().post(new LandPlayedEvent(this, land));
|
||||
@@ -3160,7 +3135,7 @@ public class Player extends GameEntity implements Comparable<Player> {
|
||||
public void onMulliganned() {
|
||||
game.getEvents().post(new MulliganEvent(this)); // quest listener may interfere here
|
||||
final int newHand = getCardsIn(ZoneType.Hand).size();
|
||||
game.getGameLog().add("Mulligan", this + " has mulliganed down to " + newHand + " cards.", GameLogLevel.MULLIGAN);
|
||||
game.getGameLog().add(GameEventType.MULLIGAN, this + " has mulliganed down to " + newHand + " cards.");
|
||||
stats.notifyHasMulliganed();
|
||||
stats.notifyOpeningHandSize(newHand);
|
||||
}
|
||||
|
||||
@@ -33,7 +33,7 @@ import forge.Card;
|
||||
import forge.CardLists;
|
||||
import forge.FThreads;
|
||||
import forge.CardPredicates.Presets;
|
||||
import forge.GameLogLevel;
|
||||
import forge.GameEventType;
|
||||
import forge.card.ability.AbilityUtils;
|
||||
import forge.card.cardfactory.CardFactory;
|
||||
import forge.card.cardfactory.CardFactoryUtil;
|
||||
@@ -311,7 +311,7 @@ public class MagicStack extends MyObservable implements Iterable<SpellAbilitySta
|
||||
AbilityUtils.resolve(sp, false);
|
||||
//sp.resolve();
|
||||
sp.resetOnceResolved();
|
||||
game.getGameLog().add("Mana", sp.getSourceCard() + " - " + sp.getDescription(), GameLogLevel.MANA);
|
||||
game.getGameLog().add(GameEventType.MANA, sp.getSourceCard() + " - " + sp.getDescription());
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -355,7 +355,7 @@ public class MagicStack extends MyObservable implements Iterable<SpellAbilitySta
|
||||
}
|
||||
sb.append(".");
|
||||
|
||||
game.getGameLog().add("AddToStack", sb.toString(), GameLogLevel.STACK);
|
||||
game.getGameLog().add(GameEventType.STACK_ADD, sb.toString());
|
||||
//============= GameLog ======================
|
||||
|
||||
// if activating player slips through the cracks, assign activating
|
||||
@@ -604,7 +604,7 @@ public class MagicStack extends MyObservable implements Iterable<SpellAbilitySta
|
||||
|
||||
boolean thisHasFizzled = this.hasFizzled(sa, source, false);
|
||||
String messageForLog = thisHasFizzled ? source.getName() + " ability fizzles." : sa.getStackDescription();
|
||||
game.getGameLog().add("ResolveStack", messageForLog, GameLogLevel.STACK);
|
||||
game.getGameLog().add(GameEventType.STACK_RESOLVE, messageForLog);
|
||||
if (thisHasFizzled) { // Fizzle
|
||||
// TODO: Spell fizzles, what's the best way to alert player?
|
||||
Log.debug(source.getName() + " ability fizzles.");
|
||||
|
||||
@@ -11,13 +11,18 @@ import javax.swing.JScrollPane;
|
||||
import javax.swing.SwingConstants;
|
||||
import javax.swing.SwingUtilities;
|
||||
|
||||
import org.apache.commons.lang3.tuple.Pair;
|
||||
|
||||
import net.miginfocom.swing.MigLayout;
|
||||
import forge.Command;
|
||||
import forge.GameLog;
|
||||
import forge.GameLogEntry;
|
||||
import forge.GameLogLevel;
|
||||
import forge.GameEventType;
|
||||
import forge.Singletons;
|
||||
import forge.control.FControl;
|
||||
import forge.game.MatchController;
|
||||
import forge.game.player.LobbyPlayer;
|
||||
import forge.game.player.PlayerStatistics;
|
||||
import forge.gui.toolbox.FButton;
|
||||
import forge.gui.toolbox.FLabel;
|
||||
import forge.gui.toolbox.FOverlay;
|
||||
@@ -175,17 +180,29 @@ public class ViewWinLose {
|
||||
}
|
||||
});
|
||||
|
||||
lblTitle.setText(match.getLastGameOutcome().getWinner().getName() + " Won!");
|
||||
lblTitle.setText(composeTitle(match));
|
||||
|
||||
GameLog log = match.getCurrentGame().getGameLog();
|
||||
|
||||
for (GameLogEntry o : log.getLogEntriesExact(GameLogLevel.GAME_OUTCOME))
|
||||
for (GameLogEntry o : log.getLogEntriesExact(GameEventType.GAME_OUTCOME))
|
||||
pnlOutcomes.add(new FLabel.Builder().text(o.message).fontSize(14).build(), "h 20!");
|
||||
|
||||
for (GameLogEntry o : log.getLogEntriesExact(GameLogLevel.MATCH_RESULTS))
|
||||
for (GameLogEntry o : log.getLogEntriesExact(GameEventType.MATCH_RESULTS))
|
||||
lblStats.setText(o.message);
|
||||
}
|
||||
|
||||
private String composeTitle(MatchController match) {
|
||||
LobbyPlayer guiPlayer = FControl.SINGLETON_INSTANCE.getLobby().getGuiPlayer();
|
||||
int nHumansInGame = 0;
|
||||
for(Pair<LobbyPlayer, PlayerStatistics> pps : match.getLastGameOutcome()) {
|
||||
if( pps.getKey() == guiPlayer )
|
||||
nHumansInGame++;
|
||||
}
|
||||
LobbyPlayer winner = match.getLastGameOutcome().getWinner();
|
||||
String title = nHumansInGame == 1 ? "You " + (winner == guiPlayer ? "won!" : "lost!") : winner.getName() + " Won!";
|
||||
return title;
|
||||
}
|
||||
|
||||
/** @return {@link forge.gui.toolbox.FButton} */
|
||||
public FButton getBtnContinue() {
|
||||
return this.btnContinue;
|
||||
|
||||
@@ -27,7 +27,7 @@ import javax.swing.border.EmptyBorder;
|
||||
import net.miginfocom.swing.MigLayout;
|
||||
import forge.GameLog;
|
||||
import forge.GameLogEntry;
|
||||
import forge.GameLogLevel;
|
||||
import forge.GameEventType;
|
||||
import forge.gui.framework.DragCell;
|
||||
import forge.gui.framework.DragTab;
|
||||
import forge.gui.framework.EDocID;
|
||||
@@ -119,7 +119,7 @@ public enum VLog implements IVDoc<CLog> {
|
||||
|
||||
// TODO - some option to make this configurable is probably desirable
|
||||
// By default, grab everything log level 3 or less.
|
||||
final List<GameLogEntry> data = model.getLogEntries(GameLogLevel.DAMAGE);
|
||||
final List<GameLogEntry> data = model.getLogEntries(GameEventType.DAMAGE);
|
||||
final int size = data.size();
|
||||
|
||||
pnl.removeAll();
|
||||
|
||||
Reference in New Issue
Block a user