GetGameLog inlined

This commit is contained in:
Maxmtg
2012-10-18 15:30:39 +00:00
parent a2cf0d29d5
commit da1e300ab0
16 changed files with 24 additions and 137 deletions

1
.gitattributes vendored
View File

@@ -12368,7 +12368,6 @@ src/main/config/forge.sh svneol=native#text/x-sh
src/main/config/forge_checks.xml svneol=native#text/xml
src/main/config/support/template.applescript -text
src/main/java/forge/AllZone.java svneol=native#text/plain
src/main/java/forge/AllZoneUtil.java svneol=native#text/plain
src/main/java/forge/Card.java svneol=native#text/plain
src/main/java/forge/CardCharacteristicName.java -text
src/main/java/forge/CardColor.java svneol=native#text/plain

View File

@@ -20,7 +20,6 @@ package forge;
import forge.card.cardfactory.CardFactory;
import forge.card.cardfactory.CardFactoryInterface;
import forge.control.input.InputControl;
import forge.game.GameState;
import forge.game.limited.GauntletMini;
import forge.properties.ForgeProps;
import forge.properties.NewConstants;
@@ -79,24 +78,6 @@ public final class AllZone {
return AllZone.gauntlet;
}
/**
* <p>
* getGameLog.
* </p>
*
* @return a {@link forge.GameLog} object; may be null.
* @since 1.2.0
*/
public static GameLog getGameLog() {
final GameState gameState = Singletons.getModel().getGameState();
if (gameState != null) {
return gameState.getGameLog();
}
return null;
}
/**
* <p>
* getCardFactory.

View File

@@ -1,89 +0,0 @@
/*
* Forge: Play Magic: the Gathering.
* Copyright (C) 2011 Forge Team
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package forge;
/**
* AllZoneUtil contains static functions used to get CardLists of various cards
* in various zones.
*
* @author dennis.r.friedrichsen (slapshot5 on slightlymagic.net)
* @version $Id$
*/
public abstract class AllZoneUtil {
// ////////// Creatures
// ////////// Creatures
// /////////////// Lands
// =============================================================================
//
// These functions handle getting all cards for a given player
// and all cards with a given name for either or both players
//
// =============================================================================
// ////////////// getting all cards of a given color
/**
* <p>
* compare.
* </p>
*
* @param leftSide
* a int.
* @param comp
* a {@link java.lang.String} object.
* @param rightSide
* a int.
* @return a boolean.
* @since 1.0.15
*/
public static boolean compare(final int leftSide, final String comp, final int rightSide) {
// should this function be somewhere else?
// leftSide COMPARED to rightSide:
if (comp.contains("LT")) {
return leftSide < rightSide;
} else if (comp.contains("LE")) {
return leftSide <= rightSide;
} else if (comp.contains("EQ")) {
return leftSide == rightSide;
} else if (comp.contains("GE")) {
return leftSide >= rightSide;
} else if (comp.contains("GT")) {
return leftSide > rightSide;
} else if (comp.contains("NE")) {
return leftSide != rightSide; // not equals
} else if (comp.contains("M2")) {
return (leftSide % 2) == (rightSide % 2); // they are equal modulo 2
}
return false;
}
} // end class AllZoneUtil

View File

