From 690a04bcb8d2adf727faf1aa23acd6540bcb0b0f Mon Sep 17 00:00:00 2001 From: Joffrey BION Date: Sat, 10 Dec 2016 11:34:38 +0100 Subject: Add multiple effects support for cards --- .../java/org/luxons/sevenwonders/game/cards/Card.java | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) (limited to 'src/main') diff --git a/src/main/java/org/luxons/sevenwonders/game/cards/Card.java b/src/main/java/org/luxons/sevenwonders/game/cards/Card.java index 111275be..5c79ac32 100644 --- a/src/main/java/org/luxons/sevenwonders/game/cards/Card.java +++ b/src/main/java/org/luxons/sevenwonders/game/cards/Card.java @@ -1,5 +1,7 @@ package org.luxons.sevenwonders.game.cards; +import java.util.List; + import org.luxons.sevenwonders.game.boards.Board; import org.luxons.sevenwonders.game.effects.Effect; @@ -11,13 +13,13 @@ public class Card { private final Requirements requirements; - private final Effect effect; + private final List effects; - public Card(String name, Color color, Requirements requirements, Effect effect) { + public Card(String name, Color color, Requirements requirements, List effects) { this.name = name; this.color = color; this.requirements = requirements; - this.effect = effect; + this.effects = effects; } public String getName() { @@ -32,19 +34,19 @@ public class Card { return requirements; } - public Effect getEffect() { - return effect; + public List getEffects() { + return effects; } public void play(Board board, Board leftNeighbourBoard, Board rightNeighbourBoard) { board.addCard(this); requirements.pay(board); - effect.apply(board, leftNeighbourBoard, rightNeighbourBoard); + effects.forEach(e -> e.apply(board, leftNeighbourBoard, rightNeighbourBoard)); } @Override public String toString() { - return "Card{" + "name='" + name + '\'' + ", color=" + color + ", requirements=" + requirements + ", effect=" - + effect + '}'; + return "Card{" + "name='" + name + '\'' + ", color=" + color + ", requirements=" + requirements + ", effects=" + + effects + '}'; } } -- cgit