Adding extra formats and Mulligan rule.

This commit is contained in:
marcins78@gmail.com
2011-10-18 14:48:48 +00:00
parent 45c3c6bd09
commit 0be747f98e
21 changed files with 149 additions and 28 deletions

View File

@@ -1,10 +1,11 @@
package com.gempukku.lotro.game.formats;
package com.gempukku.lotro.game;
import com.gempukku.lotro.game.DeckInvalidException;
import com.gempukku.lotro.logic.vo.LotroDeck;
public interface LotroFormat {
public boolean isOrderedSites();
public boolean hasMulliganRule();
public void validateDeck(LotroDeck deck) throws DeckInvalidException;
}

View File

@@ -2,6 +2,7 @@ package com.gempukku.lotro.game.state;
import com.gempukku.lotro.communication.UserFeedback;
import com.gempukku.lotro.game.ActionsEnvironment;
import com.gempukku.lotro.game.LotroFormat;
import com.gempukku.lotro.logic.modifiers.ModifiersEnvironment;
import com.gempukku.lotro.logic.modifiers.ModifiersQuerying;
@@ -23,4 +24,6 @@ public interface LotroGame {
public void playerLost(String currentPlayerId, String reason);
public String getWinnerPlayerId();
public LotroFormat getFormat();
}

View File

