"Halls of My Home"
This commit is contained in:
@@ -15,6 +15,10 @@ public class GameUtils {
|
||||
return shadowPlayers.toArray(new String[shadowPlayers.size()]);
|
||||
}
|
||||
|
||||
public static String[] getAllPlayers(LotroGame game) {
|
||||
return game.getGameState().getPlayerOrder().getAllPlayers().toArray(new String[0]);
|
||||
}
|
||||
|
||||
public static List<PhysicalCard> getRandomCards(List<? extends PhysicalCard> cards, int count) {
|
||||
List<PhysicalCard> randomizedCards = new ArrayList<PhysicalCard>(cards);
|
||||
Collections.shuffle(randomizedCards);
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
package com.gempukku.lotro.cards.effects;
|
||||
|
||||
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.timing.UnrespondableEffect;
|
||||
|
||||
public class DiscardCardFromDeckEffect extends UnrespondableEffect {
|
||||
private String _playerId;
|
||||
private PhysicalCard _card;
|
||||
|
||||
public DiscardCardFromDeckEffect(String playerId, PhysicalCard card) {
|
||||
_playerId = playerId;
|
||||
_card = card;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canPlayEffect(LotroGame game) {
|
||||
return game.getGameState().getDeck(_playerId).contains(_card);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void playEffect(LotroGame game) {
|
||||
GameState gameState = game.getGameState();
|
||||
gameState.removeCardFromZone(_card);
|
||||
gameState.addCardToZone(_card, Zone.DISCARD);
|
||||
}
|
||||
}
|
||||
@@ -1,14 +1,26 @@
|
||||
package com.gempukku.lotro.cards.set1.dwarven;
|
||||
|
||||
import com.gempukku.lotro.cards.AbstractLotroCardBlueprint;
|
||||
import com.gempukku.lotro.common.CardType;
|
||||
import com.gempukku.lotro.common.Culture;
|
||||
import com.gempukku.lotro.common.Keyword;
|
||||
import com.gempukku.lotro.common.Side;
|
||||
import com.gempukku.lotro.cards.GameUtils;
|
||||
import com.gempukku.lotro.cards.PlayConditions;
|
||||
import com.gempukku.lotro.cards.actions.PlayEventAction;
|
||||
import com.gempukku.lotro.cards.effects.DiscardCardFromDeckEffect;
|
||||
import com.gempukku.lotro.cards.effects.ExertCharacterEffect;
|
||||
import com.gempukku.lotro.common.*;
|
||||
import com.gempukku.lotro.filters.Filters;
|
||||
import com.gempukku.lotro.game.PhysicalCard;
|
||||
import com.gempukku.lotro.game.state.LotroGame;
|
||||
import com.gempukku.lotro.logic.actions.CostToEffectAction;
|
||||
import com.gempukku.lotro.logic.decisions.ArbitraryCardsSelectionDecision;
|
||||
import com.gempukku.lotro.logic.decisions.DecisionResultInvalidException;
|
||||
import com.gempukku.lotro.logic.decisions.MultipleChoiceAwaitingDecision;
|
||||
import com.gempukku.lotro.logic.effects.ChooseActiveCardEffect;
|
||||
import com.gempukku.lotro.logic.effects.PlayoutDecisionEffect;
|
||||
import com.gempukku.lotro.logic.timing.Action;
|
||||
import com.gempukku.lotro.logic.timing.UnrespondableEffect;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@@ -32,8 +44,85 @@ public class Card1_018 extends AbstractLotroCardBlueprint {
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<? extends Action> getPlayablePhaseActions(String playerId, LotroGame game, PhysicalCard self) {
|
||||
// TODO
|
||||
public List<? extends Action> getPlayablePhaseActions(final String playerId, final LotroGame game, PhysicalCard self) {
|
||||
if (PlayConditions.canPlayFPCardDuringPhase(game, Phase.FELLOWSHIP, self)
|
||||
&& Filters.canSpot(game.getGameState(), game.getModifiersQuerying(), Filters.keyword(Keyword.DWARF), Filters.canExert())) {
|
||||
final PlayEventAction action = new PlayEventAction(self);
|
||||
action.addCost(
|
||||
new ChooseActiveCardEffect(playerId, "Choose a Dwarf", Filters.keyword(Keyword.DWARF), Filters.canExert()) {
|
||||
@Override
|
||||
protected void cardSelected(LotroGame game, PhysicalCard dwarf) {
|
||||
action.addCost(new ExertCharacterEffect(dwarf));
|
||||
}
|
||||
});
|
||||
action.addEffect(
|
||||
new PlayoutDecisionEffect(game.getUserFeedback(), playerId,
|
||||
new MultipleChoiceAwaitingDecision(1, "Choose player", GameUtils.getAllPlayers(game)) {
|
||||
@Override
|
||||
protected void validDecisionMade(int index, final String chosenPlayerId) {
|
||||
List<? extends PhysicalCard> deck = game.getGameState().getDeck(chosenPlayerId);
|
||||
int topCards = Math.min(deck.size(), 3);
|
||||
final List<PhysicalCard> topDeckCards = new LinkedList<PhysicalCard>(deck.subList(0, topCards));
|
||||
|
||||
if (topDeckCards.size() > 0) {
|
||||
List<PhysicalCard> shadowCards = Filters.filter(topDeckCards, game.getGameState(), game.getModifiersQuerying(), Filters.side(Side.SHADOW));
|
||||
|
||||
if (shadowCards.size() > 0) {
|
||||
action.addEffect(
|
||||
new PlayoutDecisionEffect(game.getUserFeedback(), playerId,
|
||||
new ArbitraryCardsSelectionDecision(1, "Choose shadow card to discard", shadowCards, 0, 1) {
|
||||
@Override
|
||||
public void decisionMade(String result) throws DecisionResultInvalidException {
|
||||
List<PhysicalCard> selectedCards = getSelectedCardsByResponse(result);
|
||||
if (selectedCards.size() > 0) {
|
||||
action.addEffect(new DiscardCardFromDeckEffect(chosenPlayerId, selectedCards.get(0)));
|
||||
topDeckCards.remove(selectedCards.get(0));
|
||||
}
|
||||
|
||||
if (topDeckCards.size() > 0) {
|
||||
for (PhysicalCard topDeckCard : topDeckCards)
|
||||
game.getGameState().removeCardFromZone(topDeckCard);
|
||||
|
||||
action.addEffect(new ChooseCardToPutOnTop(action, playerId, topDeckCards));
|
||||
}
|
||||
}
|
||||
}));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
})
|
||||
);
|
||||
|
||||
return Collections.singletonList(action);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private class ChooseCardToPutOnTop extends UnrespondableEffect {
|
||||
private CostToEffectAction _action;
|
||||
private String _playerIdDeciding;
|
||||
private List<PhysicalCard> _cardsToPutOnTop;
|
||||
|
||||
private ChooseCardToPutOnTop(CostToEffectAction action, String playerIdDeciding, List<PhysicalCard> cardsToPutOnTop) {
|
||||
_action = action;
|
||||
_playerIdDeciding = playerIdDeciding;
|
||||
_cardsToPutOnTop = cardsToPutOnTop;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void playEffect(final LotroGame game) {
|
||||
game.getUserFeedback().sendAwaitingDecision(_playerIdDeciding,
|
||||
new ArbitraryCardsSelectionDecision(1, "Choose card to put on top", _cardsToPutOnTop, 1, 1) {
|
||||
@Override
|
||||
public void decisionMade(String result) throws DecisionResultInvalidException {
|
||||
PhysicalCard card = getSelectedCardsByResponse(result).get(0);
|
||||
game.getGameState().putCardOnTopOfDeck(card);
|
||||
_cardsToPutOnTop.remove(card);
|
||||
if (_cardsToPutOnTop.size() > 0)
|
||||
_action.addEffect(new ChooseCardToPutOnTop(_action, _playerIdDeciding, _cardsToPutOnTop));
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,9 +1,6 @@
|
||||
package com.gempukku.lotro.filters;
|
||||
|
||||
import com.gempukku.lotro.common.CardType;
|
||||
import com.gempukku.lotro.common.Culture;
|
||||
import com.gempukku.lotro.common.Keyword;
|
||||
import com.gempukku.lotro.common.Zone;
|
||||
import com.gempukku.lotro.common.*;
|
||||
import com.gempukku.lotro.game.CompletePhysicalCardVisitor;
|
||||
import com.gempukku.lotro.game.PhysicalCard;
|
||||
import com.gempukku.lotro.game.PhysicalCardVisitor;
|
||||
@@ -63,6 +60,15 @@ public class Filters {
|
||||
return visitor.getCounter();
|
||||
}
|
||||
|
||||
public static Filter side(final Side side) {
|
||||
return new Filter() {
|
||||
@Override
|
||||
public boolean accepts(GameState gameState, ModifiersQuerying modifiersQuerying, PhysicalCard physicalCard) {
|
||||
return physicalCard.getBlueprint().getSide() == side;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
public static Filter owner(final String playerId) {
|
||||
return new Filter() {
|
||||
@Override
|
||||
|
||||
@@ -217,6 +217,10 @@ public class GameState {
|
||||
addCardToZone(card, Zone.DECK);
|
||||
}
|
||||
|
||||
public void putCardOnTopOfDeck(PhysicalCard card) {
|
||||
_decks.get(card.getOwner()).add(0, (PhysicalCardImpl) card);
|
||||
}
|
||||
|
||||
public boolean iterateActiveCards(PhysicalCardVisitor physicalCardVisitor) {
|
||||
for (List<PhysicalCardImpl> physicalCards : _inPlay.values()) {
|
||||
for (PhysicalCardImpl physicalCard : physicalCards) {
|
||||
|
||||
Reference in New Issue
Block a user