"Dunlending Ransacker"
Taking control of sites.
This commit is contained in:
@@ -9,6 +9,9 @@ import com.gempukku.lotro.game.state.LotroGame;
|
||||
import com.gempukku.lotro.logic.GameUtils;
|
||||
import com.gempukku.lotro.logic.timing.UnrespondableEffect;
|
||||
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
public class PlaySiteEffect extends UnrespondableEffect {
|
||||
private String _playerId;
|
||||
private int _siteNumber;
|
||||
@@ -23,17 +26,36 @@ public class PlaySiteEffect extends UnrespondableEffect {
|
||||
GameState gameState = game.getGameState();
|
||||
PhysicalCard newSite = Filters.filter(gameState.getAdventureDeck(_playerId), game.getGameState(), game.getModifiersQuerying(), Filters.siteNumber(_siteNumber)).iterator().next();
|
||||
if (newSite != null) {
|
||||
|
||||
|
||||
PhysicalCard card = gameState.getSite(_siteNumber);
|
||||
|
||||
Zone zone = null;
|
||||
String controlled = null;
|
||||
List<PhysicalCard> stacked = null;
|
||||
|
||||
if (card != null) {
|
||||
controlled = card.getCardController();
|
||||
if (controlled != null)
|
||||
zone = card.getZone();
|
||||
stacked = new LinkedList<PhysicalCard>(gameState.getStackedCards(card));
|
||||
|
||||
if (gameState.getCurrentSiteNumber() == _siteNumber)
|
||||
gameState.stopAffecting(card);
|
||||
gameState.removeCardFromZone(card);
|
||||
gameState.addCardToZone(card, Zone.DECK);
|
||||
}
|
||||
|
||||
gameState.sendMessage(newSite.getOwner() + " plays " + GameUtils.getCardLink(newSite));
|
||||
gameState.addCardToZone(newSite, Zone.ADVENTURE_PATH);
|
||||
if (gameState.getCurrentSiteNumber() == _siteNumber)
|
||||
gameState.startAffecting(newSite, game.getModifiersEnvironment());
|
||||
|
||||
if (controlled != null) {
|
||||
gameState.takeControlOfCard(controlled, newSite, zone);
|
||||
for (PhysicalCard physicalCard : stacked)
|
||||
gameState.stackCard(physicalCard, newSite);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,57 @@
|
||||
package com.gempukku.lotro.cards.effects;
|
||||
|
||||
import com.gempukku.lotro.common.Zone;
|
||||
import com.gempukku.lotro.game.PhysicalCard;
|
||||
import com.gempukku.lotro.game.state.LotroGame;
|
||||
import com.gempukku.lotro.logic.GameUtils;
|
||||
import com.gempukku.lotro.logic.timing.AbstractEffect;
|
||||
import com.gempukku.lotro.logic.timing.EffectResult;
|
||||
|
||||
public class TakeControlOfASiteEffect extends AbstractEffect {
|
||||
private PhysicalCard _source;
|
||||
private String _playerId;
|
||||
|
||||
public TakeControlOfASiteEffect(PhysicalCard source, String playerId) {
|
||||
_source = source;
|
||||
_playerId = playerId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isPlayableInFull(LotroGame game) {
|
||||
return getFirstControllableSite(game) != null;
|
||||
}
|
||||
|
||||
private PhysicalCard getFirstControllableSite(LotroGame game) {
|
||||
int maxUnoccupiedSite = Integer.MAX_VALUE;
|
||||
for (String playerId : game.getGameState().getPlayerOrder().getAllPlayers())
|
||||
maxUnoccupiedSite = Math.min(maxUnoccupiedSite, game.getGameState().getPlayerPosition(playerId) - 1);
|
||||
|
||||
for (int i = 1; i <= maxUnoccupiedSite; i++) {
|
||||
final PhysicalCard site = game.getGameState().getSite(i);
|
||||
if (site.getCardController() == null)
|
||||
return site;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getText(LotroGame game) {
|
||||
return "Take control of a site";
|
||||
}
|
||||
|
||||
@Override
|
||||
public EffectResult.Type getType() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected FullEffectResult playEffectReturningResult(LotroGame game) {
|
||||
PhysicalCard site = getFirstControllableSite(game);
|
||||
if (site != null) {
|
||||
game.getGameState().takeControlOfCard(_playerId, site, Zone.SUPPORT);
|
||||
game.getGameState().sendMessage(_playerId + " took control of " + GameUtils.getCardLink(site));
|
||||
}
|
||||
return new FullEffectResult(null, false, false);
|
||||
}
|
||||
}
|
||||
@@ -3,6 +3,7 @@ package com.gempukku.lotro.cards.set4.dunland;
|
||||
import com.gempukku.lotro.cards.AbstractMinion;
|
||||
import com.gempukku.lotro.cards.PlayConditions;
|
||||
import com.gempukku.lotro.cards.effects.StackCardFromPlayEffect;
|
||||
import com.gempukku.lotro.common.CardType;
|
||||
import com.gempukku.lotro.common.Culture;
|
||||
import com.gempukku.lotro.common.Race;
|
||||
import com.gempukku.lotro.filters.Filters;
|
||||
@@ -53,7 +54,8 @@ public class Card4_011 extends AbstractMinion {
|
||||
|
||||
@Override
|
||||
public List<? extends Action> getPhaseActionsFromStacked(String playerId, LotroGame game, PhysicalCard self) {
|
||||
if (playerId.equals(self.getStackedOn().getSiteController())
|
||||
if (self.getStackedOn().getBlueprint().getCardType() == CardType.SITE
|
||||
&& playerId.equals(self.getStackedOn().getCardController())
|
||||
&& checkPlayRequirements(playerId, game, self, -2)) {
|
||||
return Collections.singletonList(getPlayCardAction(playerId, game, self, -2));
|
||||
}
|
||||
|
||||
@@ -0,0 +1,44 @@
|
||||
package com.gempukku.lotro.cards.set4.dunland;
|
||||
|
||||
import com.gempukku.lotro.cards.AbstractMinion;
|
||||
import com.gempukku.lotro.cards.PlayConditions;
|
||||
import com.gempukku.lotro.cards.effects.TakeControlOfASiteEffect;
|
||||
import com.gempukku.lotro.common.Culture;
|
||||
import com.gempukku.lotro.common.Race;
|
||||
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.OptionalTriggerAction;
|
||||
import com.gempukku.lotro.logic.timing.EffectResult;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Set: The Two Towers
|
||||
* Side: Shadow
|
||||
* Culture: Dunland
|
||||
* Twilight Cost: 2
|
||||
* Type: Minion • Man
|
||||
* Strength: 7
|
||||
* Vitality: 1
|
||||
* Site: 3
|
||||
* Game Text: Each time this minion wins a skirmish, you may spot another [DUNLAND] Man to take control of a site.
|
||||
*/
|
||||
public class Card4_014 extends AbstractMinion {
|
||||
public Card4_014() {
|
||||
super(2, 7, 1, 3, Race.MAN, Culture.DUNLAND, "Dunlending Ransacker");
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<OptionalTriggerAction> getOptionalAfterTriggers(String playerId, LotroGame game, EffectResult effectResult, PhysicalCard self) {
|
||||
if (PlayConditions.winsSkirmish(effectResult, self)
|
||||
&& Filters.canSpot(game.getGameState(), game.getModifiersQuerying(), Filters.not(Filters.sameCard(self)), Filters.culture(Culture.DUNLAND), Filters.race(Race.MAN))) {
|
||||
OptionalTriggerAction action = new OptionalTriggerAction(self);
|
||||
action.appendEffect(
|
||||
new TakeControlOfASiteEffect(self, playerId));
|
||||
return Collections.singletonList(action);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -363,7 +363,7 @@ public class Filters {
|
||||
return new Filter() {
|
||||
@Override
|
||||
public boolean accepts(GameState gameState, ModifiersQuerying modifiersQuerying, PhysicalCard physicalCard) {
|
||||
return physicalCard.getBlueprint().getCardType() == CardType.SITE && playerId.equals(physicalCard.getSiteController());
|
||||
return physicalCard.getBlueprint().getCardType() == CardType.SITE && playerId.equals(physicalCard.getCardController());
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@@ -9,7 +9,7 @@ public interface PhysicalCard {
|
||||
|
||||
public String getOwner();
|
||||
|
||||
public String getSiteController();
|
||||
public String getCardController();
|
||||
|
||||
public int getCardId();
|
||||
|
||||
|
||||
@@ -12,7 +12,7 @@ public class PhysicalCardImpl implements PhysicalCard {
|
||||
private int _cardId;
|
||||
private String _blueprintId;
|
||||
private String _owner;
|
||||
private String _siteController;
|
||||
private String _cardController;
|
||||
private Zone _zone;
|
||||
private LotroCardBlueprint _blueprint;
|
||||
|
||||
@@ -50,13 +50,13 @@ public class PhysicalCardImpl implements PhysicalCard {
|
||||
return _owner;
|
||||
}
|
||||
|
||||
public void setSiteController(String siteController) {
|
||||
_siteController = siteController;
|
||||
public void setCardController(String siteController) {
|
||||
_cardController = siteController;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSiteController() {
|
||||
return _siteController;
|
||||
public String getCardController() {
|
||||
return _cardController;
|
||||
}
|
||||
|
||||
public void startAffectingGame(ModifiersEnvironment modifiersEnvironment) {
|
||||
|
||||
@@ -217,6 +217,13 @@ public class GameState {
|
||||
listener.cardMoved(card);
|
||||
}
|
||||
|
||||
public void takeControlOfCard(String playerId, PhysicalCard card, Zone zone) {
|
||||
((PhysicalCardImpl) card).setCardController(playerId);
|
||||
((PhysicalCardImpl) card).setZone(zone);
|
||||
for (GameStateListener listener : getAllGameStateListeners())
|
||||
listener.cardMoved(card);
|
||||
}
|
||||
|
||||
public void attachCard(PhysicalCard card, PhysicalCard attachTo) {
|
||||
((PhysicalCardImpl) card).attachTo((PhysicalCardImpl) attachTo);
|
||||
addCardToZone(card, Zone.ATTACHED);
|
||||
@@ -438,6 +445,10 @@ public class GameState {
|
||||
listener.setPlayerPosition(playerId, i);
|
||||
}
|
||||
|
||||
public int getPlayerPosition(String playerId) {
|
||||
return _playerPosition.get(playerId);
|
||||
}
|
||||
|
||||
private int getTokenCount(PhysicalCard physicalCard, Token token) {
|
||||
Map<Token, Integer> tokens = _cardTokens.get(physicalCard);
|
||||
if (tokens == null)
|
||||
|
||||
@@ -24,6 +24,7 @@ public class GameEvent {
|
||||
private Type _type;
|
||||
private Zone _zone;
|
||||
private String _participantId;
|
||||
private String _controllerId;
|
||||
private List<String> _allParticipantIds;
|
||||
private Integer _index;
|
||||
private String _blueprintId;
|
||||
@@ -123,8 +124,19 @@ public class GameEvent {
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getControllerId() {
|
||||
return _controllerId;
|
||||
}
|
||||
|
||||
public GameEvent controllerId(String controllerId) {
|
||||
_controllerId = controllerId;
|
||||
return this;
|
||||
}
|
||||
|
||||
public GameEvent card(PhysicalCard physicalCard) {
|
||||
GameEvent gameEvent = cardId(physicalCard.getCardId()).blueprintId(physicalCard.getBlueprintId()).participantId(physicalCard.getOwner()).zone(physicalCard.getZone()).side(physicalCard.getBlueprint().getSide().name());
|
||||
if (physicalCard.getCardController() != null)
|
||||
gameEvent = gameEvent.controllerId(physicalCard.getCardController());
|
||||
PhysicalCard attachedTo = physicalCard.getAttachedTo();
|
||||
if (attachedTo != null)
|
||||
gameEvent = gameEvent.targetCardId(attachedTo.getCardId());
|
||||
|
||||
@@ -720,6 +720,8 @@ public class ServerResource {
|
||||
eventElem.setAttribute("cardId", gameEvent.getCardId().toString());
|
||||
if (gameEvent.getIndex() != null)
|
||||
eventElem.setAttribute("index", gameEvent.getIndex().toString());
|
||||
if (gameEvent.getControllerId() != null)
|
||||
eventElem.setAttribute("controllerId", gameEvent.getParticipantId());
|
||||
if (gameEvent.getParticipantId() != null)
|
||||
eventElem.setAttribute("participantId", gameEvent.getParticipantId());
|
||||
if (gameEvent.getAllParticipantIds() != null) {
|
||||
|
||||
Reference in New Issue
Block a user