Extra costs are played at the correct time.

This commit is contained in:
marcin.sciesinski
2019-10-18 11:28:05 -07:00
parent dbf3c6c50e
commit 686b384c14
4 changed files with 50 additions and 23 deletions

View File

@@ -357,7 +357,7 @@
"type": "minion",
"race": "orc",
"strength": 10,
"vitality": 4,
"vitality": 3,
"site": 4,
"effects": {
"type": "trigger",

View File

@@ -23,27 +23,32 @@ public abstract class DelayedAppender implements EffectAppender {
@Override
public final void appendEffect(boolean cost, CostToEffectAction action, ActionContext actionContext) {
action.appendEffect(
new UnrespondableEffect() {
@Override
protected void doPlayEffect(LotroGame game) {
// Need to insert them, but in the reverse order
final List<? extends Effect> effects = createEffects(cost, action, actionContext);
if (effects != null) {
final Effect[] effectsArray = effects.toArray(new Effect[0]);
for (int i = effectsArray.length - 1; i >= 0; i--)
if (cost)
action.insertCost(effectsArray[i]);
else
action.insertEffect(effectsArray[i]);
}
}
final UnrespondableEffect effect = new UnrespondableEffect() {
@Override
protected void doPlayEffect(LotroGame game) {
// Need to insert them, but in the reverse order
final List<? extends Effect> effects = createEffects(cost, action, actionContext);
if (effects != null) {
final Effect[] effectsArray = effects.toArray(new Effect[0]);
for (int i = effectsArray.length - 1; i >= 0; i--)
if (cost)
action.insertCost(effectsArray[i]);
else
action.insertEffect(effectsArray[i]);
}
}
@Override
public String getText(LotroGame game) {
return text;
}
});
@Override
public String getText(LotroGame game) {
return text;
}
};
if (cost) {
action.appendCost(effect);
} else {
action.appendEffect(effect);
}
}
protected Effect createEffect(boolean cost, CostToEffectAction action, ActionContext actionContext) {

View File

@@ -36,4 +36,26 @@ public class CostAtTest extends AbstractAtTest {
playerDecided(P1, "0");
assertEquals(twilightPool, _game.getGameState().getTwilightPool());
}
@Test
public void exertExtraCost() throws DecisionResultInvalidException, CardNotFoundException {
initializeSimplestGame();
final PhysicalCardImpl azog = createCard(P2, "32_28");
final PhysicalCardImpl fimbul = createCard(P2, "30_33");
_game.getGameState().addCardToZone(_game, azog, Zone.HAND);
_game.getGameState().addCardToZone(_game, fimbul, Zone.HAND);
skipMulligans();
_game.getGameState().setTwilight(20);
playerDecided(P1, "");
playerDecided(P2, getCardActionId(P2, "Play Azog"));
playerDecided(P2, getCardActionId(P2, "Play Fimbul"));
assertEquals(1, _game.getGameState().getWounds(azog));
}
}

View File

@@ -482,9 +482,9 @@ public class NewCardsAtTest extends AbstractAtTest {
skipMulligans();
playerDecided(P1, "0");
playerDecided(P1, "2");
playerDecided(P1, "");
playerDecided(P1, "2");
playerDecided(P1, "" + blackBreath.getCardId());
playerDecided(P1, "" + blackBreath2.getCardId());
@@ -509,9 +509,9 @@ public class NewCardsAtTest extends AbstractAtTest {
skipMulligans();
playerDecided(P1, "0");
playerDecided(P1, "1");
playerDecided(P1, "");
playerDecided(P1, "1");
playerDecided(P1, "" + blackBreath.getCardId());
assertEquals(AwaitingDecisionType.CARD_ACTION_CHOICE, _userFeedback.getAwaitingDecision(P1).getDecisionType());