Introducing card activated effect.

This commit is contained in:
marcins78@gmail.com
2011-10-10 13:46:14 +00:00
parent 9b126d6136
commit be51161dad
5 changed files with 155 additions and 14 deletions

View File

@@ -3,6 +3,8 @@ package com.gempukku.lotro.logic.actions;
import com.gempukku.lotro.common.Keyword;
import com.gempukku.lotro.game.PhysicalCard;
import com.gempukku.lotro.game.state.LotroGame;
import com.gempukku.lotro.logic.GameUtils;
import com.gempukku.lotro.logic.effects.ActivateCardEffect;
import com.gempukku.lotro.logic.effects.SendMessageEffect;
import com.gempukku.lotro.logic.timing.Effect;
@@ -10,11 +12,16 @@ public class ActivateCardAction extends AbstractCostToEffectAction {
private PhysicalCard _physicalCard;
private Keyword _type;
private ActivateCardEffect _activateCardEffect;
private boolean _sentMessage;
private boolean _activated;
public ActivateCardAction(PhysicalCard physicalCard, Keyword type) {
_physicalCard = physicalCard;
_type = type;
_activateCardEffect = new ActivateCardEffect(physicalCard);
}
@Override
@@ -44,14 +51,21 @@ public class ActivateCardAction extends AbstractCostToEffectAction {
if (cost != null)
return cost;
Effect effect = getNextEffect();
if (effect != null)
return effect;
if (!_activated) {
_activated = true;
return _activateCardEffect;
}
if (!_activateCardEffect.isCancelled()) {
Effect effect = getNextEffect();
if (effect != null)
return effect;
}
}
return null;
}
protected String getMessage() {
return "<div class='cardHint' value='" + _physicalCard.getBlueprintId() + "'>" + _physicalCard.getBlueprint().getName() + "</div> is used";
private String getMessage() {
return GameUtils.getCardLink(_physicalCard) + " is used";
}
}

View File

@@ -1,17 +1,56 @@
package com.gempukku.lotro.logic.actions;
import com.gempukku.lotro.common.Keyword;
import com.gempukku.lotro.game.PhysicalCard;
import com.gempukku.lotro.game.state.LotroGame;
import com.gempukku.lotro.logic.GameUtils;
import com.gempukku.lotro.logic.effects.SendMessageEffect;
import com.gempukku.lotro.logic.timing.Effect;
public class OptionalTriggerAction extends ActivateCardAction {
public class OptionalTriggerAction extends AbstractCostToEffectAction {
private PhysicalCard _physicalCard;
private boolean _sentMessage;
public OptionalTriggerAction(PhysicalCard physicalCard) {
super(physicalCard, null);
_physicalCard = physicalCard;
}
@Override
protected String getMessage() {
return "<div class='cardHint' value='" + _physicalCard.getBlueprintId() + "'>" + _physicalCard.getBlueprint().getName() + "</div> optional triggered effect is used";
public Keyword getType() {
return null;
}
@Override
public PhysicalCard getActionSource() {
return _physicalCard;
}
@Override
public String getText(LotroGame game) {
return null;
}
@Override
public Effect nextEffect() {
if (!_sentMessage && _physicalCard != null) {
_sentMessage = true;
return new SendMessageEffect(getMessage());
}
if (!isCostFailed()) {
Effect cost = getNextCost();
if (cost != null)
return cost;
Effect effect = getNextEffect();
if (effect != null)
return effect;
}
return null;
}
private String getMessage() {
return GameUtils.getCardLink(_physicalCard) + " optional triggered effect is used";
}
}

View File

@@ -1,17 +1,56 @@
package com.gempukku.lotro.logic.actions;
import com.gempukku.lotro.common.Keyword;
import com.gempukku.lotro.game.PhysicalCard;
import com.gempukku.lotro.game.state.LotroGame;
import com.gempukku.lotro.logic.GameUtils;
import com.gempukku.lotro.logic.effects.SendMessageEffect;
import com.gempukku.lotro.logic.timing.Effect;
public class RequiredTriggerAction extends ActivateCardAction {
public class RequiredTriggerAction extends AbstractCostToEffectAction {
private PhysicalCard _physicalCard;
private boolean _sentMessage;
public RequiredTriggerAction(PhysicalCard physicalCard) {
super(physicalCard, null);
_physicalCard = physicalCard;
}
@Override
protected String getMessage() {
return "<div class='cardHint' value='" + _physicalCard.getBlueprintId() + "'>" + _physicalCard.getBlueprint().getName() + "</div> required triggered effect is used";
public Keyword getType() {
return null;
}
@Override
public PhysicalCard getActionSource() {
return _physicalCard;
}
@Override
public String getText(LotroGame game) {
return null;
}
@Override
public Effect nextEffect() {
if (!_sentMessage && _physicalCard != null) {
_sentMessage = true;
return new SendMessageEffect(getMessage());
}
if (!isCostFailed()) {
Effect cost = getNextCost();
if (cost != null)
return cost;
Effect effect = getNextEffect();
if (effect != null)
return effect;
}
return null;
}
private String getMessage() {
return GameUtils.getCardLink(_physicalCard) + " required triggered effect is used";
}
}

View File

@@ -0,0 +1,49 @@
package com.gempukku.lotro.logic.effects;
import com.gempukku.lotro.game.PhysicalCard;
import com.gempukku.lotro.game.state.LotroGame;
import com.gempukku.lotro.logic.GameUtils;
import com.gempukku.lotro.logic.timing.AbstractEffect;
import com.gempukku.lotro.logic.timing.EffectResult;
public class ActivateCardEffect extends AbstractEffect {
private PhysicalCard _source;
private boolean _cancelled;
public ActivateCardEffect(PhysicalCard source) {
_source = source;
}
@Override
public EffectResult.Type getType() {
return EffectResult.Type.ACTIVATE;
}
@Override
public String getText(LotroGame game) {
return "Activated " + GameUtils.getCardLink(_source);
}
public PhysicalCard getSource() {
return _source;
}
@Override
public boolean isPlayableInFull(LotroGame game) {
return true;
}
public boolean isCancelled() {
return _cancelled;
}
public void cancel() {
_cancelled = true;
}
@Override
protected FullEffectResult playEffectReturningResult(LotroGame game) {
return new FullEffectResult(null, true, true);
}
}

View File

@@ -14,7 +14,7 @@ public abstract class EffectResult {
START_OF_TURN,
END_OF_TURN,
PLAY, DRAW_CARD_OR_PUT_INTO_HAND,
PLAY, ACTIVATE, DRAW_CARD_OR_PUT_INTO_HAND,
PUT_ON_THE_ONE_RING, REMOVE_BURDEN, ADD_BURDEN,