@@ -4003,7 +4003,7 @@ public class Card extends GameEntity implements Comparable<Card> {
*/
public final void equipCard(final Card c) {
if (c.hasKeyword("CARDNAME can't be equipped.")) {
AllZone.getGameLog().add("ResolveStack", "Trying to equip " + c.getName()
Singletons.getModel().getGameState().getGameLog().add("ResolveStack", "Trying to equip " + c.getName()
+ " but it can't be equipped.", 2);
return;
}
@@ -4189,7 +4189,7 @@ public class Card extends GameEntity implements Comparable<Card> {
*/
public final void enchantEntity(final GameEntity entity) {
if (entity.hasKeyword("CARDNAME can't be enchanted.")) {
AllZone.getGameLog().add("ResolveStack", "Trying to enchant " + entity.getName()
Singletons.getModel().getGameState().getGameLog().add("ResolveStack", "Trying to enchant " + entity.getName()
+ " but it can't be enchanted.", 2);
return;
}

View File

@@ -425,7 +425,7 @@ public final class GameActionUtil {
source.addCounterFromNonEffect(counterType, amount);
} else {
hasPaid = false;
AllZone.getGameLog().add("ResolveStack", "Trying to pay upkeep for " + source + " but it can't have "
Singletons.getModel().getGameState().getGameLog().add("ResolveStack", "Trying to pay upkeep for " + source + " but it can't have "
+ counterType.getName() + " counters put on it.", 2);
}
} else {

View File

@@ -910,7 +910,7 @@ public class CardFactoryUtil {
StringBuilder sb = new StringBuilder();
sb.append(this.getActivatingPlayer()).append(" has unmorphed ");
sb.append(sourceCard.getName());
AllZone.getGameLog().add("ResolveStack", sb.toString(), 2);
Singletons.getModel().getGameState().getGameLog().add("ResolveStack", sb.toString(), 2);
}
}
@@ -1133,7 +1133,7 @@ public class CardFactoryUtil {
sb.append(this.getActivatingPlayer()).append(" has suspended ");
sb.append(c.getName()).append("with ");
sb.append(counters).append(" time counters on it.");
AllZone.getGameLog().add("ResolveStack", sb.toString(), 2);
Singletons.getModel().getGameState().getGameLog().add("ResolveStack", sb.toString(), 2);
}
};
final StringBuilder sbDesc = new StringBuilder();

View File

@@ -22,7 +22,6 @@ import java.util.EnumSet;
import java.util.HashMap;
import java.util.List;
import forge.AllZone;
import forge.Card;
import forge.GameActionUtil;
import forge.Singletons;
@@ -147,7 +146,7 @@ public class ReplacementHandler {
ReplacementResult res = this.executeReplacement(runParams, chosenRE, decider);
if (res != ReplacementResult.NotReplaced) {
chosenRE.setHasRun(false);
AllZone.getGameLog().add("ReplacementEffect", chosenRE.toString(), 2);
Singletons.getModel().getGameState().getGameLog().add("ReplacementEffect", chosenRE.toString(), 2);
return res;
} else {
if (possibleReplacers.size() == 0) {

View File

@@ -20,7 +20,6 @@ package forge.control.input;
import java.util.ArrayList;
import java.util.List;
import forge.AllZone;
import forge.Card;
import forge.CardLists;
@@ -172,7 +171,7 @@ public class InputMulligan extends Input {
ga.checkStateEffects();
AllZone.getGameLog().add("Turn",
Singletons.getModel().getGameState().getGameLog().add("Turn",
"Turn " + Singletons.getModel().getGameState().getPhaseHandler().getTurn()
+ " (" + Singletons.getModel().getGameState().getPhaseHandler().getPlayerTurn() + ")",
0);

View File

@@ -172,7 +172,7 @@ public class GameNew {
if (ante == null) {
throw new RuntimeException(p + " library is empty.");
}
AllZone.getGameLog().add("Ante", p + " anted " + ante, 0);
Singletons.getModel().getGameState().getGameLog().add("Ante", p + " anted " + ante, 0);
VAntes.SINGLETON_INSTANCE.addAnteCard(p, ante);
Singletons.getModel().getGameAction().moveTo(ZoneType.Ante, ante);
msg.append(p.getName()).append(" ante: ").append(ante).append(nl);

View File

@@ -136,7 +136,7 @@ public class MatchController {
// Update observers
Singletons.getModel().getGameState().getStack().updateObservers();
AllZone.getInputControl().updateObservers();
AllZone.getGameLog().updateObservers();
Singletons.getModel().getGameState().getGameLog().updateObservers();
for( Player p : currentGame.getPlayers() ) {

View File

@@ -531,13 +531,13 @@ public class PhaseHandler extends MyObservable implements java.io.Serializable {
}
}
AllZone.getGameLog().add("Phase", this.getPlayerTurn() + " " + this.getPhase().Name, 6);
Singletons.getModel().getGameState().getGameLog().add("Phase", this.getPlayerTurn() + " " + this.getPhase().Name, 6);
// **** Anything BELOW Here is actually in the next phase. Maybe move
// this to handleBeginPhase
if (this.getPhase() == PhaseType.UNTAP) {
this.turn++;
AllZone.getGameLog().add("Turn", "Turn " + this.turn + " (" + this.getPlayerTurn() + ")", 0);
Singletons.getModel().getGameState().getGameLog().add("Turn", "Turn " + this.turn + " (" + this.getPlayerTurn() + ")", 0);
}
PhaseUtil.visuallyActivatePhase(this.getPhase());

View File

@@ -23,7 +23,6 @@ import java.util.List;
import com.google.common.base.Predicate;
import forge.AllZone;
import forge.Card;
import forge.CardLists;
import forge.CardPredicates.Presets;
@@ -336,7 +335,7 @@ public class PhaseUtil {
}
AllZone.getGameLog().add("Combat", CombatUtil.getCombatAttackForLog(), 1);
Singletons.getModel().getGameState().getGameLog().add("Combat", CombatUtil.getCombatAttackForLog(), 1);
final HashMap<String, Object> runParams = new HashMap<String, Object>();
runParams.put("Attackers", list);
@@ -394,7 +393,7 @@ public class PhaseUtil {
Singletons.getModel().getGameState().getStack().unfreezeStack();
AllZone.getGameLog().add("Combat", CombatUtil.getCombatBlockForLog(), 1);
Singletons.getModel().getGameState().getGameLog().add("Combat", CombatUtil.getCombatBlockForLog(), 1);
}
// ***** Combat Utility **********

View File

@@ -33,7 +33,6 @@ import com.google.common.base.Predicate;
import com.google.common.collect.Iterables;
import com.google.common.collect.Lists;
import forge.AllZone;
import forge.Card;
import forge.CardLists;
@@ -922,7 +921,7 @@ public abstract class Player extends GameEntity implements Comparable<Player> {
public final void addPoisonCounters(final int num, final Card source) {
if (!this.hasKeyword("You can't get poison counters")) {
this.poisonCounters += num;
AllZone.getGameLog().add("Poison", this + " receives a poison counter from " + source, 3);
Singletons.getModel().getGameState().getGameLog().add("Poison", this + " receives a poison counter from " + source, 3);
this.updateObservers();
}
}
@@ -1234,7 +1233,7 @@ public abstract class Player extends GameEntity implements Comparable<Player> {
for (int i = 0; i < newHand; i++) {
drawCard();
}
AllZone.getGameLog().add("Mulligan", this + " has mulliganed down to " + newHand + " cards.", 0);
Singletons.getModel().getGameState().getGameLog().add("Mulligan", this + " has mulliganed down to " + newHand + " cards.", 0);
stats.notifyHasMulliganed();
stats.notifyOpeningHandSize(newHand);
return newHand;
@@ -1802,7 +1801,7 @@ public abstract class Player extends GameEntity implements Comparable<Player> {
Singletons.getModel().getGameAction().checkStateEffects();
// add to log
AllZone.getGameLog().add("Land", this + " played " + land, 2);
Singletons.getModel().getGameState().getGameLog().add("Land", this + " played " + land, 2);
// Run triggers
final HashMap<String, Object> runParams = new HashMap<String, Object>();

View File

@@ -413,7 +413,7 @@ public class MagicStack extends MyObservable {
if (sp instanceof AbilityMana) { // Mana Abilities go straight through
sp.resolve();
sp.resetOnceResolved();
AllZone.getGameLog().add("Mana", sp.getSourceCard() + " - " + sp.getDescription(), 4);
Singletons.getModel().getGameState().getGameLog().add("Mana", sp.getSourceCard() + " - " + sp.getDescription(), 4);
return;
}
@@ -456,7 +456,7 @@ public class MagicStack extends MyObservable {
}
sb.append(".");
AllZone.getGameLog().add("AddToStack", sb.toString(), 2);
Singletons.getModel().getGameState().getGameLog().add("AddToStack", sb.toString(), 2);
//============= GameLog ======================
// if activating player slips through the cracks, assign activating
@@ -897,14 +897,14 @@ public class MagicStack extends MyObservable {
if (this.hasFizzled(sa, source, false)) { // Fizzle
// TODO: Spell fizzles, what's the best way to alert player?
Log.debug(source.getName() + " ability fizzles.");
AllZone.getGameLog().add("ResolveStack", source.getName() + " ability fizzles.", 2);
Singletons.getModel().getGameState().getGameLog().add("ResolveStack", source.getName() + " ability fizzles.", 2);
this.finishResolving(sa, true);
} else if (sa.getAbilityFactory() != null) {
AllZone.getGameLog().add("ResolveStack", sa.getStackDescription(), 2);
Singletons.getModel().getGameState().getGameLog().add("ResolveStack", sa.getStackDescription(), 2);
AbilityFactory.handleRemembering(sa, sa.getAbilityFactory());
AbilityFactory.resolve(sa, true);
} else {
AllZone.getGameLog().add("ResolveStack", sa.getStackDescription(), 2);
Singletons.getModel().getGameState().getGameLog().add("ResolveStack", sa.getStackDescription(), 2);
sa.resolve();
this.finishResolving(sa, false);
}

View File

@@ -120,7 +120,7 @@ public class ViewWinLose {
// Assemble game log scroller.
txtLog = new FTextArea();
txtLog.setText(AllZone.getGameLog().getLogText());
txtLog.setText(Singletons.getModel().getGameState().getGameLog().getLogText());
txtLog.setFont(FSkin.getFont(14));
// Add all components accordingly.

View File

@@ -25,8 +25,8 @@ import javax.swing.JTextArea;
import javax.swing.border.EmptyBorder;
import net.miginfocom.swing.MigLayout;
import forge.AllZone;
import forge.GameLog.LogEntry;
import forge.Singletons;
import forge.gui.framework.DragCell;
import forge.gui.framework.DragTab;
import forge.gui.framework.EDocID;
@@ -118,7 +118,7 @@ public enum VLog implements IVDoc {
// TODO - some option to make this configurable is probably desirable
// By default, grab everything log level 3 or less.
final List<LogEntry> data = AllZone.getGameLog().getLogEntries(3);
final List<LogEntry> data = Singletons.getModel().getGameState().getGameLog().getLogEntries(3);
final int size = data.size();
pnl.removeAll();