Hand size is based on format.

This commit is contained in:
marcins78
2014-06-18 14:35:08 +00:00
parent 9def156b4a
commit 4b0489657c
6 changed files with 46 additions and 18 deletions

View File

@@ -35,4 +35,6 @@ public interface LotroFormat {
public Block getSiteBlock();
public String getSurveyUrl();
public int getHandSize();
}

View File

@@ -3,7 +3,11 @@ package com.gempukku.lotro.game.state.actions;
import com.gempukku.lotro.common.Filterable;
import com.gempukku.lotro.common.Phase;
import com.gempukku.lotro.filters.Filters;
import com.gempukku.lotro.game.*;
import com.gempukku.lotro.game.AbstractActionProxy;
import com.gempukku.lotro.game.ActionProxy;
import com.gempukku.lotro.game.ActionsEnvironment;
import com.gempukku.lotro.game.CompletePhysicalCardVisitor;
import com.gempukku.lotro.game.PhysicalCard;
import com.gempukku.lotro.game.state.LotroGame;
import com.gempukku.lotro.logic.actions.ActivateCardAction;
import com.gempukku.lotro.logic.actions.OptionalTriggerAction;
@@ -17,15 +21,20 @@ import com.gempukku.lotro.logic.timing.results.AssignedToSkirmishResult;
import com.gempukku.lotro.logic.timing.results.CharacterLostSkirmishResult;
import com.gempukku.lotro.logic.timing.results.CharacterWonSkirmishResult;
import com.gempukku.lotro.logic.timing.results.PlayCardResult;
import com.gempukku.lotro.logic.timing.rules.CharacterDeathRule;
import org.apache.log4j.Logger;
import java.util.*;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Set;
public class DefaultActionsEnvironment implements ActionsEnvironment {
private static Logger LOG = Logger.getLogger(DefaultActionsEnvironment.class);
private LotroGame _lotroGame;
private CharacterDeathRule _characterDeathRule;
private ActionStack _actionStack;
private List<ActionProxy> _actionProxies = new LinkedList<ActionProxy>();
private Map<Phase, List<ActionProxy>> _untilStartOfPhaseActionProxies = new HashMap<Phase, List<ActionProxy>>();
@@ -102,10 +111,6 @@ public class DefaultActionsEnvironment implements ActionsEnvironment {
_effectResults.add(effectResult);
}
public boolean hasPendingEffectResults() {
return _effectResults.size() > 0;
}
public Set<EffectResult> consumeEffectResults() {
Set<EffectResult> result = _effectResults;
_effectResults = new HashSet<EffectResult>();

View File

@@ -83,11 +83,13 @@ public class PlayerReconcilesAction implements Action {
game.getGameState().sendMessage(_playerId + " reconciles");
_effectQueue = new LinkedList<Effect>();
final int handSize = game.getFormat().getHandSize();
GameState gameState = _game.getGameState();
final Set<? extends PhysicalCard> cardsInHand = new HashSet<PhysicalCard>(gameState.getHand(_playerId));
if (cardsInHand.size() > 8) {
if (cardsInHand.size() > handSize) {
_effectQueue.add(new PlayoutDecisionEffect(_playerId,
new CardsSelectionDecision(1, "Choose cards to discard down to 8", cardsInHand, cardsInHand.size() - 8, cardsInHand.size() - 8) {
new CardsSelectionDecision(1, "Choose cards to discard down to "+handSize, cardsInHand, cardsInHand.size() - handSize, cardsInHand.size() - handSize) {
@Override
public void decisionMade(String result) throws DecisionResultInvalidException {
Set<PhysicalCard> cards = getSelectedCardsByResponse(result);
@@ -106,15 +108,15 @@ public class PlayerReconcilesAction implements Action {
_effectQueue.add(new DiscardCardsFromHandEffect(null, _playerId, selectedCards, false));
}
int cardsInHandAfterDiscard = cardsInHand.size() - selectedCards.size();
if (cardsInHandAfterDiscard < 8) {
_effectQueue.add(new DrawCardsEffect(PlayerReconcilesAction.this, _playerId, 8 - cardsInHandAfterDiscard));
if (cardsInHandAfterDiscard < handSize) {
_effectQueue.add(new DrawCardsEffect(PlayerReconcilesAction.this, _playerId, handSize - cardsInHandAfterDiscard));
}
_effectQueue.add(
new TriggeringResultEffect(new ReconcileResult(_playerId), "Player reconciled"));
}
}));
} else {
_effectQueue.add(new DrawCardsEffect(PlayerReconcilesAction.this, _playerId, 8));
_effectQueue.add(new DrawCardsEffect(PlayerReconcilesAction.this, _playerId, handSize));
_effectQueue.add(
new TriggeringResultEffect(new ReconcileResult(_playerId), "Player reconciled"));
}

View File

@@ -23,10 +23,12 @@ public class MulliganProcess implements GameProcess {
@Override
public void process(final LotroGame game) {
final int handSize = game.getFormat().getHandSize();
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"}) {
new MultipleChoiceAwaitingDecision(1, "Do you wish to mulligan? (Shuffle cards back and draw " + (handSize - 2) + ")", new String[]{"No", "Yes"}) {
@Override
protected void validDecisionMade(int index, String result) {
if (index == 1) {
@@ -38,7 +40,7 @@ public class MulliganProcess implements GameProcess {
gameState.addCardToZone(game, card, Zone.DECK);
gameState.shuffleDeck(nextPlayer);
for (int i = 0; i < 6; i++)
for (int i = 0; i < handSize - 2; i++)
gameState.playerDrawsCard(nextPlayer);
} else {
game.getGameState().sendMessage(nextPlayer + " decides not to mulligan");

View File

@@ -16,10 +16,12 @@ public class PlayersDrawEightCardsGameProcess implements GameProcess {
@Override
public void process(LotroGame game) {
int handSize = game.getFormat().getHandSize();
GameState gameState = game.getGameState();
for (String player : gameState.getPlayerOrder().getAllPlayers()) {
gameState.shuffleDeck(player);
for (int i = 0; i < 8; i++)
for (int i = 0; i < handSize; i++)
gameState.playerDrawsCard(player);
}
gameState.setCurrentPhase(Phase.BETWEEN_TURNS);

View File

@@ -4,11 +4,21 @@ import com.gempukku.lotro.common.Block;
import com.gempukku.lotro.common.CardType;
import com.gempukku.lotro.common.Keyword;
import com.gempukku.lotro.common.Side;
import com.gempukku.lotro.game.*;
import com.gempukku.lotro.game.CardNotFoundException;
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.GameUtils;
import com.gempukku.lotro.logic.vo.LotroDeck;
import java.util.*;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
public class DefaultLotroFormat implements LotroFormat {
private LotroCardBlueprintLibrary _library;
@@ -111,6 +121,11 @@ public class DefaultLotroFormat implements LotroFormat {
return _surveyUrl;
}
@Override
public int getHandSize() {
return 8;
}
protected void addBannedCard(String baseBlueprintId) {
if (baseBlueprintId.contains("-")) {
String[] parts = baseBlueprintId.split("_");