-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCard.java
69 lines (53 loc) · 2.04 KB
/
Card.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
import java.util.Map;
import java.util.HashMap;
public class Card {
private static final Map<String, CardType> cardTypes = new HashMap<>();
private static final Map<String, CardEffect> cardEffects = new HashMap<>();
static {
cardTypes.put("Bang", CardType.BANG);
cardTypes.put("Missed", CardType.MISSED);
cardTypes.put("Beer", CardType.BEER);
cardTypes.put("Cat Balou", CardType.CAT_BALOU);
cardTypes.put("Stagecoach", CardType.STAGECOACH);
cardTypes.put("Indians", CardType.INDIANS);
cardTypes.put("Jail", CardType.JAIL);
cardTypes.put("Dynamite", CardType.DYNAMITE);
cardTypes.put("Barrel", CardType.BARREL);
cardEffects.put("Bang", (game, player) -> {
game.attackPlayer(player);
});
cardEffects.put("Missed", (game, player) -> {
// Missed cards are automatically played when attacked
});
cardEffects.put("Beer", (game, player) -> {
game.increasePlayerLives(player, 1);
});
cardEffects.put("Cat Balou", (game, player) -> {
game.removeRandomCardFromOpponent(player);
});
cardEffects.put("Stagecoach", (game, player) -> {
game.drawStagecoachCards(player);
});
cardEffects.put("Indians", (game, player) -> {
game.indiansAttack(player);
});
cardEffects.put("Jail", (game, player) -> {
game.putPlayerInJail(player);
});
cardEffects.put("Dynamite", (game, player) -> {
game.placeDynamite(player);
});
cardEffects.put("Barrel", (game, player) -> {
game.addBarrel(player);
});
}
public static CardType getCardType(String card) {
return cardTypes.get(card);
}
public static CardEffect getCardEffect(String card) {
return cardEffects.get(card);
}
public interface CardEffect {
void execute(BangGame game, String player);
}
}