Skip to content

Commit

Permalink
fix validation of counting of ammo
Browse files Browse the repository at this point in the history
  • Loading branch information
mochoy committed Jan 1, 2018
1 parent 0f0e404 commit 2455a6f
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions nerf-ammo-counter.ino
Original file line number Diff line number Diff line change
Expand Up @@ -87,9 +87,9 @@ void initDisplayAmmo () {
void countAmmo () {
triggerBtn.read(); //read trigger button
if (triggerBtn.wasPressed()) { //trigger button pressed
if (maxAmmo != 0 && currentAmmo < 99) { //make sure that the ammo is less than 99 so it doesnt overflow the display and not in count-up mode
if (maxAmmo != 0 && currentAmmo < 99 && currentAmmo > 0) { //make sure that the ammo is less than 99 so it doesnt overflow the display and not in count-up mode
currentAmmo--; //increment ammo
} else if (maxAmmo == 0 && currentAmmo > 0) { //make sure that the ammo is more than 0 so no negative numbers are displayed and in count-up mode
} else if (maxAmmo == 0 && currentAmmo < 99) { //make sure that the ammo is more than 0 so no negative numbers are displayed and in count-up mode
currentAmmo++; //decrement ammo
}
initDisplayAmmo(); //display ammo
Expand Down

0 comments on commit 2455a6f

Please sign in to comment.