Skip to content

Commit

Permalink
Update Player.scala
Browse files Browse the repository at this point in the history
Review fixes
  • Loading branch information
onegrx authored Oct 9, 2016
1 parent 4ecf0e5 commit 50ef7de
Showing 1 changed file with 3 additions and 12 deletions.
15 changes: 3 additions & 12 deletions src/main/scala/lab/project/game/Player.scala
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ object Player extends ShootsBolts {
state.neededKeys {
case ("hit", true) => shieldsDrop()
case ("crash", true) => shieldsDrop(5)
// (1 to 5).foreach(_ => shieldsDrop())
}
}
}
Expand Down Expand Up @@ -66,19 +65,11 @@ object Player extends ShootsBolts {
}

/**
* If player has shields it drops them by 1,
* If player has shields it drops them by the amount of damage,
* otherwise player dies and it's game over.
*/
private def shieldsDrop(): Unit = {
if (shields > 0) {
shields -= 1
} else {
alive = false
}
}

private def shieldsDrop(damage: Int): Unit = {
if (shields > damage) {
private def shieldsDrop(damage: Int = 1): Unit = {
if (shields >= damage) {
shields -= damage
} else {
alive = false
Expand Down

0 comments on commit 50ef7de

Please sign in to comment.