Fixing how possession class uniquness on character is checked.

This commit is contained in:
marcins78@gmail.com
2011-09-09 15:33:13 +00:00
parent 0246077793
commit a9628b6f85
31 changed files with 63 additions and 32 deletions

View File

@@ -5,7 +5,9 @@ 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.modifiers.ModifiersQuerying;
import com.gempukku.lotro.logic.timing.Action;
import java.util.Collections;
@@ -29,6 +31,35 @@ public abstract class AbstractAttachable extends AbstractLotroCardBlueprint {
addKeyword(_possessionClass);
}
public Keyword getPossessionClass() {
return _possessionClass;
}
public boolean isExtraPossessionClass() {
return false;
}
protected Filter getFullValidTargetFilter(String playerId, final LotroGame game, PhysicalCard self) {
return Filters.and(getValidTargetFilter(playerId, game, self),
new Filter() {
@Override
public boolean accepts(GameState gameState, ModifiersQuerying modifiersQuerying, PhysicalCard physicalCard) {
Keyword possessionClass = getPossessionClass();
if (possessionClass != null) {
boolean extraPossessionClass = isExtraPossessionClass();
List<PhysicalCard> attachedCards = game.getGameState().getAttachedCards(physicalCard);
List<PhysicalCard> matchingClassPossessions = Filters.filter(attachedCards, gameState, modifiersQuerying, Filters.type(CardType.POSSESSION), Filters.keyword(possessionClass));
if (matchingClassPossessions.size() > 1)
return false;
if (!extraPossessionClass && matchingClassPossessions.size() == 1 &&
!((AbstractAttachable) matchingClassPossessions.get(0)).isExtraPossessionClass())
return false;
}
return true;
}
});
}
protected abstract Filter getValidTargetFilter(String playerId, LotroGame game, PhysicalCard self);
@Override
@@ -39,7 +70,7 @@ public abstract class AbstractAttachable extends AbstractLotroCardBlueprint {
public boolean checkPlayRequirements(String playerId, LotroGame game, PhysicalCard self, Filter additionalAttachmentFilter, int twilightModifier) {
return (self.getBlueprint().getSide() != Side.SHADOW || PlayConditions.canPayForShadowCard(game, self, twilightModifier))
&& PlayConditions.checkUniqueness(game.getGameState(), game.getModifiersQuerying(), self)
&& Filters.canSpot(game.getGameState(), game.getModifiersQuerying(), getValidTargetFilter(playerId, game, self), additionalAttachmentFilter);
&& Filters.canSpot(game.getGameState(), game.getModifiersQuerying(), getFullValidTargetFilter(playerId, game, self), additionalAttachmentFilter);
}
@Override
@@ -65,7 +96,7 @@ public abstract class AbstractAttachable extends AbstractLotroCardBlueprint {
}
public Action getPlayCardAction(String playerId, LotroGame game, PhysicalCard self, Filter additionalAttachmentFilter, int twilightModifier) {
return new AttachPermanentAction(game, self, Filters.and(getValidTargetFilter(playerId, game, self), additionalAttachmentFilter), getAttachCostModifiers(playerId, game, self));
return new AttachPermanentAction(game, self, Filters.and(getFullValidTargetFilter(playerId, game, self), additionalAttachmentFilter), getAttachCostModifiers(playerId, game, self));
}
protected List<? extends Action> getExtraPhaseActions(String playerId, LotroGame game, PhysicalCard self) {

View File

@@ -54,7 +54,7 @@ public abstract class AbstractAttachableFPPossession extends AbstractAttachable
@Override
public final List<? extends Action> getPhaseActions(String playerId, LotroGame game, PhysicalCard self) {
List<Action> actions = new LinkedList<Action>(super.getPhaseActions(playerId, game, self));
appendTransferPossessionAction(actions, game, self, getValidTargetFilter(playerId, game, self));
appendTransferPossessionAction(actions, game, self, getFullValidTargetFilter(playerId, game, self));
return actions;
}
}

View File

@@ -25,7 +25,7 @@ public class Card1_008 extends AbstractAttachableFPPossession {
@Override
protected Filter getValidTargetFilter(String playerId, LotroGame game, PhysicalCard self) {
return Filters.and(Filters.keyword(Keyword.DWARF), Filters.not(Filters.hasAttached(Filters.keyword(Keyword.ARMOR))));
return Filters.keyword(Keyword.DWARF);
}
@Override

View File

@@ -38,7 +38,7 @@ public class Card1_009 extends AbstractAttachableFPPossession {
@Override
protected Filter getValidTargetFilter(String playerId, LotroGame game, PhysicalCard self) {
return Filters.and(Filters.keyword(Keyword.DWARF), Filters.not(Filters.hasAttached(Filters.keyword(Keyword.HAND_WEAPON))));
return Filters.keyword(Keyword.DWARF);
}
@Override

View File

@@ -38,7 +38,7 @@ public class Card1_014 extends AbstractAttachableFPPossession {
@Override
protected Filter getValidTargetFilter(String playerId, LotroGame game, PhysicalCard self) {
return Filters.and(Filters.name("Gimli"), Filters.not(Filters.hasAttached(Filters.keyword(Keyword.HAND_WEAPON))));
return Filters.name("Gimli");
}
@Override

View File

@@ -35,7 +35,7 @@ public class Card1_015 extends AbstractAttachableFPPossession {
@Override
protected Filter getValidTargetFilter(String playerId, LotroGame game, PhysicalCard self) {
return Filters.and(Filters.name("Gimli"), Filters.not(Filters.hasAttached(Filters.keyword(Keyword.HELM))));
return Filters.name("Gimli");
}
@Override

View File

@@ -39,7 +39,7 @@ public class Card1_031 extends AbstractAttachableFPPossession {
@Override
protected Filter getValidTargetFilter(String playerId, LotroGame game, PhysicalCard self) {
return Filters.and(Filters.keyword(Keyword.ELF), Filters.not(Filters.hasAttached(Filters.keyword(Keyword.MOUNT))));
return Filters.keyword(Keyword.ELF);
}
@Override

View File

@@ -36,7 +36,7 @@ public class Card1_033 extends AbstractAttachableFPPossession {
@Override
protected Filter getValidTargetFilter(String playerId, LotroGame game, PhysicalCard self) {
return Filters.and(Filters.name("Legolas"), Filters.not(Filters.hasAttached(Filters.keyword(Keyword.RANGED_WEAPON))));
return Filters.name("Legolas");
}
@Override

View File

@@ -25,7 +25,7 @@ public class Card1_041 extends AbstractAttachableFPPossession {
@Override
protected Filter getValidTargetFilter(String playerId, LotroGame game, PhysicalCard self) {
return Filters.and(Filters.keyword(Keyword.ELF), Filters.not(Filters.hasAttached(Filters.keyword(Keyword.RANGED_WEAPON))));
return Filters.keyword(Keyword.ELF);
}
@Override

View File

@@ -27,7 +27,7 @@ public class Card1_042 extends AbstractAttachableFPPossession {
@Override
protected Filter getValidTargetFilter(String playerId, LotroGame game, PhysicalCard self) {
return Filters.and(Filters.type(CardType.COMPANION), Filters.not(Filters.hasAttached(Filters.keyword(Keyword.CLOAK))));
return Filters.type(CardType.COMPANION);
}
@Override

View File

@@ -43,7 +43,7 @@ public class Card1_047 extends AbstractAttachableFPPossession {
@Override
protected Filter getValidTargetFilter(String playerId, LotroGame game, PhysicalCard self) {
return Filters.and(Filters.name("Arwen"), Filters.not(Filters.hasAttached(Filters.keyword(Keyword.HAND_WEAPON))));
return Filters.name("Arwen");
}
@Override

View File

@@ -37,7 +37,7 @@ public class Card1_074 extends AbstractAttachableFPPossession {
@Override
protected Filter getValidTargetFilter(String playerId, LotroGame game, PhysicalCard self) {
return Filters.and(Filters.name("Gandalf"), Filters.not(Filters.hasAttached(Filters.keyword(Keyword.PIPE))));
return Filters.name("Gandalf");
}
@Override

View File

@@ -40,7 +40,7 @@ public class Card1_075 extends AbstractAttachableFPPossession {
@Override
protected Filter getValidTargetFilter(String playerId, LotroGame game, PhysicalCard self) {
return Filters.and(Filters.name("Gandalf"), Filters.not(Filters.hasAttached(Filters.keyword(Keyword.HAND_WEAPON))));
return Filters.name("Gandalf");
}
@Override

View File

@@ -39,7 +39,7 @@ public class Card1_090 extends AbstractAttachableFPPossession {
@Override
protected Filter getValidTargetFilter(String playerId, LotroGame game, PhysicalCard self) {
return Filters.and(Filters.name("Aragorn"), Filters.not(Filters.hasAttached(Filters.keyword(Keyword.RANGED_WEAPON))));
return Filters.name("Aragorn");
}
@Override

View File

@@ -35,7 +35,7 @@ public class Card1_091 extends AbstractAttachableFPPossession {
@Override
protected Filter getValidTargetFilter(String playerId, LotroGame game, PhysicalCard self) {
return Filters.and(Filters.culture(Culture.GONDOR), Filters.type(CardType.COMPANION), Filters.not(Filters.hasAttached(Filters.keyword(Keyword.PIPE))));
return Filters.and(Filters.culture(Culture.GONDOR), Filters.type(CardType.COMPANION));
}
@Override

View File

@@ -33,7 +33,7 @@ public class Card1_092 extends AbstractAttachableFPPossession {
@Override
protected Filter getValidTargetFilter(String playerId, LotroGame game, PhysicalCard self) {
return Filters.and(Filters.keyword(Keyword.MAN), Filters.not(Filters.hasAttached(Filters.keyword(Keyword.ARMOR))));
return Filters.keyword(Keyword.MAN);
}
@Override

View File

@@ -41,7 +41,7 @@ public class Card1_095 extends AbstractAttachableFPPossession {
@Override
protected Filter getValidTargetFilter(String playerId, LotroGame game, PhysicalCard self) {
return Filters.and(Filters.name("Boromir"), Filters.not(Filters.hasAttached(Filters.keyword(Keyword.HAND_WEAPON))));
return Filters.name("Boromir");
}
@Override

View File

@@ -34,7 +34,7 @@ public class Card1_098 extends AbstractAttachableFPPossession {
@Override
protected Filter getValidTargetFilter(String playerId, LotroGame game, PhysicalCard self) {
return Filters.and(Filters.name("Boromir"), Filters.not(Filters.hasAttached(Filters.keyword(Keyword.CLOAK))));
return Filters.name("Boromir");
}
@Override

View File

@@ -25,7 +25,7 @@ public class Card1_101 extends AbstractAttachableFPPossession {
@Override
protected Filter getValidTargetFilter(String playerId, LotroGame game, PhysicalCard self) {
return Filters.and(Filters.keyword(Keyword.MAN), Filters.not(Filters.hasAttached(Filters.keyword(Keyword.ARMOR))));
return Filters.keyword(Keyword.MAN);
}
@Override

View File

@@ -26,7 +26,7 @@ public class Card1_107 extends AbstractAttachableFPPossession {
@Override
protected Filter getValidTargetFilter(String playerId, LotroGame game, PhysicalCard self) {
return Filters.and(Filters.keyword(Keyword.MAN), Filters.not(Filters.hasAttached(Filters.keyword(Keyword.SHIELD))));
return Filters.keyword(Keyword.MAN);
}
@Override

View File

@@ -31,7 +31,7 @@ public class Card1_112 extends AbstractAttachableFPPossession {
@Override
protected Filter getValidTargetFilter(String playerId, LotroGame game, PhysicalCard self) {
return Filters.and(Filters.name("Aragorn"), Filters.not(Filters.hasAttached(Filters.keyword(Keyword.HAND_WEAPON))));
return Filters.name("Aragorn");
}
@Override

View File

@@ -37,7 +37,7 @@ public class Card1_160 extends AbstractAttachable {
@Override
protected Filter getValidTargetFilter(String playerId, LotroGame game, PhysicalCard self) {
return Filters.and(Filters.keyword(Keyword.URUK_HAI), Filters.not(Filters.hasAttached(Filters.keyword(Keyword.HAND_WEAPON))));
return Filters.keyword(Keyword.URUK_HAI);
}
@Override

View File

@@ -33,7 +33,7 @@ public class Card1_166 extends AbstractAttachable {
@Override
protected Filter getValidTargetFilter(String playerId, LotroGame game, PhysicalCard self) {
return Filters.and(Filters.name("Cave Troll of Moria"), Filters.not(Filters.hasAttached(Filters.keyword(Keyword.HAND_WEAPON))));
return Filters.name("Cave Troll of Moria");
}
@Override

View File

@@ -41,7 +41,7 @@ public class Card1_180 extends AbstractAttachable {
@Override
protected Filter getValidTargetFilter(String playerId, LotroGame game, PhysicalCard self) {
return Filters.and(Filters.culture(Culture.MORIA), Filters.keyword(Keyword.ORC), Filters.not(Filters.hasAttached(Filters.keyword(Keyword.HAND_WEAPON))));
return Filters.and(Filters.culture(Culture.MORIA), Filters.keyword(Keyword.ORC));
}
@Override

View File

@@ -38,7 +38,7 @@ public class Card1_182 extends AbstractAttachable {
@Override
protected Filter getValidTargetFilter(String playerId, LotroGame game, PhysicalCard self) {
return Filters.and(Filters.culture(Culture.MORIA), Filters.type(CardType.MINION), Filters.not(Filters.hasAttached(Filters.keyword(Keyword.HAND_WEAPON))));
return Filters.and(Filters.culture(Culture.MORIA), Filters.type(CardType.MINION));
}
@Override

View File

@@ -36,7 +36,7 @@ public class Card1_190 extends AbstractAttachable {
@Override
protected Filter getValidTargetFilter(String playerId, LotroGame game, PhysicalCard self) {
return Filters.and(Filters.culture(Culture.MORIA), Filters.keyword(Keyword.ORC), Filters.not(Filters.hasAttached(Filters.keyword(Keyword.HAND_WEAPON))));
return Filters.and(Filters.culture(Culture.MORIA), Filters.keyword(Keyword.ORC));
}
@Override

View File

@@ -40,7 +40,7 @@ public class Card1_285 extends AbstractAttachableFPPossession {
@Override
protected Filter getValidTargetFilter(String playerId, LotroGame game, PhysicalCard self) {
return Filters.and(Filters.keyword(Keyword.HOBBIT), Filters.not(Filters.hasAttached(Filters.keyword(Keyword.PIPE))));
return Filters.keyword(Keyword.HOBBIT);
}
@Override

View File

@@ -37,7 +37,7 @@ public class Card1_292 extends AbstractAttachableFPPossession {
@Override
protected Filter getValidTargetFilter(String playerId, LotroGame game, PhysicalCard self) {
return Filters.and(Filters.keyword(Keyword.HOBBIT), Filters.not(Filters.hasAttached(Filters.keyword(Keyword.PIPE))));
return Filters.keyword(Keyword.HOBBIT);
}
@Override

View File

@@ -26,7 +26,7 @@ public class Card1_299 extends AbstractAttachableFPPossession {
@Override
protected Filter getValidTargetFilter(String playerId, LotroGame game, PhysicalCard self) {
return Filters.and(Filters.keyword(Keyword.HOBBIT), Filters.not(Filters.hasAttached(Filters.keyword(Keyword.HAND_WEAPON))));
return Filters.keyword(Keyword.HOBBIT);
}
@Override

View File

@@ -39,7 +39,7 @@ public class Card1_313 extends AbstractAttachableFPPossession {
@Override
protected Filter getValidTargetFilter(String playerId, LotroGame game, PhysicalCard self) {
return Filters.and(Filters.name("Frodo"), Filters.not(Filters.hasAttached(Filters.keyword(Keyword.HAND_WEAPON))));
return Filters.name("Frodo");
}
@Override

View File

@@ -39,7 +39,7 @@ public class Card1_208 extends AbstractAttachable {
@Override
protected Filter getValidTargetFilter(String playerId, LotroGame game, PhysicalCard self) {
return Filters.and(Filters.keyword(Keyword.NAZGUL), Filters.not(Filters.hasAttached(Filters.keyword(Keyword.MOUNT))));
return Filters.keyword(Keyword.NAZGUL);
}
@Override