"Gimli"
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
package com.gempukku.lotro.cards.modifiers;
|
||||
|
||||
import com.gempukku.lotro.cards.modifiers.evaluator.ConstantEvaluator;
|
||||
import com.gempukku.lotro.cards.modifiers.evaluator.Evaluator;
|
||||
import com.gempukku.lotro.filters.Filter;
|
||||
import com.gempukku.lotro.game.PhysicalCard;
|
||||
import com.gempukku.lotro.game.state.GameState;
|
||||
@@ -9,19 +11,32 @@ import com.gempukku.lotro.logic.modifiers.ModifierEffect;
|
||||
import com.gempukku.lotro.logic.modifiers.ModifiersQuerying;
|
||||
|
||||
public class StrengthModifier extends AbstractModifier {
|
||||
private int _modifier;
|
||||
private Evaluator _evaluator;
|
||||
|
||||
public StrengthModifier(PhysicalCard source, Filter affectFilter, int modifier) {
|
||||
this(source, affectFilter, null, modifier);
|
||||
}
|
||||
|
||||
public StrengthModifier(PhysicalCard source, Filter affectFilter, Condition condition, int modifier) {
|
||||
super(source, "Strength " + ((modifier < 0) ? modifier : ("+" + modifier)), affectFilter, condition, new ModifierEffect[]{ModifierEffect.STRENGTH_MODIFIER});
|
||||
_modifier = modifier;
|
||||
this(source, affectFilter, condition, new ConstantEvaluator(modifier));
|
||||
}
|
||||
|
||||
public StrengthModifier(PhysicalCard source, Filter affectFilter, Condition condition, Evaluator evaluator) {
|
||||
super(source, null, affectFilter, condition, new ModifierEffect[]{ModifierEffect.STRENGTH_MODIFIER});
|
||||
_evaluator = evaluator;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getText(GameState gameState, ModifiersQuerying modifiersQuerying) {
|
||||
final int value = _evaluator.evaluateExpression(gameState, modifiersQuerying);
|
||||
if (value >= 0)
|
||||
return "Strength +" + value;
|
||||
else
|
||||
return "Strength " + value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getStrength(GameState gameState, ModifiersQuerying modifiersQuerying, PhysicalCard physicalCard, int result) {
|
||||
return result + _modifier;
|
||||
return result + _evaluator.evaluateExpression(gameState, modifiersQuerying);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
package com.gempukku.lotro.cards.modifiers.evaluator;
|
||||
|
||||
import com.gempukku.lotro.game.state.GameState;
|
||||
import com.gempukku.lotro.logic.modifiers.ModifiersQuerying;
|
||||
|
||||
public class ConstantEvaluator implements Evaluator {
|
||||
private int _value;
|
||||
|
||||
public ConstantEvaluator(int value) {
|
||||
_value = value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int evaluateExpression(GameState gameState, ModifiersQuerying modifiersQuerying) {
|
||||
return _value;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
package com.gempukku.lotro.cards.modifiers.evaluator;
|
||||
|
||||
import com.gempukku.lotro.filters.Filter;
|
||||
import com.gempukku.lotro.filters.Filters;
|
||||
import com.gempukku.lotro.game.state.GameState;
|
||||
import com.gempukku.lotro.logic.modifiers.ModifiersQuerying;
|
||||
|
||||
public class CountSpottableEvaluator implements Evaluator {
|
||||
private Filter _filter;
|
||||
|
||||
public CountSpottableEvaluator(Filter filter) {
|
||||
_filter = filter;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int evaluateExpression(GameState gameState, ModifiersQuerying modifiersQuerying) {
|
||||
return Filters.countSpottable(gameState, modifiersQuerying, _filter);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
package com.gempukku.lotro.cards.modifiers.evaluator;
|
||||
|
||||
import com.gempukku.lotro.game.state.GameState;
|
||||
import com.gempukku.lotro.logic.modifiers.ModifiersQuerying;
|
||||
|
||||
public interface Evaluator {
|
||||
public int evaluateExpression(GameState gameState, ModifiersQuerying modifiersQuerying);
|
||||
}
|
||||
@@ -34,7 +34,7 @@ public class Card4_047 extends AbstractPermanent {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected List<? extends Action> getExtraPhaseActions(String playerId, LotroGame game, final PhysicalCard self) {
|
||||
protected List<? extends Action> getExtraPhaseActions(final String playerId, LotroGame game, final PhysicalCard self) {
|
||||
if (PlayConditions.canUseFPCardDuringPhase(game.getGameState(), Phase.SKIRMISH, self)
|
||||
&& PlayConditions.canExert(self, game.getGameState(), game.getModifiersQuerying(), Filters.race(Race.DWARF))
|
||||
&& Filters.filter(game.getGameState().getHand(playerId), game.getGameState(), game.getModifiersQuerying(), Filters.side(Side.FREE_PEOPLE)).size() > 0) {
|
||||
|
||||
@@ -0,0 +1,41 @@
|
||||
package com.gempukku.lotro.cards.set4.dwarven;
|
||||
|
||||
import com.gempukku.lotro.cards.AbstractCompanion;
|
||||
import com.gempukku.lotro.cards.modifiers.StrengthModifier;
|
||||
import com.gempukku.lotro.cards.modifiers.evaluator.CountSpottableEvaluator;
|
||||
import com.gempukku.lotro.common.Culture;
|
||||
import com.gempukku.lotro.common.Keyword;
|
||||
import com.gempukku.lotro.common.Race;
|
||||
import com.gempukku.lotro.common.Signet;
|
||||
import com.gempukku.lotro.filters.Filters;
|
||||
import com.gempukku.lotro.game.PhysicalCard;
|
||||
import com.gempukku.lotro.logic.modifiers.Modifier;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Set: The Two Towers
|
||||
* Side: Free
|
||||
* Culture: Dwarven
|
||||
* Twilight Cost: 2
|
||||
* Type: Companion • Dwarf
|
||||
* Strength: 6
|
||||
* Vitality: 3
|
||||
* Resistance: 6
|
||||
* Signet: Aragorn
|
||||
* Game Text: Damage +1. Gimli is strength +1 for each unbound Hobbit companion you can spot.
|
||||
*/
|
||||
public class Card4_048 extends AbstractCompanion {
|
||||
public Card4_048() {
|
||||
super(2, 6, 3, Culture.DWARVEN, Race.DWARF, Signet.ARAGORN, "Gimli", true);
|
||||
addKeyword(Keyword.DAMAGE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<? extends Modifier> getAlwaysOnModifiers(PhysicalCard self) {
|
||||
return Collections.singletonList(
|
||||
new StrengthModifier(self, Filters.sameCard(self), null,
|
||||
new CountSpottableEvaluator(Filters.and(Filters.unboundCompanion(), Filters.race(Race.HOBBIT)))));
|
||||
}
|
||||
}
|
||||
@@ -36,7 +36,7 @@ public abstract class AbstractModifier implements Modifier {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getText() {
|
||||
public String getText(GameState gameState, ModifiersQuerying modifiersQuerying) {
|
||||
return _text;
|
||||
}
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@ import java.util.Map;
|
||||
public interface Modifier {
|
||||
public PhysicalCard getSource();
|
||||
|
||||
public String getText();
|
||||
public String getText(GameState gameState, ModifiersQuerying modifiersQuerying);
|
||||
|
||||
public ModifierEffect[] getModifierEffects();
|
||||
|
||||
|
||||
@@ -73,9 +73,9 @@ public class LotroGameMediator {
|
||||
for (Modifier modifier : modifiers) {
|
||||
PhysicalCard source = modifier.getSource();
|
||||
if (source != null)
|
||||
sb.append("<br><b>" + source.getBlueprint().getName() + ":</b> " + modifier.getText());
|
||||
sb.append("<br><b>" + source.getBlueprint().getName() + ":</b> " + modifier.getText(_lotroGame.getGameState(), _lotroGame.getModifiersQuerying()));
|
||||
else
|
||||
sb.append("<br><b><i>System</i>:</b> " + modifier.getText());
|
||||
sb.append("<br><b><i>System</i>:</b> " + modifier.getText(_lotroGame.getGameState(), _lotroGame.getModifiersQuerying()));
|
||||
}
|
||||
if (modifiers.size() == 0)
|
||||
sb.append("<br><i>nothing</i>");
|
||||
|
||||
Reference in New Issue
Block a user