mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-18 19:58:00 +00:00
gamelog entries are filled in MatchController class for now, at least displaying gamewinlose is not gamestate's responsibility
GameState.getLandsInPlay inlined
This commit is contained in:
@@ -55,10 +55,8 @@ public class ChooseCardEffect extends SpellEffect {
|
|||||||
? CardFactoryUtil.xCount(host, host.getSVar(sa.getParam("Amount"))) : Integer.parseInt(numericAmount);
|
? CardFactoryUtil.xCount(host, host.getSVar(sa.getParam("Amount"))) : Integer.parseInt(numericAmount);
|
||||||
|
|
||||||
if (sa.hasParam("SunderingTitan")) {
|
if (sa.hasParam("SunderingTitan")) {
|
||||||
final List<Card> land = Singletons.getModel().getGame().getLandsInPlay();
|
final List<Card> land = CardLists.filter(Singletons.getModel().getGame().getCardsIn(ZoneType.Battlefield), Presets.LANDS);
|
||||||
final ArrayList<String> basic = CardType.getBasicTypes();
|
for (final String type : CardType.getBasicTypes()) {
|
||||||
|
|
||||||
for (final String type : basic) {
|
|
||||||
final List<Card> cl = CardLists.getType(land, type);
|
final List<Card> cl = CardLists.getType(land, type);
|
||||||
if (cl.size() > 0) {
|
if (cl.size() > 0) {
|
||||||
final String prompt = "Choose a" + (type.equals("Island") ? "n " : " ") + type;
|
final String prompt = "Choose a" + (type.equals("Island") ? "n " : " ") + type;
|
||||||
|
|||||||
@@ -21,14 +21,12 @@ import java.util.ArrayList;
|
|||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Map.Entry;
|
|
||||||
import java.util.TreeMap;
|
import java.util.TreeMap;
|
||||||
|
|
||||||
import com.google.common.eventbus.EventBus;
|
import com.google.common.eventbus.EventBus;
|
||||||
|
|
||||||
import forge.Card;
|
import forge.Card;
|
||||||
import forge.CardLists;
|
import forge.CardLists;
|
||||||
import forge.CardPredicates.Presets;
|
|
||||||
import forge.ColorChanger;
|
import forge.ColorChanger;
|
||||||
import forge.GameLog;
|
import forge.GameLog;
|
||||||
import forge.Singletons;
|
import forge.Singletons;
|
||||||
@@ -39,7 +37,6 @@ import forge.card.spellability.SpellAbility;
|
|||||||
import forge.card.spellability.SpellAbilityStackInstance;
|
import forge.card.spellability.SpellAbilityStackInstance;
|
||||||
import forge.card.trigger.TriggerHandler;
|
import forge.card.trigger.TriggerHandler;
|
||||||
import forge.card.trigger.TriggerType;
|
import forge.card.trigger.TriggerType;
|
||||||
import forge.game.event.DuelOutcomeEvent;
|
|
||||||
import forge.game.phase.Cleanup;
|
import forge.game.phase.Cleanup;
|
||||||
import forge.game.phase.Combat;
|
import forge.game.phase.Combat;
|
||||||
import forge.game.phase.EndOfCombat;
|
import forge.game.phase.EndOfCombat;
|
||||||
@@ -51,15 +48,11 @@ import forge.game.player.AIPlayer;
|
|||||||
import forge.game.player.HumanPlayer;
|
import forge.game.player.HumanPlayer;
|
||||||
import forge.game.player.LobbyPlayer;
|
import forge.game.player.LobbyPlayer;
|
||||||
import forge.game.player.Player;
|
import forge.game.player.Player;
|
||||||
import forge.game.player.PlayerStatistics;
|
|
||||||
import forge.game.player.PlayerType;
|
import forge.game.player.PlayerType;
|
||||||
import forge.game.zone.MagicStack;
|
import forge.game.zone.MagicStack;
|
||||||
import forge.game.zone.PlayerZone;
|
import forge.game.zone.PlayerZone;
|
||||||
import forge.game.zone.Zone;
|
import forge.game.zone.Zone;
|
||||||
import forge.game.zone.ZoneType;
|
import forge.game.zone.ZoneType;
|
||||||
import forge.gui.match.ViewWinLose;
|
|
||||||
import forge.properties.ForgeProps;
|
|
||||||
import forge.properties.NewConstants.Lang.GuiWinLose.WinLoseText;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents the state of a <i>single game</i> and is
|
* Represents the state of a <i>single game</i> and is
|
||||||
@@ -271,7 +264,7 @@ public class GameState {
|
|||||||
* @return the next timestamp
|
* @return the next timestamp
|
||||||
*/
|
*/
|
||||||
public final long getNextTimestamp() {
|
public final long getNextTimestamp() {
|
||||||
this.setTimestamp(this.getTimestamp() + 1);
|
this.timestamp = this.getTimestamp() + 1;
|
||||||
return this.getTimestamp();
|
return this.getTimestamp();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -284,17 +277,6 @@ public class GameState {
|
|||||||
return this.timestamp;
|
return this.timestamp;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets the timestamp.
|
|
||||||
*
|
|
||||||
* @param timestamp0
|
|
||||||
* the timestamp to set
|
|
||||||
*/
|
|
||||||
protected final void setTimestamp(final long timestamp0) {
|
|
||||||
this.timestamp = timestamp0;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return the replacementHandler
|
* @return the replacementHandler
|
||||||
*/
|
*/
|
||||||
@@ -319,40 +301,8 @@ public class GameState {
|
|||||||
p.onGameOver();
|
p.onGameOver();
|
||||||
}
|
}
|
||||||
match.addGamePlayed(reason, this);
|
match.addGamePlayed(reason, this);
|
||||||
|
|
||||||
// add result entries to the game log
|
|
||||||
LobbyPlayer human = Singletons.getControl().getPlayer().getLobbyPlayer();
|
|
||||||
String title = ForgeProps.getLocalized(match.getLastGameOutcome().isWinner(human) ? WinLoseText.WIN : WinLoseText.LOSE);
|
|
||||||
gameLog.add("Final", title, 0);
|
|
||||||
|
|
||||||
List<String> outcomes = new ArrayList<String>();
|
|
||||||
for (Entry<LobbyPlayer, PlayerStatistics> p : match.getLastGameOutcome()) {
|
|
||||||
String outcome = String.format("%s %s", p.getKey().equals(human) ? "You have" : p.getKey().getName() + " has",
|
|
||||||
p.getValue().getOutcome().toString());
|
|
||||||
outcomes.add(outcome);
|
|
||||||
gameLog.add("Final", outcome, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
int humanWins = match.getGamesWonBy(human);
|
|
||||||
int humanLosses = match.getPlayedGames().size() - humanWins;
|
|
||||||
String statsSummary = ForgeProps.getLocalized(WinLoseText.WON) + humanWins
|
|
||||||
+ ForgeProps.getLocalized(WinLoseText.LOST) + humanLosses;
|
|
||||||
gameLog.add("Final", statsSummary, 0);
|
|
||||||
|
|
||||||
ViewWinLose v = new ViewWinLose(match);
|
|
||||||
v.setTitle(title);
|
|
||||||
v.setOutcomes(outcomes);
|
|
||||||
v.setStatsSummary(statsSummary);
|
|
||||||
|
|
||||||
// Play the win/lose sound
|
|
||||||
boolean humanWon = match.getLastGameOutcome().isWinner(Singletons.getControl().getPlayer().getLobbyPlayer());
|
|
||||||
getEvents().post(new DuelOutcomeEvent(humanWon));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// THESE WERE MOVED HERE FROM AllZoneUtil
|
|
||||||
// They must once become non-static members of this class
|
|
||||||
|
|
||||||
public Zone getZoneOf(final Card c) {
|
public Zone getZoneOf(final Card c) {
|
||||||
if (getStackZone().contains(c)) {
|
if (getStackZone().contains(c)) {
|
||||||
return getStackZone();
|
return getStackZone();
|
||||||
@@ -406,10 +356,6 @@ public class GameState {
|
|||||||
return cards;
|
return cards;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<Card> getLandsInPlay() {
|
|
||||||
return CardLists.filter(getCardsIn(ZoneType.Battlefield), Presets.LANDS);
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isCardExiled(final Card c) {
|
public boolean isCardExiled(final Card c) {
|
||||||
return getCardsIn(ZoneType.Exile).contains(c);
|
return getCardsIn(ZoneType.Exile).contains(c);
|
||||||
}
|
}
|
||||||
@@ -514,8 +460,7 @@ public class GameState {
|
|||||||
public Player getNextPlayerAfter(final Player playerTurn) {
|
public Player getNextPlayerAfter(final Player playerTurn) {
|
||||||
int iPlayer = roIngamePlayers.indexOf(playerTurn);
|
int iPlayer = roIngamePlayers.indexOf(playerTurn);
|
||||||
|
|
||||||
if (-1 == iPlayer && !roIngamePlayers.isEmpty()) { // should do something if playerTurn has just lost!
|
if (-1 == iPlayer && !roIngamePlayers.isEmpty()) { // if playerTurn has just lost
|
||||||
|
|
||||||
int iAlive;
|
int iAlive;
|
||||||
iPlayer = allPlayers.indexOf(playerTurn);
|
iPlayer = allPlayers.indexOf(playerTurn);
|
||||||
do {
|
do {
|
||||||
@@ -535,7 +480,7 @@ public class GameState {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Only game knows how to make siutable players out of just connected clients.
|
* Only game knows how to get suitable players out of just connected clients.
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public Player getIngamePlayer(LobbyPlayer player) {
|
public Player getIngamePlayer(LobbyPlayer player) {
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import java.util.Collections;
|
|||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.Map.Entry;
|
||||||
|
|
||||||
import forge.Singletons;
|
import forge.Singletons;
|
||||||
import forge.Constant.Preferences;
|
import forge.Constant.Preferences;
|
||||||
@@ -12,8 +13,10 @@ import forge.control.FControl;
|
|||||||
import forge.control.input.InputControl;
|
import forge.control.input.InputControl;
|
||||||
import forge.deck.Deck;
|
import forge.deck.Deck;
|
||||||
import forge.error.ErrorViewer;
|
import forge.error.ErrorViewer;
|
||||||
|
import forge.game.event.DuelOutcomeEvent;
|
||||||
import forge.game.player.LobbyPlayer;
|
import forge.game.player.LobbyPlayer;
|
||||||
import forge.game.player.Player;
|
import forge.game.player.Player;
|
||||||
|
import forge.game.player.PlayerStatistics;
|
||||||
import forge.game.player.PlayerType;
|
import forge.game.player.PlayerType;
|
||||||
import forge.game.zone.ZoneType;
|
import forge.game.zone.ZoneType;
|
||||||
import forge.gui.GuiInput;
|
import forge.gui.GuiInput;
|
||||||
@@ -21,6 +24,7 @@ import forge.gui.framework.EDocID;
|
|||||||
import forge.gui.framework.SDisplayUtil;
|
import forge.gui.framework.SDisplayUtil;
|
||||||
import forge.gui.match.CMatchUI;
|
import forge.gui.match.CMatchUI;
|
||||||
import forge.gui.match.VMatchUI;
|
import forge.gui.match.VMatchUI;
|
||||||
|
import forge.gui.match.ViewWinLose;
|
||||||
import forge.gui.match.controllers.CDock;
|
import forge.gui.match.controllers.CDock;
|
||||||
import forge.gui.match.controllers.CLog;
|
import forge.gui.match.controllers.CLog;
|
||||||
import forge.gui.match.controllers.CMessage;
|
import forge.gui.match.controllers.CMessage;
|
||||||
@@ -28,6 +32,8 @@ import forge.gui.match.controllers.CStack;
|
|||||||
import forge.gui.match.nonsingleton.VField;
|
import forge.gui.match.nonsingleton.VField;
|
||||||
import forge.gui.match.views.VAntes;
|
import forge.gui.match.views.VAntes;
|
||||||
import forge.properties.ForgePreferences.FPref;
|
import forge.properties.ForgePreferences.FPref;
|
||||||
|
import forge.properties.ForgeProps;
|
||||||
|
import forge.properties.NewConstants.Lang.GuiWinLose.WinLoseText;
|
||||||
import forge.util.Aggregates;
|
import forge.util.Aggregates;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -87,6 +93,34 @@ public class MatchController {
|
|||||||
GameOutcome result = new GameOutcome(reason, game.getRegisteredPlayers());
|
GameOutcome result = new GameOutcome(reason, game.getRegisteredPlayers());
|
||||||
result.setTurnsPlayed(game.getPhaseHandler().getTurn());
|
result.setTurnsPlayed(game.getPhaseHandler().getTurn());
|
||||||
gamesPlayed.add(result);
|
gamesPlayed.add(result);
|
||||||
|
|
||||||
|
// add result entries to the game log
|
||||||
|
LobbyPlayer human = Singletons.getControl().getPlayer().getLobbyPlayer();
|
||||||
|
String title = ForgeProps.getLocalized(result.isWinner(human) ? WinLoseText.WIN : WinLoseText.LOSE);
|
||||||
|
game.getGameLog().add("Final", title, 0);
|
||||||
|
|
||||||
|
List<String> outcomes = new ArrayList<String>();
|
||||||
|
for (Entry<LobbyPlayer, PlayerStatistics> p : result) {
|
||||||
|
String outcome = String.format("%s %s", p.getKey().equals(human) ? "You have" : p.getKey().getName() + " has",
|
||||||
|
p.getValue().getOutcome().toString());
|
||||||
|
outcomes.add(outcome);
|
||||||
|
game.getGameLog().add("Final", outcome, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
int humanWins = getGamesWonBy(human);
|
||||||
|
int humanLosses = getPlayedGames().size() - humanWins;
|
||||||
|
String statsSummary = ForgeProps.getLocalized(WinLoseText.WON) + humanWins
|
||||||
|
+ ForgeProps.getLocalized(WinLoseText.LOST) + humanLosses;
|
||||||
|
game.getGameLog().add("Final", statsSummary, 0);
|
||||||
|
|
||||||
|
ViewWinLose v = new ViewWinLose(this);
|
||||||
|
v.setTitle(title);
|
||||||
|
v.setOutcomes(outcomes);
|
||||||
|
v.setStatsSummary(statsSummary);
|
||||||
|
|
||||||
|
// Play the win/lose sound
|
||||||
|
boolean humanWon = result.isWinner(human);
|
||||||
|
game.getEvents().post(new DuelOutcomeEvent(humanWon));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user