online compiler and debugger for c/c++

code. compile. run. debug. share.
Source Code    Language
#GAME NAME: CRUSTACEAN COMBAT #Leader: Yoong Tsun Chuen #Members: Tan Ethan, Tan Hsien Jien import random import time def battlecode_(): hp=100 canmercy=0 mercy=0 crabhp=80 healcharges=5 print() print("You encounter a wild crab!") print() while mercy==0 or hp<=0 or crabhp<=0: print ("Your turn!") print () print ("Choose an action") print ("1.FIGHT") print ("2.ACT") print ("3.ITEM") print ("4.MERCY") battlechoice=int(input("Type a number: ")) if battlechoice==1: attacknumber=random.randint(1,10) attack=int(input("CHOOSE A NUMBER (1-10): ")) atk=(attacknumber)-attack if atk < 0: atk= -1 if atk==0: attackpower=10 if atk==1: attackpower=9 if atk==2: attackpower=8 if atk==3: attackpower=7 if atk==4: attackpower=6 if atk==5: attackpower=5 if atk==6: attackpower=4 if atk==7: attackpower=3 if atk==8: attackpower=2 if atk==9: attackpower=1 print ("The number was: ") print(attacknumber) crabhp-=attackpower time.sleep(2) print("Damage dealt:") print (attackpower) time.sleep(2) print ("Current crab health:") print(crabhp) time.sleep(2) elif battlechoice==2: print("Choose an act") print("1. Pet") print("2. Crabwalk") print("3. Compliment") actchoice=int(input("")) print() if actchoice==1: if canmercy<=50 or crabhp<=80: print ("You attempted to pet the crab") time.sleep(2) print ("It snaps its claws at you angrily") time.sleep(2) print ("+0 Mercy") print ("Mercy Meter: ") print(canmercy) else: print ("You pet the crab!") canmercy+=50 print ("+50 Mercy") print ("Mercy Meter: ") print(canmercy) elif actchoice==2: print ("You crabwalk!") time.sleep(1) print ("*The crab finds you amusing") canmercy+=5 print ("+5 Mercy") print ("Mercy Meter: ") print(canmercy) elif actchoice==3: print("You compliment the crab!") a=random.randint(1,2) if a==1: print("*It doesn't understand you") print("*But it is flattered anyway") canmercy+=10 time.sleep(1) print("+10 Mercy") print("Mercy Meter: ") print(canmercy) else: print("*The crab is unimpressed") time.sleep(1) print("+0 Mercy") print("Mercy Meter: ") print(canmercy) elif battlechoice==3: print() print("+25 Health Points") print() hp+=25 healcharges-=1 print("Amount of heal charges left:") print(healcharges) time.sleep(1) print("Total health:") print(hp) elif battlechoice==4: if canmercy>=100: mercy=1 else: print("*You attempt to make peace with the crab!") print("*However, it is still agitated") else: print ("What?") print ("*You skip your turn*") print() print ("Crab's turn!") crabchoice=random.randint(1,5) if crabchoice <=4: crabattackpower=random.randint(1,15) print ("The crab attacks!") time.sleep(1) hp-=crabattackpower print ("Damage Taken:") print(crabattackpower) time.sleep(1) print ("Current health:") print(hp) time.sleep(1) else: idle=random.randint(1,3) if idle==1: print ("*The crab is busy cleaning sand off its claws") time.sleep(2) elif idle==2: print ("The crab clacks its claws to the beat of 'Crabrave'") time.sleep(2) elif idle==3: print ("The crab stares at you menacingly") time.sleep(2) print() if crabhp<=0: print("Genocide Ending") time.sleep(3) print("You have killed the crab") time.sleep(2) print("...now what?") elif hp<=0: print("GAME OVER") time.sleep(3) print("You lost to a crab. How pathetic.") else: print("Pacifist Ending") time.sleep(3) print("You have made a new aquatic friend!") def menu_(): print ("Welcome to CRUSTACEAN COMBAT") print ("Choose a number") print ("1. Play") print ("2. Help") menuchoice=int(input("")) print() if menuchoice==1: battlecode_() elif menuchoice==2: print("CHOICES") print("") time.sleep(3) print("1. FIGHT") print("We will choose a number from 1-10 and so will you. The closer the numbers are together, the more damage you will do.") print("") time.sleep(5) print("2. ACT") print("Acts increase the Mercy Meter. When the Mercy Meter reaches 100, you may spare the crab.") print("") time.sleep(5) print("3. ITEM") print("Heals 25 Health. It is just a magical health wand that works 5 times, because why not?") print("") time.sleep(5) print("4. Mercy") print("Spare the crab.") time.sleep(5) print() menu_() else: print("Invalid input") menu_() menu_()

Compiling Program...

Command line arguments:
Standard Input: Interactive Console Text
×

                

                

Program is not being debugged. Click "Debug" button to start program in debug mode.

#FunctionFile:Line
VariableValue
RegisterValue
ExpressionValue