Added Rule of 4.

This commit is contained in:
marcins78@gmail.com
2011-09-13 09:34:42 +00:00
parent 2be9584f9c
commit 295587c551
6 changed files with 39 additions and 8 deletions

View File

@@ -28,7 +28,9 @@ public class PutCardFromDeckIntoHandOrDiscardEffect extends UnrespondableEffect
@Override
public void doPlayEffect(LotroGame game) {
game.getGameState().removeCardFromZone(_physicalCard);
game.getGameState().addCardToZone(_physicalCard, Zone.HAND);
if (game.getModifiersQuerying().canDrawCardAndIncrement(game.getGameState(), _physicalCard.getOwner())) {
game.getGameState().removeCardFromZone(_physicalCard);
game.getGameState().addCardToZone(_physicalCard, Zone.HAND);
}
}
}

View File

@@ -15,8 +15,10 @@ public class PutCardFromDiscardIntoHandEffect extends UnrespondableEffect {
@Override
public void doPlayEffect(LotroGame game) {
GameState gameState = game.getGameState();
gameState.removeCardFromZone(_card);
gameState.addCardToZone(_card, Zone.HAND);
if (game.getModifiersQuerying().canDrawCardAndIncrement(game.getGameState(), _card.getOwner())) {
GameState gameState = game.getGameState();
gameState.removeCardFromZone(_card);
gameState.addCardToZone(_card, Zone.HAND);
}
}
}

View File

@@ -17,6 +17,7 @@ public class DrawCardEffect extends UnrespondableEffect {
@Override
public void doPlayEffect(LotroGame game) {
game.getGameState().playerDrawsCard(_playerId);
if (game.getModifiersQuerying().canDrawCardAndIncrement(game.getGameState(), _playerId))
game.getGameState().playerDrawsCard(_playerId);
}
}

View File

@@ -21,6 +21,8 @@ public class ModifiersLogic implements ModifiersEnvironment, ModifiersQuerying {
private Map<Phase, Map<PhysicalCard, LimitCounter>> _counters = new HashMap<Phase, Map<PhysicalCard, LimitCounter>>();
private int _drawnThisPhaseCount = 0;
@Override
public LimitCounter getUntilEndOfPhaseLimitCounter(PhysicalCard card, Phase phase) {
Map<PhysicalCard, LimitCounter> limitCounterMap = _counters.get(phase);
@@ -84,6 +86,8 @@ public class ModifiersLogic implements ModifiersEnvironment, ModifiersQuerying {
Map<PhysicalCard, LimitCounter> counterMap = _counters.get(phase);
if (counterMap != null)
counterMap.clear();
_drawnThisPhaseCount = 0;
}
public void removeStartOfPhase(Phase phase) {
@@ -408,6 +412,26 @@ public class ModifiersLogic implements ModifiersEnvironment, ModifiersQuerying {
return result;
}
/**
* Rule of 4. "You cannot draw (or take into hand) more than 4 cards during your fellowship phase."
*
* @param gameState
* @param playerId
* @return
*/
@Override
public boolean canDrawCardAndIncrement(GameState gameState, String playerId) {
if (gameState.getCurrentPlayerId().equals(playerId)) {
if (gameState.getCurrentPhase() != Phase.FELLOWSHIP || _drawnThisPhaseCount < 4) {
_drawnThisPhaseCount++;
return true;
} else {
return false;
}
}
return true;
}
private class ModifierHookImpl implements ModifierHook {
private Modifier _modifier;

View File

@@ -49,4 +49,6 @@ public interface ModifiersQuerying {
public boolean canBeDiscardedFromPlay(GameState gameState, PhysicalCard card, PhysicalCard source);
public boolean canBeHealed(GameState gameState, PhysicalCard card);
public boolean canDrawCardAndIncrement(GameState gameState, String playerId);
}

View File

@@ -6,8 +6,6 @@ final methods were possible to avoid implementation errors on new cards added.
and go with different selection.
9. Add checkbox option to auto-pass if there is no actions to be played.
10. Add active/all cards switch to the user interface.
11. Merge Shadow and FP support area on the UI and extend the Shadow and FP characters window.
12. Add rule of 4.
13. Add dead/discard pile displays.
14. Add hand/deck card count displays.
@@ -21,3 +19,5 @@ overloaded constructor for single cards for backward compatibility, this constru
with Filters.sameCard(...) filter.
5. Introduce move card operation in communication between the server and client to change the zone/params of the card.
7. Add chat.
11. Merge Shadow and FP support area on the UI and extend the Shadow and FP characters window.
12. Add rule of 4.