Fixed sites with optional triggers being triggerable by the wrong player (Shadows Prancing Pony, Shadows Green Dragon Inn, and others)

This commit is contained in:
Christian 'ketura' McCarty
2024-12-11 22:23:18 -06:00
parent 1c3a07557c
commit 627b705b53
3 changed files with 28 additions and 25 deletions

View File

@@ -788,10 +788,6 @@ public class BuiltLotroCardBlueprint implements LotroCardBlueprint {
for (ActionSource optionalBeforeTrigger : optionalBeforeTriggers) {
var actionContext = new DefaultActionContext(playerId, game, self, null, effect);
if(optionalBeforeTrigger.getPlayer() != null) {
actionContext = new DefaultActionContext(optionalBeforeTrigger.getPlayer().getPlayer(actionContext), game, self, null, effect);
}
if (optionalBeforeTrigger.isValid(actionContext)) {
OptionalTriggerAction action = new OptionalTriggerAction(self);
optionalBeforeTrigger.createAction(action, actionContext);
@@ -823,10 +819,6 @@ public class BuiltLotroCardBlueprint implements LotroCardBlueprint {
for (ActionSource optionalAfterTrigger : optionalAfterTriggers) {
DefaultActionContext actionContext = new DefaultActionContext(playerId, game, self, effectResult, null);
if(optionalAfterTrigger.getPlayer() != null) {
actionContext = new DefaultActionContext(optionalAfterTrigger.getPlayer().getPlayer(actionContext), game, self, effectResult, null);
}
if (optionalAfterTrigger.isValid(actionContext)) {
OptionalTriggerAction action = new OptionalTriggerAction(self);
optionalAfterTrigger.createAction(action, actionContext);

View File

@@ -17,7 +17,7 @@ import org.json.simple.JSONObject;
public class TriggerEffectProcessor implements EffectProcessor {
@Override
public void processEffect(JSONObject value, BuiltLotroCardBlueprint blueprint, CardGenerationEnvironment environment) throws InvalidCardDefinitionException {
FieldUtils.validateAllowedFields(value, "trigger", "optional", "requires", "cost", "effect", "text", "player", "limitPerTurn", "limitPerPhase", "phase", "identifierSuffix");
FieldUtils.validateAllowedFields(value, "trigger", "optional", "requires", "cost", "effect", "text", "player", "limitPerTurn", "limitPerPhase", "phase");
final String text = FieldUtils.getString(value.get("text"), "text");
final JSONObject[] triggerArray = FieldUtils.getObjectArray(value.get("trigger"), "trigger");
@@ -30,7 +30,6 @@ public class TriggerEffectProcessor implements EffectProcessor {
final String player = FieldUtils.getString(value.get("player"), "player");
PlayerSource playerSource = (player != null) ? PlayerResolver.resolvePlayer(player) : null;
final String identifierSuffix = FieldUtils.getString(value.get("identifierSuffix"), "identifierSuffix");
for (JSONObject trigger : triggerArray) {
final TriggerChecker triggerChecker = environment.getTriggerCheckerFactory().getTriggerChecker(trigger, environment);

View File

@@ -17,12 +17,23 @@ public class Card_11_242_Tests
return new GenericCardTestHelper(
new HashMap<>()
{{
put("card", "11_242");
// put other cards in here as needed for the test case
put("sam", "1_310");
put("gaffer", "1_291");
}},
new HashMap<>() {{
put("greendragon", "11_242");
put("site2", "13_185");
put("site3", "11_234");
put("site4", "17_148");
put("site5", "18_138");
put("site6", "11_230");
put("site7", "12_187");
put("site8", "12_185");
put("site9", "17_146");
}},
GenericCardTestHelper.FellowshipSites,
GenericCardTestHelper.FOTRFrodo,
GenericCardTestHelper.RulingRing
GenericCardTestHelper.RulingRing,
GenericCardTestHelper.Shadows
);
}
@@ -44,9 +55,7 @@ public class Card_11_242_Tests
var scn = GetScenario();
//Use this once you have set the deck up properly
//var card = scn.GetFreepsSite();
var card = scn.GetFreepsCard("card");
var card = scn.GetFreepsCard("greendragon");
assertEquals("Green Dragon Inn", card.getBlueprint().getTitle());
assertNull(card.getBlueprint().getSubtitle());
@@ -56,18 +65,21 @@ public class Card_11_242_Tests
assertEquals(3, card.getBlueprint().getTwilightCost());
}
// Uncomment any @Test markers below once this is ready to be used
//@Test
public void GreenDragonInnTest1() throws DecisionResultInvalidException, CardNotFoundException {
@Test
public void GreenDragonInnIsOnlyTriggeredByFreePeoplesPlayerAndNotShadow() throws DecisionResultInvalidException, CardNotFoundException {
//Pre-game setup
var scn = GetScenario();
var card = scn.GetFreepsCard("card");
scn.FreepsMoveCardToHand(card);
var sam = scn.GetFreepsCard("sam");
scn.FreepsMoveCharToTable(sam);
scn.StartGame();
scn.FreepsPlayCard(card);
var greendragon = scn.GetFreepsCard("greendragon");
assertEquals(3, scn.GetTwilight());
scn.StartGame(greendragon);
scn.FreepsMoveCardsToTopOfDeck("gaffer");
assertTrue(scn.FreepsHasOptionalTriggerAvailable());
scn.FreepsDeclineOptionalTrigger();
assertFalse(scn.ShadowHasOptionalTriggerAvailable());
}
}