"Ring of Barahir"
This commit is contained in:
@@ -0,0 +1,66 @@
|
||||
package com.gempukku.lotro.cards.set6.gondor;
|
||||
|
||||
import com.gempukku.lotro.cards.AbstractAttachableFPPossession;
|
||||
import com.gempukku.lotro.common.*;
|
||||
import com.gempukku.lotro.filters.Filter;
|
||||
import com.gempukku.lotro.filters.Filters;
|
||||
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.actions.OptionalTriggerAction;
|
||||
import com.gempukku.lotro.logic.effects.ChooseAndHealCharactersEffect;
|
||||
import com.gempukku.lotro.logic.modifiers.ModifiersQuerying;
|
||||
import com.gempukku.lotro.logic.timing.EffectResult;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* Set: Ents of Fangorn
|
||||
* Side: Free
|
||||
* Culture: Gondor
|
||||
* Twilight Cost: 0
|
||||
* Type: Artifact • Ring
|
||||
* Game Text: Bearer must be Aragorn. At the start of each of your turns, you may spot a culture token to heal
|
||||
* a companion of that culture.
|
||||
*/
|
||||
public class Card6_055 extends AbstractAttachableFPPossession {
|
||||
public Card6_055() {
|
||||
super(0, 0, 0, Culture.GONDOR, CardType.ARTIFACT, PossessionClass.RING, "Ring of Barahir", true);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Filterable getValidTargetFilter(String playerId, LotroGame game, PhysicalCard self) {
|
||||
return Filters.name("Aragorn");
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<OptionalTriggerAction> getOptionalAfterTriggers(String playerId, LotroGame game, EffectResult effectResult, PhysicalCard self) {
|
||||
if (effectResult.getType() == EffectResult.Type.START_OF_TURN) {
|
||||
final Set<Culture> cultureTokens = new HashSet<Culture>();
|
||||
for (PhysicalCard physicalCard : Filters.filterActive(game.getGameState(), game.getModifiersQuerying(), Filters.hasAnyTokens(1))) {
|
||||
Map<Token, Integer> tokens = game.getGameState().getTokens(physicalCard);
|
||||
for (Map.Entry<Token, Integer> tokenIntegerEntry : tokens.entrySet()) {
|
||||
if (tokenIntegerEntry.getValue() > 0) {
|
||||
Culture culture = tokenIntegerEntry.getKey().getCulture();
|
||||
if (culture != null)
|
||||
cultureTokens.add(culture);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (cultureTokens.size() > 0) {
|
||||
OptionalTriggerAction action = new OptionalTriggerAction(self);
|
||||
|
||||
action.appendEffect(
|
||||
new ChooseAndHealCharactersEffect(action, playerId, CardType.COMPANION,
|
||||
new Filter() {
|
||||
@Override
|
||||
public boolean accepts(GameState gameState, ModifiersQuerying modifiersQuerying, PhysicalCard physicalCard) {
|
||||
return cultureTokens.contains(physicalCard.getBlueprint().getCulture());
|
||||
}
|
||||
}));
|
||||
return Collections.singletonList(action);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -3,6 +3,20 @@ package com.gempukku.lotro.common;
|
||||
public enum Token {
|
||||
BURDEN, WOUND,
|
||||
|
||||
DUNLAND, DWARVEN, ELVEN, GANDALF,
|
||||
GONDOR, ISENGARD, RAIDER, ROHAN, SHIRE
|
||||
DUNLAND(Culture.DUNLAND), DWARVEN(Culture.DWARVEN), ELVEN(Culture.ELVEN), GANDALF(Culture.GANDALF),
|
||||
GONDOR(Culture.GONDOR), ISENGARD(Culture.ISENGARD), RAIDER(Culture.RAIDER), ROHAN(Culture.ROHAN), SHIRE(Culture.SHIRE);
|
||||
|
||||
private Culture _culture;
|
||||
|
||||
private Token() {
|
||||
this(null);
|
||||
}
|
||||
|
||||
private Token(Culture culture) {
|
||||
_culture = culture;
|
||||
}
|
||||
|
||||
public Culture getCulture() {
|
||||
return _culture;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -71,8 +71,9 @@ public class Filters {
|
||||
return new Filter() {
|
||||
@Override
|
||||
public boolean accepts(GameState gameState, ModifiersQuerying modifiersQuerying, PhysicalCard physicalCard) {
|
||||
for (Token token : Token.values()) {
|
||||
if (gameState.getTokenCount(physicalCard, token) >= count)
|
||||
Map<Token, Integer> tokens = gameState.getTokens(physicalCard);
|
||||
for (Integer integer : tokens.values()) {
|
||||
if (integer >= count)
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
||||
@@ -596,6 +596,13 @@ public class GameState {
|
||||
return _playerPosition.get(playerId);
|
||||
}
|
||||
|
||||
public Map<Token, Integer> getTokens(PhysicalCard card) {
|
||||
Map<Token, Integer> map = _cardTokens.get(card);
|
||||
if (map == null)
|
||||
return Collections.emptyMap();
|
||||
return Collections.unmodifiableMap(map);
|
||||
}
|
||||
|
||||
public int getTokenCount(PhysicalCard physicalCard, Token token) {
|
||||
Map<Token, Integer> tokens = _cardTokens.get(physicalCard);
|
||||
if (tokens == null)
|
||||
|
||||
Reference in New Issue
Block a user