aboutsummaryrefslogtreecommitdiff
path: root/src/ch/epfl
diff options
context:
space:
mode:
Diffstat (limited to 'src/ch/epfl')
-rw-r--r--src/ch/epfl/xblast/server/Bonus.java35
1 files changed, 24 insertions, 11 deletions
diff --git a/src/ch/epfl/xblast/server/Bonus.java b/src/ch/epfl/xblast/server/Bonus.java
index 09a2248..f22c9fe 100644
--- a/src/ch/epfl/xblast/server/Bonus.java
+++ b/src/ch/epfl/xblast/server/Bonus.java
@@ -1,40 +1,53 @@
1package ch.epfl.xblast.server; 1package ch.epfl.xblast.server;
2 2
3/** 3/**
4 * Bonuses. 4 * @author TimothéE FLOURE (257420)
5 *
6 * @author Pacien TRAN-GIRARD (261948)
7 * @author Timothée FLOURE (257420)
8 */ 5 */
9public enum Bonus { 6public enum Bonus {
10 7
11 /** 8 /**
12 * Increases the maximum number of bombs used simultaneously. 9 * Increase the maximum number of bombs used simultaneously.
13 */ 10 */
14 INC_BOMB { 11 INC_BOMB {
15 @Override 12 @Override
16 public Player applyTo(Player player) { 13 public Player applyTo(Player player) {
17 // TODO 14 if (player.maxBombs() < BOMBS_LIMIT) {
18 return null; 15 return player.withMaxBombs(player.maxBombs() + 1);
16 } else {
17 return player.withMaxBombs(BOMBS_LIMIT);
18 }
19 } 19 }
20 }, 20 },
21 21
22 /** 22 /**
23 * Increases the range of the bombs. 23 * Increase the range of the bombs.
24 */ 24 */
25 INC_RANGE { 25 INC_RANGE {
26 @Override 26 @Override
27 public Player applyTo(Player player) { 27 public Player applyTo(Player player) {
28 // TODO 28 if (player.bombRange() < RANGE_LIMIT) {
29 return null; 29 return player.withBombRange(player.bombRange() + 1);
30 } else {
31 return player.withBombRange(RANGE_LIMIT);
32 }
30 } 33 }
31 }; 34 };
32 35
33 /** 36 /**
37 * Maximum number of bombs.
38 */
39 private final int BOMBS_LIMIT = 9;
40
41 /**
42 * Maximum range of a bomb.
43 */
44 private final int RANGE_LIMIT = 9;
45
46 /**
34 * Apply the bonus to the given player. 47 * Apply the bonus to the given player.
35 * 48 *
36 * @param player receiving the bonus 49 * @param player receiving the bonus
50 * @return a new player with the modified values
37 */ 51 */
38 abstract public Player applyTo(Player player); 52 abstract public Player applyTo(Player player);
39
40} 53}