1 package nl.tudelft.jpacman.game;
2
3 import java.util.List;
4
5 import nl.tudelft.jpacman.level.Level;
6 import nl.tudelft.jpacman.level.Player;
7
8 import com.google.common.collect.ImmutableList;
9 import nl.tudelft.jpacman.points.PointCalculator;
10
11 /**
12 * A game with one player and a single level.
13 *
14 * @author Jeroen Roosen
15 */
16 public class SinglePlayerGame extends Game {
17
18 /**
19 * The player of this game.
20 */
21 private final Player player;
22
23 /**
24 * The level of this game.
25 */
26 private final Level level;
27
28 /**
29 * Create a new single player game for the provided level and player.
30 *
31 * @param player
32 * The player.
33 * @param level
34 * The level.
35 * @param pointCalculator
36 * The way to calculate points upon collisions.
37 */
38 protected SinglePlayerGame(Player player, Level level, PointCalculator pointCalculator) {
39 super(pointCalculator);
40
41 assert player != null;
42 assert level != null;
43
44 this.player = player;
45 this.level = level;
46 this.level.registerPlayer(player);
47 }
48
49 @Override
50 public List<Player> getPlayers() {
51 return ImmutableList.of(player);
52 }
53
54 @Override
55 public Level getLevel() {
56 return level;
57 }
58 }