diff options
Diffstat (limited to 'src/ch/epfl/xblast/server/Player.java')
-rw-r--r-- | src/ch/epfl/xblast/server/Player.java | 22 |
1 files changed, 20 insertions, 2 deletions
diff --git a/src/ch/epfl/xblast/server/Player.java b/src/ch/epfl/xblast/server/Player.java index 094d395..fdc4715 100644 --- a/src/ch/epfl/xblast/server/Player.java +++ b/src/ch/epfl/xblast/server/Player.java | |||
@@ -238,7 +238,7 @@ public final class Player { | |||
238 | 238 | ||
239 | int newLives = lives() - 1; | 239 | int newLives = lives() - 1; |
240 | 240 | ||
241 | if (newLives >= 0) { | 241 | if (newLives <= 0) { |
242 | LifeState dead = new LifeState(newLives, LifeState.State.DEAD); | 242 | LifeState dead = new LifeState(newLives, LifeState.State.DEAD); |
243 | nextLifeState = nextLifeState.concat(Sq.constant(dead)); | 243 | nextLifeState = nextLifeState.concat(Sq.constant(dead)); |
244 | } else { | 244 | } else { |
@@ -260,6 +260,13 @@ public final class Player { | |||
260 | } | 260 | } |
261 | 261 | ||
262 | /** | 262 | /** |
263 | * @return the vulnerability state of the player | ||
264 | */ | ||
265 | public boolean isVulnerable() { | ||
266 | return this.lifeState().state() == LifeState.State.VULNERABLE; | ||
267 | } | ||
268 | |||
269 | /** | ||
263 | * @return the current number of lives of the player | 270 | * @return the current number of lives of the player |
264 | */ | 271 | */ |
265 | public int lives() { | 272 | public int lives() { |
@@ -270,7 +277,7 @@ public final class Player { | |||
270 | * @return true is the player has more than 0 lives | 277 | * @return true is the player has more than 0 lives |
271 | */ | 278 | */ |
272 | public boolean isAlive() { | 279 | public boolean isAlive() { |
273 | return this.lives() >= 0; | 280 | return this.lives() > 0; |
274 | } | 281 | } |
275 | 282 | ||
276 | /** | 283 | /** |
@@ -329,4 +336,15 @@ public final class Player { | |||
329 | return new Bomb(this.id(), this.position().containingCell(), Ticks.BOMB_FUSE_TICKS, this.bombRange()); | 336 | return new Bomb(this.id(), this.position().containingCell(), Ticks.BOMB_FUSE_TICKS, this.bombRange()); |
330 | } | 337 | } |
331 | 338 | ||
339 | @Override | ||
340 | public String toString() { | ||
341 | return "Player{" + | ||
342 | "id=" + id + | ||
343 | ", lifeStates=" + lifeStates + | ||
344 | ", directedPos=" + directedPos + | ||
345 | ", maxBombs=" + maxBombs + | ||
346 | ", bombRange=" + bombRange + | ||
347 | '}'; | ||
348 | } | ||
349 | |||
332 | } | 350 | } |