Fixed effects that reduce cost of playing a card on a card.

This commit is contained in:
marcin.sciesinski
2019-09-18 18:12:45 -07:00
parent d8ea5fc52b
commit e6ad0863fd
10 changed files with 114 additions and 82 deletions

View File

@@ -40,7 +40,7 @@ public class Card13_124 extends AbstractCompanion {
public List<? extends Modifier> getInPlayModifiers(LotroGame game, final PhysicalCard self) {
return Collections.singletonList(new AbstractModifier(self, "The cost of each possession you play on Eowyn during the fellowship phase is twilight cost -1", CardType.POSSESSION, new PhaseCondition(Phase.FELLOWSHIP), ModifierEffect.TWILIGHT_COST_MODIFIER) {
@Override
public int getPlayOnTwilightCostModifier(LotroGame game, PhysicalCard physicalCard, PhysicalCard target) {
public int getTwilightCostModifier(LotroGame game, PhysicalCard physicalCard, PhysicalCard target, boolean ignoreRoamingPenalty) {
if (target == self)
return -1;
return 0;

View File

@@ -36,8 +36,8 @@ public class Card2_023 extends AbstractPermanent {
CardType.POSSESSION,
CardType.ARTIFACT), ModifierEffect.TWILIGHT_COST_MODIFIER) {
@Override
public int getPlayOnTwilightCostModifier(LotroGame game, PhysicalCard physicalCard, PhysicalCard target) {
if (physicalCard.getBlueprint().getCardType() == CardType.POSSESSION || physicalCard.getBlueprint().getCardType() == CardType.ARTIFACT) {
public int getTwilightCostModifier(LotroGame game, PhysicalCard physicalCard, PhysicalCard target, boolean ignoreRoamingPenalty) {
if (target != null && physicalCard.getBlueprint().getCardType() == CardType.POSSESSION || physicalCard.getBlueprint().getCardType() == CardType.ARTIFACT) {
CardType cardType = target.getBlueprint().getCardType();
if (target.getBlueprint().getTitle().equals("Gandalf") || (cardType == CardType.COMPANION && target.getBlueprint().getSignet() == Signet.GANDALF))
return -1;

View File

@@ -36,7 +36,7 @@ public class Card2_102 extends AbstractCompanion {
return Collections.singletonList(
new AbstractModifier(self, "The cost of each artifact, possession, and [SHIRE] tale played on Frodo is -1.", Filters.or(CardType.ARTIFACT, CardType.POSSESSION, Filters.and(Culture.SHIRE, Keyword.TALE)), ModifierEffect.TWILIGHT_COST_MODIFIER) {
@Override
public int getPlayOnTwilightCostModifier(LotroGame game, PhysicalCard physicalCard, PhysicalCard target) {
public int getTwilightCostModifier(LotroGame game, PhysicalCard physicalCard, PhysicalCard target, boolean ignoreRoamingPenalty) {
if (target == self)
return -1;
return 0;

View File

@@ -40,7 +40,7 @@ public class Card4_080 extends AbstractCompanion {
return Collections.singletonList(
new AbstractModifier(self, "The twilight cost of each ranged weapon played on Ordulus is -1.", PossessionClass.RANGED_WEAPON, ModifierEffect.TWILIGHT_COST_MODIFIER) {
@Override
public int getPlayOnTwilightCostModifier(LotroGame game, PhysicalCard physicalCard, PhysicalCard target) {
public int getTwilightCostModifier(LotroGame game, PhysicalCard physicalCard, PhysicalCard target, boolean ignoreRoamingPenalty) {
if (target == self)
return -1;
return 0;

View File

@@ -34,8 +34,8 @@ public class ModifyPlayOnCost implements ModifierSourceProducer {
return new AbstractModifier(actionContext.getSource(), "Cost to play on is modifier", filterable,
requirementCondition, ModifierEffect.TWILIGHT_COST_MODIFIER) {
@Override
public int getPlayOnTwilightCostModifier(LotroGame game, PhysicalCard physicalCard, PhysicalCard target) {
if (Filters.and(onFilterable).accepts(game, target))
public int getTwilightCostModifier(LotroGame game, PhysicalCard physicalCard, PhysicalCard target, boolean ignoreRoamingPenalty) {
if (target != null && Filters.and(onFilterable).accepts(game, target))
return evaluator.evaluateExpression(game, null);
return 0;
}

View File

@@ -129,12 +129,7 @@ public abstract class AbstractModifier implements Modifier {
}
@Override
public int getTwilightCostModifier(LotroGame game, PhysicalCard physicalCard, boolean ignoreRoamingPenalty) {
return 0;
}
@Override
public int getPlayOnTwilightCostModifier(LotroGame game, PhysicalCard physicalCard, PhysicalCard target) {
public int getTwilightCostModifier(LotroGame game, PhysicalCard physicalCard, PhysicalCard target, boolean ignoreRoamingPenalty) {
return 0;
}

View File

@@ -13,143 +13,141 @@ import java.util.Map;
import java.util.Set;
public interface Modifier {
public PhysicalCard getSource();
PhysicalCard getSource();
public String getText(LotroGame game, PhysicalCard self);
String getText(LotroGame game, PhysicalCard self);
public ModifierEffect getModifierEffect();
ModifierEffect getModifierEffect();
public boolean isNonCardTextModifier();
boolean isNonCardTextModifier();
public Condition getCondition();
Condition getCondition();
boolean isExtraPossessionClass(LotroGame game, PhysicalCard physicalCard, PhysicalCard attachedTo);
public boolean affectsCard(LotroGame game, PhysicalCard physicalCard);
boolean affectsCard(LotroGame game, PhysicalCard physicalCard);
public boolean hasRemovedText(LotroGame game, PhysicalCard physicalCard);
boolean hasRemovedText(LotroGame game, PhysicalCard physicalCard);
public boolean hasKeyword(LotroGame game, PhysicalCard physicalCard, Keyword keyword);
boolean hasKeyword(LotroGame game, PhysicalCard physicalCard, Keyword keyword);
public boolean hasSignet(LotroGame game, PhysicalCard physicalCard, Signet signet);
boolean hasSignet(LotroGame game, PhysicalCard physicalCard, Signet signet);
public int getKeywordCountModifier(LotroGame game, PhysicalCard physicalCard, Keyword keyword);
int getKeywordCountModifier(LotroGame game, PhysicalCard physicalCard, Keyword keyword);
public boolean appliesKeywordModifier(LotroGame game, PhysicalCard modifierSource, Keyword keyword);
boolean appliesKeywordModifier(LotroGame game, PhysicalCard modifierSource, Keyword keyword);
public boolean isKeywordRemoved(LotroGame game, PhysicalCard physicalCard, Keyword keyword);
boolean isKeywordRemoved(LotroGame game, PhysicalCard physicalCard, Keyword keyword);
public int getStrengthModifier(LotroGame game, PhysicalCard physicalCard);
int getStrengthModifier(LotroGame game, PhysicalCard physicalCard);
public boolean appliesStrengthBonusModifier(LotroGame game, PhysicalCard modifierSource, PhysicalCard modifierTaget);
boolean appliesStrengthBonusModifier(LotroGame game, PhysicalCard modifierSource, PhysicalCard modifierTaget);
public int getVitalityModifier(LotroGame game, PhysicalCard physicalCard);
int getVitalityModifier(LotroGame game, PhysicalCard physicalCard);
public int getResistanceModifier(LotroGame game, PhysicalCard physicalCard);
int getResistanceModifier(LotroGame game, PhysicalCard physicalCard);
public int getMinionSiteNumberModifier(LotroGame game, PhysicalCard physicalCard);
int getMinionSiteNumberModifier(LotroGame game, PhysicalCard physicalCard);
public boolean isAdditionalCardTypeModifier(LotroGame game, PhysicalCard physicalCard, CardType cardType);
boolean isAdditionalCardTypeModifier(LotroGame game, PhysicalCard physicalCard, CardType cardType);
public int getTwilightCostModifier(LotroGame game, PhysicalCard physicalCard, boolean ignoreRoamingPenalty);
int getTwilightCostModifier(LotroGame game, PhysicalCard physicalCard, PhysicalCard target, boolean ignoreRoamingPenalty);
public int getPlayOnTwilightCostModifier(LotroGame game, PhysicalCard physicalCard, PhysicalCard target);
int getRoamingPenaltyModifier(LotroGame game, PhysicalCard physicalCard);
public int getRoamingPenaltyModifier(LotroGame game, PhysicalCard physicalCard);
int getOverwhelmMultiplier(LotroGame game, PhysicalCard physicalCard);
public int getOverwhelmMultiplier(LotroGame game, PhysicalCard physicalCard);
boolean canTakeWounds(LotroGame game, Collection<PhysicalCard> woundSources, PhysicalCard physicalCard, int woundsAlreadyTakenInPhase, int woundsToTake);
public boolean canTakeWounds(LotroGame game, Collection<PhysicalCard> woundSources, PhysicalCard physicalCard, int woundsAlreadyTakenInPhase, int woundsToTake);
boolean canTakeWoundsFromLosingSkirmish(LotroGame game, PhysicalCard physicalCard, Set<PhysicalCard> winners);
public boolean canTakeWoundsFromLosingSkirmish(LotroGame game, PhysicalCard physicalCard, Set<PhysicalCard> winners);
boolean canTakeArcheryWound(LotroGame game, PhysicalCard physicalCard);
public boolean canTakeArcheryWound(LotroGame game, PhysicalCard physicalCard);
boolean canBeExerted(LotroGame game, PhysicalCard exertionSource, PhysicalCard exertedCard);
public boolean canBeExerted(LotroGame game, PhysicalCard exertionSource, PhysicalCard exertedCard);
boolean isAllyParticipateInArcheryFire(LotroGame game, PhysicalCard card);
public boolean isAllyParticipateInArcheryFire(LotroGame game, PhysicalCard card);
boolean isAllyParticipateInSkirmishes(LotroGame game, Side sidePlayer, PhysicalCard card);
public boolean isAllyParticipateInSkirmishes(LotroGame game, Side sidePlayer, PhysicalCard card);
boolean isUnhastyCompanionAllowedToParticipateInSkirmishes(LotroGame game, PhysicalCard card);
public boolean isUnhastyCompanionAllowedToParticipateInSkirmishes(LotroGame game, PhysicalCard card);
boolean isAllyPreventedFromParticipatingInArcheryFire(LotroGame game, PhysicalCard card);
public boolean isAllyPreventedFromParticipatingInArcheryFire(LotroGame game, PhysicalCard card);
boolean isAllyPreventedFromParticipatingInSkirmishes(LotroGame game, Side sidePlayer, PhysicalCard card);
public boolean isAllyPreventedFromParticipatingInSkirmishes(LotroGame game, Side sidePlayer, PhysicalCard card);
int getArcheryTotalModifier(LotroGame game, Side side);
public int getArcheryTotalModifier(LotroGame game, Side side);
public int getMoveLimitModifier(LotroGame game);
int getMoveLimitModifier(LotroGame game);
boolean addsTwilightForCompanionMove(LotroGame game, PhysicalCard companion);
public boolean addsToArcheryTotal(LotroGame game, PhysicalCard card);
boolean addsToArcheryTotal(LotroGame game, PhysicalCard card);
public boolean canPlayAction(LotroGame game, String performingPlayer, Action action);
boolean canPlayAction(LotroGame game, String performingPlayer, Action action);
public List<? extends Action> getExtraPhaseAction(LotroGame game, PhysicalCard card);
List<? extends Action> getExtraPhaseAction(LotroGame game, PhysicalCard card);
public List<? extends Action> getExtraPhaseActionFromStacked(LotroGame game, PhysicalCard card);
List<? extends Action> getExtraPhaseActionFromStacked(LotroGame game, PhysicalCard card);
public boolean canPayExtraCostsToPlay(LotroGame game, PhysicalCard card);
boolean canPayExtraCostsToPlay(LotroGame game, PhysicalCard card);
public void appendExtraCosts(LotroGame game, CostToEffectAction action, PhysicalCard card);
void appendExtraCosts(LotroGame game, CostToEffectAction action, PhysicalCard card);
public boolean canHavePlayedOn(LotroGame game, PhysicalCard playedCard, PhysicalCard target);
boolean canHavePlayedOn(LotroGame game, PhysicalCard playedCard, PhysicalCard target);
public boolean canHaveTransferredOn(LotroGame game, PhysicalCard playedCard, PhysicalCard target);
boolean canHaveTransferredOn(LotroGame game, PhysicalCard playedCard, PhysicalCard target);
public boolean canBeTransferred(LotroGame game, PhysicalCard attachment);
boolean canBeTransferred(LotroGame game, PhysicalCard attachment);
public boolean shouldSkipPhase(LotroGame game, Phase phase, String playerId);
boolean shouldSkipPhase(LotroGame game, Phase phase, String playerId);
public boolean isValidAssignments(LotroGame game, Side Side, PhysicalCard companion, Set<PhysicalCard> minions);
boolean isValidAssignments(LotroGame game, Side Side, PhysicalCard companion, Set<PhysicalCard> minions);
public boolean isValidAssignments(LotroGame game, Side Side, Map<PhysicalCard, Set<PhysicalCard>> assignments);
boolean isValidAssignments(LotroGame game, Side Side, Map<PhysicalCard, Set<PhysicalCard>> assignments);
public boolean isPreventedFromBeingAssignedToSkirmish(LotroGame game, Side sidePlayer, PhysicalCard card);
boolean isPreventedFromBeingAssignedToSkirmish(LotroGame game, Side sidePlayer, PhysicalCard card);
public boolean canBeDiscardedFromPlay(LotroGame game, String performingPlayer, PhysicalCard card, PhysicalCard source);
boolean canBeDiscardedFromPlay(LotroGame game, String performingPlayer, PhysicalCard card, PhysicalCard source);
public boolean canBeLiberated(LotroGame game, String performingPlayer, PhysicalCard card, PhysicalCard source);
boolean canBeLiberated(LotroGame game, String performingPlayer, PhysicalCard card, PhysicalCard source);
public boolean canBeReturnedToHand(LotroGame game, PhysicalCard card, PhysicalCard source);
boolean canBeReturnedToHand(LotroGame game, PhysicalCard card, PhysicalCard source);
public boolean canBeHealed(LotroGame game, PhysicalCard card);
boolean canBeHealed(LotroGame game, PhysicalCard card);
public boolean canAddBurden(LotroGame game, String performingPlayer, PhysicalCard source);
boolean canAddBurden(LotroGame game, String performingPlayer, PhysicalCard source);
public boolean canRemoveBurden(LotroGame game, PhysicalCard source);
boolean canRemoveBurden(LotroGame game, PhysicalCard source);
public boolean canRemoveThreat(LotroGame game, PhysicalCard source);
boolean canRemoveThreat(LotroGame game, PhysicalCard source);
public boolean canLookOrRevealCardsInHand(LotroGame game, String revealingPlayerId, String actingPlayerId);
boolean canLookOrRevealCardsInHand(LotroGame game, String revealingPlayerId, String actingPlayerId);
public boolean canDiscardCardsFromHand(LotroGame game, String playerId, PhysicalCard source);
boolean canDiscardCardsFromHand(LotroGame game, String playerId, PhysicalCard source);
public boolean canDiscardCardsFromTopOfDeck(LotroGame game, String playerId, PhysicalCard source);
boolean canDiscardCardsFromTopOfDeck(LotroGame game, String playerId, PhysicalCard source);
public int getSpotCountModifier(LotroGame game, Filterable filter);
int getSpotCountModifier(LotroGame game, Filterable filter);
public boolean hasFlagActive(LotroGame game, ModifierFlag modifierFlag);
boolean hasFlagActive(LotroGame game, ModifierFlag modifierFlag);
public boolean isSiteReplaceable(LotroGame game, String playerId);
boolean isSiteReplaceable(LotroGame game, String playerId);
public boolean canPlaySite(LotroGame game, String playerId);
boolean canPlaySite(LotroGame game, String playerId);
public boolean shadowCanHaveInitiative(LotroGame game);
boolean shadowCanHaveInitiative(LotroGame game);
public Side hasInitiative(LotroGame game);
Side hasInitiative(LotroGame game);
public int getInitiativeHandSizeModifier(LotroGame game);
int getInitiativeHandSizeModifier(LotroGame game);
public boolean lostAllKeywords(LotroGame game, PhysicalCard card);
boolean lostAllKeywords(LotroGame game, PhysicalCard card);
Evaluator getFpSkirmishStrengthOverrideEvaluator(LotroGame game, PhysicalCard fpCharacter);
public boolean canSpotCulture(LotroGame game, Culture culture, String playerId);
boolean canSpotCulture(LotroGame game, Culture culture, String playerId);
public int getFPCulturesSpotCountModifier(LotroGame game, String playerId);
int getFPCulturesSpotCountModifier(LotroGame game, String playerId);
int getSanctuaryHealModifier(LotroGame game);

View File

@@ -473,7 +473,7 @@ public class ModifiersLogic implements ModifiersEnvironment, ModifiersQuerying {
int result = physicalCard.getBlueprint().getTwilightCost() + twilightCostModifier;
result += physicalCard.getBlueprint().getTwilightCostModifier(game, physicalCard, target);
for (Modifier modifier : getModifiersAffectingCard(game, ModifierEffect.TWILIGHT_COST_MODIFIER, physicalCard)) {
result += modifier.getTwilightCostModifier(game, physicalCard, ignoreRoamingPenalty);
result += modifier.getTwilightCostModifier(game, physicalCard, target, ignoreRoamingPenalty);
}
result = Math.max(0, result);

View File

@@ -32,7 +32,7 @@ public class TwilightCostModifier extends AbstractModifier {
}
@Override
public int getTwilightCostModifier(LotroGame game, PhysicalCard physicalCard, boolean ignoreRoamingPenalty) {
public int getTwilightCostModifier(LotroGame game, PhysicalCard physicalCard, PhysicalCard target, boolean ignoreRoamingPenalty) {
return _evaluator.evaluateExpression(game, physicalCard);
}
}

View File

@@ -0,0 +1,39 @@
package com.gempukku.lotro.at;
import com.gempukku.lotro.common.Zone;
import com.gempukku.lotro.game.CardNotFoundException;
import com.gempukku.lotro.game.PhysicalCardImpl;
import com.gempukku.lotro.logic.decisions.DecisionResultInvalidException;
import com.gempukku.lotro.logic.vo.LotroDeck;
import org.junit.Test;
import java.util.HashMap;
import java.util.Map;
import static org.junit.Assert.assertEquals;
public class CostAtTest extends AbstractAtTest {
@Test
public void playOnCostReduction() throws DecisionResultInvalidException, CardNotFoundException {
Map<String, LotroDeck> decks = new HashMap<String, LotroDeck>();
LotroDeck deck = createSimplestDeck();
// Frodo, Reluctant Adventurer
deck.setRingBearer("2_102");
decks.put(P1, deck);
addPlayerDeck(P2, decks, null);
initializeGameWithDecks(decks);
PhysicalCardImpl hobbitSword = createCard(P1, "1_299");
_game.getGameState().addCardToZone(_game, hobbitSword, Zone.HAND);
skipMulligans();
// Play Hobbit Sword (on Frodo) - should be free
final int twilightPool = _game.getGameState().getTwilightPool();
playerDecided(P1, "0");
assertEquals(twilightPool, _game.getGameState().getTwilightPool());
}
}