Sites can now be prevented from being liberated (fixed some issues).

This commit is contained in:
marcins78@gmail.com
2013-01-10 20:17:36 +00:00
parent 8adab86adb
commit 624fa236c3
5 changed files with 31 additions and 9 deletions

View File

@@ -38,14 +38,36 @@ public class PlayConditions {
return true;
}
public static boolean canLiberateASite(LotroGame game) {
return Filters.countActive(game.getGameState(), game.getModifiersQuerying(), Filters.siteControlledByShadowPlayer(game.getGameState().getCurrentPlayerId())) > 0;
public static boolean canLiberateASite(LotroGame game, String performingPlayer, PhysicalCard source) {
return canLiberateASite(game, performingPlayer, source, null);
}
public static boolean canLiberateASite(LotroGame game, String playerId) {
return Filters.countActive(game.getGameState(), game.getModifiersQuerying(), Filters.siteControlled(playerId)) > 0;
public static boolean canLiberateASite(LotroGame game, String performingPlayer, PhysicalCard source, String controlledByPlayerId) {
PhysicalCard siteToLiberate = getSiteToLiberate(game, controlledByPlayerId);
return siteToLiberate != null && game.getModifiersQuerying().canBeLiberated(game.getGameState(), performingPlayer, siteToLiberate, source);
}
private static PhysicalCard getSiteToLiberate(LotroGame game, String controlledByPlayerId) {
int maxUnoccupiedSite = Integer.MAX_VALUE;
for (String playerId : game.getGameState().getPlayerOrder().getAllPlayers())
maxUnoccupiedSite = Math.min(maxUnoccupiedSite, game.getGameState().getPlayerPosition(playerId) - 1);
for (int i = maxUnoccupiedSite; i >= 1; i--) {
PhysicalCard site = game.getGameState().getSite(i);
if (controlledByPlayerId == null) {
if (site != null && site.getCardController() != null
&& !site.getCardController().equals(game.getGameState().getCurrentPlayerId()))
return site;
} else {
if (site != null && site.getCardController() != null && site.getCardController().equals(controlledByPlayerId))
return site;
}
}
return null;
}
public static boolean canDiscardFromHand(LotroGame game, String playerId, int count, Filterable... cardFilter) {
return hasCardInHand(game, playerId, count, cardFilter);
}

View File

@@ -1,7 +1,7 @@
package com.gempukku.lotro.cards.effects;
import com.gempukku.lotro.cards.PlayConditions;
import com.gempukku.lotro.common.Zone;
import com.gempukku.lotro.filters.Filters;
import com.gempukku.lotro.game.PhysicalCard;
import com.gempukku.lotro.game.state.LotroGame;
import com.gempukku.lotro.logic.timing.AbstractEffect;
@@ -27,7 +27,7 @@ public class LiberateASiteEffect extends AbstractEffect {
@Override
public boolean isPlayableInFull(LotroGame game) {
return Filters.countActive(game.getGameState(), game.getModifiersQuerying(), Filters.siteControlledByShadowPlayer(game.getGameState().getCurrentPlayerId())) > 0;
return PlayConditions.canLiberateASite(game, _source.getOwner(), _source, _playerId);
}
@Override

View File

@@ -37,7 +37,7 @@ public class Card17_125 extends AbstractMinion {
@Override
public List<OptionalTriggerAction> getOptionalAfterTriggers(String playerId, final LotroGame game, EffectResult effectResult, final PhysicalCard self) {
if (TriggerConditions.played(game, effectResult, self)
&& PlayConditions.canLiberateASite(game)) {
&& PlayConditions.canLiberateASite(game, playerId, self)) {
final OptionalTriggerAction action = new OptionalTriggerAction(self);
action.appendCost(
new LiberateASiteEffect(self) {

View File

@@ -49,7 +49,7 @@ public class Card17_138 extends AbstractPermanent {
@Override
protected List<? extends Action> getExtraPhaseActions(String playerId, LotroGame game, final PhysicalCard self) {
if (PlayConditions.canUseShadowCardDuringPhase(game, Phase.SKIRMISH, self, 0)
&& PlayConditions.canLiberateASite(game)) {
&& PlayConditions.canLiberateASite(game, playerId, self)) {
final ActivateCardAction action = new ActivateCardAction(self);
action.appendCost(
new LiberateASiteEffect(self));

View File

@@ -41,7 +41,7 @@ public class Card18_075 extends AbstractMinion {
@Override
protected List<? extends Action> getExtraPhaseActions(final String playerId, LotroGame game, final PhysicalCard self) {
if (PlayConditions.canUseShadowCardDuringPhase(game, Phase.MANEUVER, self, 0)
&& PlayConditions.canLiberateASite(game, playerId)) {
&& PlayConditions.canLiberateASite(game, playerId, self, playerId)) {
ActivateCardAction action = new ActivateCardAction(self);
action.appendCost(
new LiberateASiteEffect(self, playerId));