"Harsh Tongues" and initiative workings...

This commit is contained in:
marcins78@gmail.com
2011-11-03 15:35:57 +00:00
parent 32c51e9185
commit f2fd60ebce
13 changed files with 117 additions and 36 deletions

View File

@@ -148,7 +148,7 @@ public class PlayConditions {
}
public static boolean hasInitiative(LotroGame game, Side side) {
return game.getGameState().getInitiativeSide() == side;
return game.getModifiersQuerying().hasInitiative(game.getGameState()) == side;
}
public static boolean canAddThreat(LotroGame game, PhysicalCard card, int count) {

View File

@@ -0,0 +1,27 @@
package com.gempukku.lotro.cards.modifiers;
import com.gempukku.lotro.common.Side;
import com.gempukku.lotro.game.PhysicalCard;
import com.gempukku.lotro.game.state.GameState;
import com.gempukku.lotro.logic.modifiers.AbstractModifier;
import com.gempukku.lotro.logic.modifiers.Condition;
import com.gempukku.lotro.logic.modifiers.ModifierEffect;
import com.gempukku.lotro.logic.modifiers.ModifiersQuerying;
public class HasInitiativeModifier extends AbstractModifier {
private Condition _condition;
private Side _side;
public HasInitiativeModifier(PhysicalCard source, Condition condition, Side side) {
super(source, side + " has initiative", null, ModifierEffect.INITIATIVE_MODIFIER);
_condition = condition;
_side = side;
}
@Override
public Side hasInitiative(GameState gameState, ModifiersQuerying modifiersQuerying) {
if (_condition == null || _condition.isFullfilled(gameState, modifiersQuerying))
return _side;
return null;
}
}

View File

@@ -14,6 +14,6 @@ public class InitiativeCondition implements Condition {
@Override
public boolean isFullfilled(GameState gameState, ModifiersQuerying modifiersQuerying) {
return gameState.getInitiativeSide() == _side;
return modifiersQuerying.hasInitiative(gameState) == _side;
}
}

View File

@@ -1,6 +1,7 @@
package com.gempukku.lotro.cards.set7.gandalf;
import com.gempukku.lotro.cards.AbstractEvent;
import com.gempukku.lotro.cards.PlayConditions;
import com.gempukku.lotro.cards.actions.PlayEventAction;
import com.gempukku.lotro.common.Culture;
import com.gempukku.lotro.common.Keyword;
@@ -33,7 +34,7 @@ public class Card7_031 extends AbstractEvent {
new ChooseActiveCardEffect(self, playerId, "Choose Gandalf", Filters.gandalf) {
@Override
protected void cardSelected(LotroGame game, PhysicalCard card) {
if (game.getGameState().getInitiativeSide() == Side.FREE_PEOPLE) {
if (PlayConditions.hasInitiative(game, Side.FREE_PEOPLE)) {
game.getModifiersEnvironment().addUntilEndOfPhaseModifier(
new StrengthModifier(self, card, 4), Phase.SKIRMISH);
game.getModifiersEnvironment().addUntilEndOfPhaseModifier(

View File

@@ -38,7 +38,7 @@ public class Card7_043 extends AbstractEvent {
@Override
public PlayEventAction getPlayCardAction(String playerId, LotroGame game, final PhysicalCard self, int twilightModifier) {
final PlayEventAction action = new PlayEventAction(self);
int exertCount = (game.getGameState().getInitiativeSide() == Side.FREE_PEOPLE) ? 2 : 3;
int exertCount = (PlayConditions.hasInitiative(game, Side.FREE_PEOPLE)) ? 2 : 3;
action.appendCost(
new ChooseAndExertCharactersEffect(action, playerId, 1, 1, exertCount, Filters.gandalf));
action.appendEffect(

View File

@@ -0,0 +1,59 @@
package com.gempukku.lotro.cards.set7.raider;
import com.gempukku.lotro.cards.AbstractPermanent;
import com.gempukku.lotro.cards.PlayConditions;
import com.gempukku.lotro.cards.effects.AddTokenEffect;
import com.gempukku.lotro.cards.effects.RemoveTwilightEffect;
import com.gempukku.lotro.cards.modifiers.HasInitiativeModifier;
import com.gempukku.lotro.common.*;
import com.gempukku.lotro.filters.Filters;
import com.gempukku.lotro.game.PhysicalCard;
import com.gempukku.lotro.game.state.LotroGame;
import com.gempukku.lotro.logic.actions.ActivateCardAction;
import com.gempukku.lotro.logic.modifiers.Modifier;
import com.gempukku.lotro.logic.modifiers.SpotCondition;
import com.gempukku.lotro.logic.timing.Action;
import java.util.Collections;
import java.util.List;
/**
* Set: The Return of the King
* Side: Shadow
* Culture: Raider
* Twilight Cost: 1
* Type: Condition • Support Area
* Game Text: To play, spot a [RAIDER] Man. Regroup: Remove (3) and spot a [RAIDER] Man to place a [RAIDER] token here.
* While there are 3 [RAIDER] tokens here, the Shadow has initiative regardless of the Free Peoples player's hand.
*/
public class Card7_150 extends AbstractPermanent {
public Card7_150() {
super(Side.SHADOW, 1, CardType.CONDITION, Culture.RAIDER, Zone.SUPPORT, "Harsh Tongues");
}
@Override
public boolean checkPlayRequirements(String playerId, LotroGame game, PhysicalCard self, int twilightModifier) {
return super.checkPlayRequirements(playerId, game, self, twilightModifier)
&& PlayConditions.canSpot(game, Culture.RAIDER, Race.MAN);
}
@Override
public List<? extends Modifier> getAlwaysOnModifiers(LotroGame game, PhysicalCard self) {
return Collections.singletonList(
new HasInitiativeModifier(self, new SpotCondition(self, Filters.hasToken(Token.RAIDER, 3)), Side.SHADOW));
}
@Override
protected List<? extends Action> getExtraPhaseActions(String playerId, LotroGame game, PhysicalCard self) {
if (PlayConditions.canUseShadowCardDuringPhase(game.getGameState(), Phase.REGROUP, self, 3)
&& PlayConditions.canSpot(game, Culture.RAIDER, Race.MAN)) {
ActivateCardAction action = new ActivateCardAction(self);
action.appendCost(
new RemoveTwilightEffect(3));
action.appendEffect(
new AddTokenEffect(self, self, Token.RAIDER));
return Collections.singletonList(action);
}
return null;
}
}

View File

@@ -33,8 +33,6 @@ public class GameState {
private boolean _wearingRing;
private boolean _consecutiveAction;
private Side _initiativeSide;
private Map<String, Integer> _playerPosition = new HashMap<String, Integer>();
private Map<String, Integer> _playerThreats = new HashMap<String, Integer>();
@@ -76,14 +74,6 @@ public class GameState {
listener.setPlayerOrder(playerOrder.getAllPlayers());
}
public void setInitiativeSide(Side initiativeSide) {
_initiativeSide = initiativeSide;
}
public Side getInitiativeSide() {
return _initiativeSide;
}
private void addPlayerCards(String playerId, List<String> cards, LotroCardBlueprintLibrary library) {
for (String blueprintId : cards) {
LotroCardBlueprint card = library.getLotroCardBlueprint(blueprintId);

View File

@@ -242,4 +242,9 @@ public abstract class AbstractModifier implements Modifier {
public boolean hasFlagActive(GameState gameState, ModifiersQuerying modifiersQuerying, ModifierFlag modifierFlag) {
return false;
}
@Override
public Side hasInitiative(GameState gameState, ModifiersQuerying modifiersQuerying) {
return null;
}
}

View File

@@ -96,4 +96,6 @@ public interface Modifier {
public int getSpotCountModifier(GameState gameState, ModifiersQuerying modifiersQuerying, Filter filter);
public boolean hasFlagActive(GameState gameState, ModifiersQuerying modifiersQuerying, ModifierFlag modifierFlag);
public Side hasInitiative(GameState gameState, ModifiersQuerying modifiersQuerying);
}

View File

@@ -6,7 +6,7 @@ public enum ModifierEffect {
PRESENCE_MODIFIER, ARCHERY_MODIFIER, MOVE_LIMIT_MODIFIER, ACTION_MODIFIER, ASSIGNMENT_MODIFIER, DISCARD_FROM_PLAY_MODIFIER, DISCARD_NOT_FROM_PLAY,
LOOK_OR_REVEAL_MODIFIER, SPOT_MODIFIER, TARGET_MODIFIER,
EXTRA_ACTION_MODIFIER,
EXTRA_ACTION_MODIFIER, INITIATIVE_MODIFIER,
SPECIAL_FLAG_MODIFIER
}

View File

@@ -544,13 +544,19 @@ public class ModifiersLogic implements ModifiersEnvironment, ModifiersQuerying {
}
@Override
public boolean hasInitiative(GameState gameState, Side side) {
public Side hasInitiative(GameState gameState) {
for (Modifier modifier : getModifiers(ModifierEffect.INITIATIVE_MODIFIER)) {
Side initiative = modifier.hasInitiative(gameState, this);
if (initiative != null)
return initiative;
}
int freePeopleInitiativeHandSize = gameState.getHand(gameState.getCurrentPlayerId()).size()
+ gameState.getVoid(gameState.getCurrentPlayerId()).size();
if (side == Side.SHADOW)
return freePeopleInitiativeHandSize < 4;
if (freePeopleInitiativeHandSize < 4)
return Side.SHADOW;
else
return freePeopleInitiativeHandSize >= 4;
return Side.FREE_PEOPLE;
}
@Override

View File

@@ -91,7 +91,7 @@ public interface ModifiersQuerying {
public boolean canDiscardCardsFromTopOfDeck(GameState gameState, String playerId, PhysicalCard source);
public boolean hasInitiative(GameState gameState, Side side);
public Side hasInitiative(GameState gameState);
public int getSpotCount(GameState gameState, Filter filter, int inPlayCount);

View File

@@ -41,16 +41,6 @@ public class TurnProcedure {
return _gameStats;
}
private EffectResult getOptionalInitiativeChangeResult() {
Side oldSide = _game.getGameState().getInitiativeSide();
if (!_game.getModifiersQuerying().hasInitiative(_game.getGameState(), oldSide)) {
Side newSide = (oldSide == Side.SHADOW) ? Side.FREE_PEOPLE : Side.SHADOW;
_game.getGameState().setInitiativeSide(newSide);
return new InitiativeChangeResult(newSide);
}
return null;
}
public void carryOutPendingActionsUntilDecisionNeeded() {
while (!_userFeedback.hasPendingDecisions() && _game.getWinnerPlayerId() == null) {
if (_actionStack.isEmpty()) {
@@ -113,17 +103,18 @@ public class TurnProcedure {
}
if (!_effectPlayed) {
_effectPlayed = true;
Side initiativePreEffect = _game.getModifiersQuerying().hasInitiative(_game.getGameState());
final Collection<? extends EffectResult> effectResults = _effect.playEffect(_game);
List<EffectResult> results = new LinkedList<EffectResult>();
if (effectResults != null)
results.addAll(effectResults);
// check for changing initiative, ugly but it's a sort of state based effect and not a trigger, just
// results in maybe generating a trigger along with others that might happen at the same time (discard
// cards, play cards, draw cards, etc)
EffectResult initiativeEffectResult = getOptionalInitiativeChangeResult();
if (initiativeEffectResult != null)
results.add(initiativeEffectResult);
Side initiativePostEffect = _game.getModifiersQuerying().hasInitiative(_game.getGameState());
if (initiativePreEffect != initiativePostEffect)
results.add(new InitiativeChangeResult(initiativePostEffect));
_effectResults = results;