@@ -7,6 +7,7 @@ import com.gempukku.lotro.communication.UserFeedback;
import com.gempukku.lotro.filters.Filters;
import com.gempukku.lotro.game.ActionsEnvironment;
import com.gempukku.lotro.game.LotroCardBlueprintLibrary;
import com.gempukku.lotro.game.LotroFormat;
import com.gempukku.lotro.game.PhysicalCard;
import com.gempukku.lotro.game.state.GameState;
import com.gempukku.lotro.game.state.LotroGame;
@@ -31,6 +32,7 @@ public class DefaultLotroGame implements LotroGame {
private ActionStack _actionStack;
private Map<String, GameStateListener> _gameStateListeners = new HashMap<String, GameStateListener>();
private LotroFormat _format;
private GameResultListener _gameResultListener;
private Set<String> _allPlayers;
@@ -39,7 +41,8 @@ public class DefaultLotroGame implements LotroGame {
private String _winReason;
private Map<String, String> _losers = new HashMap<String, String>();
public DefaultLotroGame(Map<String, LotroDeck> decks, UserFeedback userFeedback, GameResultListener gameResultListener, final LotroCardBlueprintLibrary library) {
public DefaultLotroGame(LotroFormat format, Map<String, LotroDeck> decks, UserFeedback userFeedback, GameResultListener gameResultListener, final LotroCardBlueprintLibrary library) {
_format = format;
_gameResultListener = gameResultListener;
_actionStack = new ActionStack();
@@ -80,6 +83,11 @@ public class DefaultLotroGame implements LotroGame {
ruleSet.applyRuleSet();
}
@Override
public LotroFormat getFormat() {
return _format;
}
public void startGame() {
_turnProcedure.carryOutPendingActionsUntilDecisionNeeded();
}

View File

@@ -0,0 +1,57 @@
package com.gempukku.lotro.logic.timing.processes.pregame;
import com.gempukku.lotro.common.Zone;
import com.gempukku.lotro.game.PhysicalCard;
import com.gempukku.lotro.game.state.GameState;
import com.gempukku.lotro.game.state.LotroGame;
import com.gempukku.lotro.logic.PlayOrder;
import com.gempukku.lotro.logic.decisions.MultipleChoiceAwaitingDecision;
import com.gempukku.lotro.logic.timing.processes.GameProcess;
import com.gempukku.lotro.logic.timing.processes.turn.StartOfTurnGameProcess;
import java.util.HashSet;
import java.util.Set;
public class MulliganProcess implements GameProcess {
private LotroGame _game;
private PlayOrder _playOrder;
private GameProcess _nextProcess;
public MulliganProcess(LotroGame game, PlayOrder playOrder) {
_game = game;
_playOrder = playOrder;
}
@Override
public void process() {
final String nextPlayer = _playOrder.getNextPlayer();
if (nextPlayer != null) {
_game.getUserFeedback().sendAwaitingDecision(nextPlayer,
new MultipleChoiceAwaitingDecision(1, "Do you wish to mulligan? (Shuffle cards back and draw 6)", new String[]{"No", "Yes"}) {
@Override
protected void validDecisionMade(int index, String result) {
if (result.equals("Yes")) {
final GameState gameState = _game.getGameState();
Set<PhysicalCard> hand = new HashSet<PhysicalCard>(gameState.getHand(nextPlayer));
gameState.removeCardsFromZone(hand);
for (PhysicalCard card : hand)
gameState.addCardToZone(card, Zone.DECK);
gameState.shuffleDeck(nextPlayer);
for (int i = 0; i < 6; i++)
gameState.playerDrawsCard(nextPlayer);
}
}
});
_nextProcess = new MulliganProcess(_game, _playOrder);
} else {
_nextProcess = new StartOfTurnGameProcess(_game);
}
}
@Override
public GameProcess getNextProcess() {
return _nextProcess;
}
}

View File

@@ -44,6 +44,6 @@ public class PlayRingBearerRingAndAddBurdersGameProcess implements GameProcess {
@Override
public GameProcess getNextProcess() {
GameState gameState = _game.getGameState();
return new PlayStartingFellowshipGameProcess(_game, gameState.getPlayerOrder().getClockwisePlayOrder(_firstPlayer, false));
return new PlayStartingFellowshipGameProcess(_game, gameState.getPlayerOrder().getClockwisePlayOrder(_firstPlayer, false), _firstPlayer);
}
}

View File

@@ -10,12 +10,14 @@ import java.util.List;
public class PlayStartingFellowshipGameProcess implements GameProcess {
private LotroGame _game;
private PlayOrder _playOrder;
private String _firstPlayer;
private GameProcess _nextProcess;
public PlayStartingFellowshipGameProcess(LotroGame game, PlayOrder playOrder) {
public PlayStartingFellowshipGameProcess(LotroGame game, PlayOrder playOrder, String firstPlayer) {
_game = game;
_playOrder = playOrder;
_firstPlayer = firstPlayer;
}
@Override
@@ -34,9 +36,9 @@ public class PlayStartingFellowshipGameProcess implements GameProcess {
for (PhysicalCard physicalCard : attachedToRingBearer)
_game.getGameState().startAffecting(_game, physicalCard, _game.getModifiersEnvironment());
_nextProcess = new PlayerPlaysStartingFellowshipGameProcess(_game, nextPlayer, new PlayStartingFellowshipGameProcess(_game, _playOrder));
_nextProcess = new PlayerPlaysStartingFellowshipGameProcess(_game, nextPlayer, new PlayStartingFellowshipGameProcess(_game, _playOrder, _firstPlayer));
} else {
_nextProcess = new PlayersDrawEightCardsGameProcess(_game);
_nextProcess = new PlayersDrawEightCardsGameProcess(_game, _firstPlayer);
}
}

View File

@@ -7,9 +7,11 @@ import com.gempukku.lotro.logic.timing.processes.turn.StartOfTurnGameProcess;
public class PlayersDrawEightCardsGameProcess implements GameProcess {
private LotroGame _game;
private String _firstPlayer;
public PlayersDrawEightCardsGameProcess(LotroGame game) {
public PlayersDrawEightCardsGameProcess(LotroGame game, String firstPlayer) {
_game = game;
_firstPlayer = firstPlayer;
}
@Override
@@ -24,6 +26,9 @@ public class PlayersDrawEightCardsGameProcess implements GameProcess {
@Override
public GameProcess getNextProcess() {
return new StartOfTurnGameProcess(_game);
if (_game.getFormat().hasMulliganRule())
return new MulliganProcess(_game, _game.getGameState().getPlayerOrder().getClockwisePlayOrder(_firstPlayer, false));
else
return new StartOfTurnGameProcess(_game);
}
}

View File

@@ -2,7 +2,6 @@ package com.gempukku.lotro.game;
import com.gempukku.lotro.common.Keyword;
import com.gempukku.lotro.common.Phase;
import com.gempukku.lotro.game.formats.LotroFormat;
import com.gempukku.lotro.logic.decisions.AwaitingDecision;
import com.gempukku.lotro.logic.decisions.DecisionResultInvalidException;
import com.gempukku.lotro.logic.modifiers.Modifier;
@@ -42,7 +41,7 @@ public class LotroGameMediator {
_playerClocks.put(participantId, 0);
_playersPlaying.add(participantId);
}
_lotroGame = new DefaultLotroGame(decks, _userFeedback, gameResultListener, library);
_lotroGame = new DefaultLotroGame(lotroFormat, decks, _userFeedback, gameResultListener, library);
}
public Set<String> getPlayersPlaying() {

View File

@@ -8,7 +8,6 @@ import com.gempukku.lotro.db.DbAccess;
import com.gempukku.lotro.db.DeckDAO;
import com.gempukku.lotro.db.PlayerDAO;
import com.gempukku.lotro.db.vo.Player;
import com.gempukku.lotro.game.formats.LotroFormat;
import com.gempukku.lotro.logic.timing.GameResultListener;
import com.gempukku.lotro.logic.vo.LotroDeck;
import org.apache.log4j.Logger;

View File

@@ -7,6 +7,7 @@ import com.gempukku.lotro.common.Side;
import com.gempukku.lotro.game.DeckInvalidException;
import com.gempukku.lotro.game.LotroCardBlueprint;
import com.gempukku.lotro.game.LotroCardBlueprintLibrary;
import com.gempukku.lotro.game.LotroFormat;
import com.gempukku.lotro.logic.vo.LotroDeck;
import java.util.HashMap;
@@ -19,17 +20,24 @@ public abstract class DefaultLotroFormat implements LotroFormat {
private Block _siteBlock;
private boolean _validateShadowFPCount = true;
private int _maximumSameName = 4;
private boolean _mulliganRule;
private int _minimumDeckSize = 60;
private Set<String> _bannedCards = new HashSet<String>();
private Set<String> _restrictedCards = new HashSet<String>();
private Set<Integer> _validSets = new HashSet<Integer>();
public DefaultLotroFormat(LotroCardBlueprintLibrary library, Block siteBlock, boolean validateShadowFPCount, int minimumDeckSize, int maximumSameName) {
public DefaultLotroFormat(LotroCardBlueprintLibrary library, Block siteBlock, boolean validateShadowFPCount, int minimumDeckSize, int maximumSameName, boolean mulliganRule) {
_library = library;
_siteBlock = siteBlock;
_validateShadowFPCount = validateShadowFPCount;
_minimumDeckSize = minimumDeckSize;
_maximumSameName = maximumSameName;
_mulliganRule = mulliganRule;
}
@Override
public boolean hasMulliganRule() {
return _mulliganRule;
}
protected void addBannedCard(String baseBlueprintId) {

View File

@@ -4,8 +4,8 @@ import com.gempukku.lotro.common.Block;
import com.gempukku.lotro.game.LotroCardBlueprintLibrary;
public class FotRBlockFormat extends DefaultLotroFormat {
public FotRBlockFormat(LotroCardBlueprintLibrary library) {
super(library, Block.FELLOWSHIP, true, 60, 4);
public FotRBlockFormat(LotroCardBlueprintLibrary library, boolean mulliganRule) {
super(library, Block.FELLOWSHIP, true, 60, 4, mulliganRule);
addRestrictedCard("1_248");
addValidSet(1);
addValidSet(2);

View File

@@ -5,7 +5,7 @@ import com.gempukku.lotro.game.LotroCardBlueprintLibrary;
public class FreeFormat extends DefaultLotroFormat {
public FreeFormat(LotroCardBlueprintLibrary library) {
super(library, Block.FELLOWSHIP, false, 0, Integer.MAX_VALUE);
super(library, Block.FELLOWSHIP, false, 0, Integer.MAX_VALUE, false);
}
@Override

View File

@@ -4,8 +4,8 @@ import com.gempukku.lotro.common.Block;
import com.gempukku.lotro.game.LotroCardBlueprintLibrary;
public class TTTBlockFormat extends DefaultLotroFormat {
public TTTBlockFormat(LotroCardBlueprintLibrary library) {
super(library, Block.TWO_TOWERS, true, 60, 4);
public TTTBlockFormat(LotroCardBlueprintLibrary library, boolean mulliganRule) {
super(library, Block.TWO_TOWERS, true, 60, 4, mulliganRule);
addValidSet(4);
addValidSet(5);
addValidSet(6);

View File

@@ -5,7 +5,7 @@ import com.gempukku.lotro.game.LotroCardBlueprintLibrary;
public class TowersStandardFormat extends DefaultLotroFormat {
public TowersStandardFormat(LotroCardBlueprintLibrary library) {
super(library, Block.TWO_TOWERS, true, 60, 4);
super(library, Block.TWO_TOWERS, true, 60, 4, true);
addBannedCard("1_40");
addBannedCard("1_45");

View File

@@ -1,7 +1,7 @@
package com.gempukku.lotro.hall;
import com.gempukku.lotro.game.LotroFormat;
import com.gempukku.lotro.game.LotroGameParticipant;
import com.gempukku.lotro.game.formats.LotroFormat;
import java.util.*;

View File

@@ -6,7 +6,10 @@ import com.gempukku.lotro.db.CollectionDAO;
import com.gempukku.lotro.db.vo.League;
import com.gempukku.lotro.db.vo.Player;
import com.gempukku.lotro.game.*;
import com.gempukku.lotro.game.formats.*;
import com.gempukku.lotro.game.formats.FotRBlockFormat;
import com.gempukku.lotro.game.formats.FreeFormat;
import com.gempukku.lotro.game.formats.TTTBlockFormat;
import com.gempukku.lotro.game.formats.TowersStandardFormat;
import com.gempukku.lotro.league.LeagueService;
import com.gempukku.lotro.logic.vo.LotroDeck;
@@ -40,9 +43,12 @@ public class HallServer extends AbstractServer {
_collectionDao = collectionDao;
_chatServer.createChatRoom("Game Hall");
addFormat("fotr_block", "Fellowship block", "default", new FotRBlockFormat(_lotroServer.getLotroCardBlueprintLibrary()));
addFormat("ttt_block", "Two Towers block", "default", new TTTBlockFormat(_lotroServer.getLotroCardBlueprintLibrary()));
addFormat("fotr_block", "Fellowship block", "default", new FotRBlockFormat(_lotroServer.getLotroCardBlueprintLibrary(), false));
addFormat("c_fotr_block", "Community Fellowship block", "default", new FotRBlockFormat(_lotroServer.getLotroCardBlueprintLibrary(), true));
addFormat("ttt_block", "Two Towers block", "default", new TTTBlockFormat(_lotroServer.getLotroCardBlueprintLibrary(), false));
addFormat("c_ttt_block", "Community Two Towers block", "default", new TTTBlockFormat(_lotroServer.getLotroCardBlueprintLibrary(), true));
addFormat("towers_standard", "Towers Standard", "default", new TowersStandardFormat(_lotroServer.getLotroCardBlueprintLibrary()));
addFormat("whatever", "Format for testing", "default", new FreeFormat(_lotroServer.getLotroCardBlueprintLibrary()));
}

View File

@@ -8,7 +8,7 @@ public class LeagueFormat extends DefaultLotroFormat {
private boolean _orderedSites;
public LeagueFormat(LotroCardBlueprintLibrary library, boolean orderedSites) {
super(library, Block.FELLOWSHIP, true, 60, Integer.MAX_VALUE);
super(library, Block.FELLOWSHIP, true, 60, Integer.MAX_VALUE, true);
_orderedSites = orderedSites;
}

View File

@@ -7,7 +7,7 @@ import com.gempukku.lotro.db.vo.League;
import com.gempukku.lotro.db.vo.Player;
import com.gempukku.lotro.game.CardCollection;
import com.gempukku.lotro.game.LotroCardBlueprintLibrary;
import com.gempukku.lotro.game.formats.LotroFormat;
import com.gempukku.lotro.game.LotroFormat;
import java.util.Set;

View File

@@ -12,7 +12,6 @@ import com.gempukku.lotro.db.PlayerDAO;
import com.gempukku.lotro.db.vo.League;
import com.gempukku.lotro.db.vo.Player;
import com.gempukku.lotro.game.*;
import com.gempukku.lotro.game.formats.LotroFormat;
import com.gempukku.lotro.hall.HallException;
import com.gempukku.lotro.hall.HallInfoVisitor;
import com.gempukku.lotro.hall.HallServer;

View File

@@ -4,7 +4,17 @@
<li>sites from Fellowship block are used,</li>
<li>Ring-bearer skirmish CAN be cancelled,</li>
<li>there is no X-list,</li>
<li>R-list has one card - <i>Forces of Mordor</i>.</li>
<li>R-list has one card - <i>Forces of Mordor</i>,</li>
<li>Mulligan rule IS NOT in effect.</li>
</ul>
<b>Community Fellowship block</b>
<ul>
<li>cards from sets 01-03 are legal,</li>
<li>sites from Fellowship block are used,</li>
<li>Ring-bearer skirmish CAN be cancelled,</li>
<li>there is no X-list,</li>
<li>R-list has one card - <i>Forces of Mordor</i>,</li>
<li>Mulligan rule IS in effect.</li>
</ul>
<b>Two Towers block</b>
<ul>
@@ -12,5 +22,29 @@
<li>sites from The Two Towers block are used,</li>
<li>Ring-bearer skirmish CAN be cancelled,</li>
<li>there is no X-list,</li>
<li>there is no R-list.</li>
<li>there is no R-list,</li>
<li>Mulligan rule IS NOT in effect.</li>
</ul>
<b>Community Two Towers block</b>
<ul>
<li>cards from sets 04-06 are legal,</li>
<li>sites from The Two Towers block are used,</li>
<li>Ring-bearer skirmish CAN be cancelled,</li>
<li>there is no X-list,</li>
<li>there is no R-list,</li>
<li>Mulligan rule IS in effect.</li>
</ul>
<b>Towers Standard</b>
<ul>
<li>cards from sets 01-06 are legal,</li>
<li>sites from The Two Towers block are used,</li>
<li>Ring-bearer skirmish CAN be cancelled,</li>
<li>X-list contains following cards: <i>Elrond, Lord of Rivendell</i>, <i>Galadriel, Lady of Light</i>, <i>Ottar,
Man of Laketown</i>, <i>No Stranger to the Shadows</i>, <i>Savagery to Match Their Numbers</i>, <i>Ulaire
Nertea, Messenger of Dol Guldur</i>, <i>Forces of Mordor</i>, <i>Sting</i>, <i>Flaming Brand</i>, <i>Filibert
Bolger, Wily Rascal</i>, <i>O Elbereth! Gilthoniel!</i>, <i>Aragorn, Heir to the White City</i>, <i>Horn of
Boromir</i>, <i>Saruman, Keeper of Isengard</i>, <i>Uruk Regular</i>,
</li>
<li>there is no R-list,</li>
<li>Mulligan rule IS in effect.</li>
</ul>