MISS_PROBABILITY=5defhit?rand(1..100)>MISS_PROBABILITYenddefall_zombies_dead_message(killed)"You shot all #{killed} zombies."enddefgot_eaten_message(killed)"You shot #{killed} zombies before being eaten: overwhelmed."enddefran_out_of_ammo_message(killed)"You shot #{killed} zombies before being eaten: ran out of ammo."enddefzombie_shootout(n,r,a)ran_out_of_ammo_message(0)ifa<nzombies_killed=0(r*2).timesdoreturnall_zombies_dead_message(zombies_killed)ifn==zombies_killedreturnran_out_of_ammo_message(zombies_killed)ifa==0a-=1ifhit?zombies_killed+=1endendreturngot_eaten_message(zombies_killed)ifzombies_killed<nendputszombie_shootout(3,10,10)putszombie_shootout(100,8,200)putszombie_shootout(50,10,8)
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Discussion on: Daily Challenge #192 - Can you Survive the Zombies?
For further actions, you may consider blocking this person and/or reporting abuse