-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathShooterGame.java
More file actions
36 lines (29 loc) · 918 Bytes
/
ShooterGame.java
File metadata and controls
36 lines (29 loc) · 918 Bytes
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
package com.dj.game;
import java.util.LinkedHashMap;
import java.util.Map;
public final class ShooterGame extends Game<Shooter> {
public ShooterGame(String gameName) {
super(gameName);
}
@Override
public Shooter createNewPlayer(String name) {
return new Shooter(name);
}
@Override
public Map<Character, GameAction> getGameActions(int playerIndex) {
var map = new LinkedHashMap<>(Map.of(
'F',
new GameAction('F', "Find Prize", this::findPrize),
'S',
new GameAction('S', "Use your gun", this::useWeapon)
));
map.putAll(getStandardActions());
return map;
}
public boolean findPrize(int playerIndex) {
return getPlayer(playerIndex).findPrize();
}
public boolean useWeapon(int playerIndex) {
return getPlayer(playerIndex).useWeapon("pistol");
}
}