This actually happens to be my first Misc Forums post other than replies! Well anyway, I haven't been using Python 3.1 for awhile- I've been working on Adobe Flash- and I'm sure that I'm just a bit rusty, but I need some help with a simple game I made. When you try to shield, you get an error message- something to do with the enemy's 'AI'. The cheat code, by the way, was included purely for the reason that I'm lazy with doing enough battles to test the features. Can someone fix this?
##Importing##
import random
##########
##Initiating Variables and Such Items##
dmg = 0# dmg can also refer to choices such as menu selection and many other varying possibilites
edmg = 0
weap = 0
minDmg = 0
maxDmg = 0
aim = 0
hp = 35
ehp = 35
mp = 3
shieldOn = 1
eshieldOn = 1
gold = 0
level = 0
win = 0
loop = 1
##########
input('''Hello and Welcome to the Arena\n(Press the Enter Key to Continue)''')
print('''Your Fight has begun!\n\n\t\tEngarde!\n''')
while loop == 1:
print('''You have ''', hp, '''HP.\nYou have ''', mp, '''MP.''')
dmg = input('''>>> ''')
if dmg == '''attack''':
dmg = random.randint(0, (10 + aim))
if dmg >= 3:
dmg = random.randint((1 + minDmg), (5 + maxDmg))
ehp -= (dmg + level + weap) // eshieldOn
eshieldOn = 1
print('''You have attacked.''')
print('''Enemy HP:\n\t''', ehp)
else:
print('''You have missed.''')
elif dmg == '''magic''':
dmg = random.randint(0, 10)
if mp > 0:
if dmg >= 3:
dmg = random.randint(4, 9)
ehp -= (dmg + level + weap) // eshieldOn
mp -= 1
eshieldOn = 1
print('''You have used magic''')
print('''Enemy HP:\n\t''', ehp)
else:
print('''You have missed''')
mp -= 1
elif mp == 0:
print('''You do not have enough MP to use this ability.''')
elif dmg == '''shield''':
print('''You have raised your shield.''')
shieldOn = 2
elif dmg == '''riches''':
print('''Cheat Code detected''')
print('''You have earned 100 Gold!''')
gold += 100
else:
print('''That is not a valid option. Your character will now pass.''')
pass
if ehp <= 0:
print('''Congradulations! You have won!''')
win = 1
gold += random.randint(0, 11)
print('''You now have ''', gold, ''' Gold!''')
edmg = random.randint(0, 10)
# Here we set the enemy choice: attack, magic, or shield
if win != 1:
if edmg < 7 and not dmg < 0:
dmg = random.randint(0, (10 + level // 2))
if dmg >= (5 - level):
hp -= 2 // shieldOn
print('''Your opponent has attacked.''')
shieldOn = 1
else:
print('''Your opponent has missed.''')
elif edmg < 9 and edmg > 6:
dmg = random.randint(0, (10 + level // 2))
if dmg >= (5 - level) and not dmg < 0:
hp -= 4 // shieldOn
print('''Your opponent has used magic.''')
else:
print('''Your enemy has missed''')
elif edmg > 8:
print('''Your opponent has raised their shield.''')
eshield = 2
else:
print('''A bug in this program has been found. Please report the event to *name removed*.''')
if hp <= 0:
print('''You have lost!''')
loop = 0
win = 0
##Ending Battle, Beginning Upgrade Stage##
if win == 1:
print('''\n\t\tWelcome to the shop! Feel free to look around.''')
dmg = input('''
Diamond: +1 to average damage dealt, 75 Gold\n
Balance: +1 to minimum damage, 60 Gold\n
Weightened Blade: +1 to maximum damage, -1 to minimum damage, 45 Gold\n
Longer Blade: +1 to maximum damage, -1 to accuracy, 45 Gold\n
Swift Attack: +1 to accuracy, 50\n''')
if dmg.lower() == '''diamond''':
if gold >= 75:
weap += 1
gold -= 75
else:
print('''You do not have enough Gold for that upgrade.''')
elif dmg.lower() == '''balance''':
if gold >= 60:
minDmg += 1
gold -= 60
else:
print('''You do not have enough Gold for that upgrade.''')
elif dmg.lower() == '''weightened blade''':
if gold >= 45:
maxDmg += 1
gold -= 45
if minDmg > 0:
minDmg -= 1
elif dmg.lower() == '''longer blade''':
if gold >= 45:
maxDmg += 1
aim += 1
else:
print('''You do not have enough Gold for that upgrade.''')
elif dmg.lower() == '''swift attack''':
if gold >= 50:
aim -= 1
else:
print('''You do not have enough Gold for that upgrade.''')
level += 1
ehp = 35 + (level * 5)
hp = 35
mp = 3
win = 0
print('''You have entered Level ''', level + 1)
So there's my code.
Regardless of whether you can help me with that last bit I just mentioned, I look forward to some help.
Sorry if some of the indents or stuff is off. I typed this from the Python file I had open because I was having trouble with copying and pasting it.
PS. I bought this book on Python (that's why I have 3.1 instead of 2.5.7 or whatever) that taught me everything I know, but I'm not understanding the part about writing files. Can someone help me with this? And also, is it possible to hide the files you write, because I don't want people to be able to hack the game by just opening the file and adding about ten zeros to their Gold.
Edit: Using the efforts of everyone who helped with this (actually through just reviewing the shop feature. Sorry, guys.) I have found my mistake. I forgot to turn 'win' back into 0 after the shop. Anyway, I have now fixed the bug. Still, I have no idea how to use the Debugger tool that was introduced to me in this thread, and I am still curious about reading and writing text files, so I will not close the topic (yet)! Thanks for the help and support, everyone!
Edit: This program has undergone some Bug Killing including some important changes, such as having to PAY for shop items (they used to be free). Anyone who uses this should update now.
Edit: The possibility to miss has been added to this game, along with new shop items which change the how likely it is to miss. Thanks again for the support!
Edit: There is a glitch when blocking! Someone please help!
New game, written in Python 3.1.4. For Msodude's Pokémon Game Made in Python thread.
import random
#Setting global variables and such items
loop = 1
level = 1
win = 0
move = ''' '''
#Setting variables and such items for Bulbasaur (player):
hp = 200
armr = 10
sparmr = 10
atk = 5
spatk = 10
speed = 0
pp1 = 20
pp2 = 40
pp3 = 10
pp4 = 15
gold = 0
#Setting variables and such items for Dark Bulbasaur (enemy):
ehp = (190 + level)
earmr = 10
esparmr = 5
eatk = 10
espatk = 10
espeed = 0
def setVar():
#Setting global variables and such items:
loop = 1
level = 1
win = 0
move = ''' '''
#Setting variables and such items for Bulbasaur (player):
hp = 200
armr = 10
sparmr = 10
atk = 5
spatk = 10
speed = 0
pp1 = 20
pp2 = 40
pp3 = 10
pp4 = 15
gold = 0
#Setting variables and such items for Dark Bulbasaur (enemy):
ehp = (190 + level)
earmr = 10
esparmr = 5
eatk = 10
espatk = 10
espeed = 0
global speed, pp1, pp2, pp3, pp4, spatk, ehp, eatk
#The function that runs the game:
def playerTurn():
global hp, speed, pp1, pp2, pp3, pp4, spatk, ehp, eatk
move = input('''What will Bulbasaur do?\n\n>>> ''')
move = move.lower()
playerMove(move)
#The function that processes the player's chosen move:
def playerMove(move):
global hp, speed, pp1, pp2, pp3, pp4, spatk, ehp, eatk
if move == '''tackle''':
if pp1 > 0:
print('''Bulbasaur has used Tackle!''')
atk = random.randint(0, 100)
if atk < (90 + speed):
ehp -= (20 + atk - earmr)
print('''Dark Bulbasaur was hurt!\n''')
else:
print('''Bulbasaur missed!''')
pp1 -= 1
else:
print('''Bulbasaur does not have enough PP to perform Tackle.\n''')
playerTurn()
elif move == '''growl''':
if pp2 > 0:
print('''Bulbasaur has used Growl!''')
atk = random.randint(0, 100)
if atk < (100 + speed):
eatk -= 5
print('''Dark Bulbasaur was weakened\n''')
else:
print('''Bulbasaur missed!\n''')
pp2 -= 1
else:
print('''Bulbasaur does not have enough PP to perform Growl.\n''')
playerTurn()
elif move == '''leech seed''':
if pp3 > 0:
print('''Bulbasaur used Leech Seed!''')
atk = random.randint(0, 100)
if atk > (90 + speed):
ehp -= (10 + spatk - esparmr)
hp += (10 + spatk - esparmr)
print('''Dark Bulbasaur was drained!\n''')
else:
print('''Bulbasaur missed!\n''')
pp3 -= 1
else:
print('''Bulbasaur does not have enough PP to perform Leech Seed.\n''')
playerTurn()
elif move == '''vine whip''':
if pp4 > 0:
print('''Bulbasaur used Vine Whip!''')
atk = random.randint(0, 100)
if atk > (100 + speed):
ehp -= (20 + spatk - esparmr)
print('''Dark Bulbasaur was hurt!\n''')
else:
print('''Bulbasaur missed!\n''')
else:
print('''Bulbasaur does not have enough PP to perform Vine Whip.\n''')
playerTurn()
pp4 -= 1
else:
print('''That is not a recognized move. Please chose from the following moves:\n\t
Tackle\n\t
Growl\n\t
Leech Seed\n\t
Vine Whip\n
If these commands do not work, check the spelling.\n''')
playerTurn()
#The function that controls the Dark Bulbasaur's move:
def enemyMove():
global hp, speed, pp1, pp2, pp3, pp4, spatk, ehp, eatk
atk = random.randint(0, 100)
if atk <= 25:
print('''Dark Bulbasaur used Tackle!''')
atk = random.randint(0, 100)
if atk <= (20 + espeed):
hp -= (35 + eatk - armr)
print('''Bulbasaur was hurt!\n''')
else:
print('''Dark Bulbasaur missed!\n''')
elif atk > 25 and atk <= 50:
print('''Dark Bulbasaur used Growl!''')
atk = random.randint(0, 100)
if atk <= (100 + espeed):
atk -= 5
print('''Bulbasaur was weakened!\n''')
else:
print('''Dark Bulbasaur missed!\n''')
elif atk > 50 and atk <= 75:
print('''Dark Bulbasaur used Leech Seed!''')
atk = random.randint(0, 100)
if atk <= (90 + espeed):
hp -= (10 + espatk - sparmr)
print('''Bulbasaur was drained!\n''')
ehp += (10 + espatk)
else:
print('''Dark Bulbasaur missed!\n''')
elif atk > 75:
print('''Dark Bulbasaur used Vine Whip!''')
atk = random.randint(0, 100)
if atk <= (100 + speed):
hp -= (20 + espatk - sparmr)
print('''Bulbasaur was hurt!\n''')
else:
print('''Dark Bulbasaur missed!\n''')
else:
print('''There is a glitch in the program. Please report the event to *name removed*.''')
loop = 0
#The function that reports the HP and PP of the Bulbasaur and Dark Bulbasaur:
def reportStats():
global hp, speed, pp1, pp2, pp3, pp4, spatk, ehp, eatk
print('''Bulbasaur has ''', hp, ''' HP!\n\nBulbasaur has ''', pp1, ''' PP for Tackle!\nBulbasaur has ''', pp2, ''' for PP for Growl!\nBulbasaur has ''', pp3, ''' PP for Leech Seed!\nBulbasaur has ''', pp4, ''' PP for Vine Whip!\n''')
print('''Dark Bulbasaur has ''', ehp, ''' HP!\n''')
#The function that checks to see whether someone is KO'ed:
def reportDeath():
global hp, speed, pp1, pp2, pp3, pp4, spatk, ehp, eatk
if hp <= 0:
print('''Bulbasaur has been KO'ed!''')
loop = 0
elif ehp <= 0:
print('''Dark Bulbasaur has been KO'ed!''')
atk = random.randint(0, 11)
gold += atk
win = 1
#The function that runs the shop feature:
def shop():
global hp, speed, pp1, pp2, pp3, pp4, spatk, ehp, eatk
print('''Welcome to the shop! Feel free to look around!''')
print('''\n
\tAttack Kit 1: +1 to ATK, 25 Gold\n
\tAttack Kit 2: +5 to ATK, 125 Gold\n
\tAttack Kit 3: +10 to ATK, 250 Gold\n
\tSp Attack Kit: +1 to Sp. ATK, 25 Gold\n
\tSp Attack Kit: +5 to Sp. ATK, 125 Gold\n
\tSp Attack Kit: +10 to Sp. ATK, 250 Gold\n
\tDefense Kit 1: +1 to DEF, 25 Gold\n
\tDefense Kit 2: +5 to DEF, 125 Gold\n
\tDefense Kit 3: +10 to DEF, 250 Gold\n
\tSp Defense Kit 1: +1 to Sp. DEF, 25 Gold\n
\tSp Defense Kit 2: +5 to Sp. DEF, 125 Gold\n
\tSp Defense Kit 3: +10 to Sp. DEF, 250 Gold\n
\tSpeed Kit 1: +1 to Speed, 25 Gold\n
\tSpeed Kit 2: +5 to Speed, 125 Gold\n
\tSpeed Kit 3: +10 to Speed, 250\n
\tQuit: Exits the shop\n
\nWhat will Bulbasaur buy?''')
atk = input('''>>> ''')
atk = atk.lower()
if atk == '''attack kit 1''':
if gold >= 25:
atk += 1
gold -= 25
print('''Bulbasaur bought the Attack Kit 1.\nBulbasaur now has ''', gold, ''' Gold.''')
shop()
else:
print('''Bulbasaur does not have enough Gold to buy that.''')
shop()
elif atk == '''attack kit 2''':
if gold >= 125:
atk += 5
gold -= 125
print('''Bulbasaur bought the Attack Kit 2.\nBulbasaur now has ''', gold, ''' Gold.''')
shop()
else:
print('''Bulbasaur does not have enough Gold to buy that.''')
shop()
elif atk == '''attack kit 3''':
if gold >= 250:
atk += 10
gold -= 250
print('''Bulbasaur bought the Attack Kit 3.\nBulbasaur now has ''', gold, ''' Gold.''')
shop()
else:
print('''Bulbasaur does not have enough Gold to buy that.''')
shop()
elif atk == '''sp attack kit 1''':
if gold >= 25:
spatk += 1
gold -= 25
print('''Bulbasaur bought the Sp Attack Kit 1.\nBulbasaur now has ''', gold, ''' Gold''')
shop()
else:
print('''Bulbasaur does not have enough Gold to buy that.''')
shop()
elif atk == '''sp attack kit 2''':
if gold >= 125:
spatk += 5
gold -= 125
print('''Bulbasaur bought the Sp Attack Kit 2.\nBulbasaur now has ''', gold, ''' Gold.''')
shop()
else:
print('''Bulbasaur does not have enough Gold to buy that.''')
shop()
elif atk == '''sp attack kit 3''':
if gold >= 250:
spatk += 10
gold -= 250
print('''Bulbasaur bought the Sp Attack Kit 3.\nBulbasaur now has ''', gold, ''' Gold.''')
shop()
else:
print('''Bulbasaur does not have enough Gold to buy that.''')
shop()
elif atk == '''defense kit 1''':
if gold >= 25:
armr += 1
gold -= 25
print('''Bulbasaur bought the Defense Kit 1.\nBulbasaur now has ''', gold, ''' Gold.''')
shop()
else:
print('''Bulbasaur does not have enough Gold to buy that.''')
shop()
elif atk == '''defense kit 2''':
if gold >= 125:
armr += 5
gold -= 125
print('''Bulbasaur bought the Defense Kit 2.\nBulbasaur now has ''', gold, ''' Gold.''')
shop()
else:
print('''Bulbasaur does not have enough Gold to buy that.''')
shop()
elif atk == '''defense kit 3''':
if gold >= 250:
armr += 10
gold -= 250
print('''Bulbasaur bought the Defense Kit 3.\nBulbasaur now has ''', gold, ''' Gold.''')
shop()
else:
print('''Bulbasaur does not have enough Gold to buy that.''')
shop()
elif atk == '''sp defense kit 1''':
if gold >= 25:
sparmr += 1
gold -= 25
print('''Bulbasaur bought the Sp Defense Kit 1.\nBulbasaur now has ''', gold, ''' Gold.''')
shop()
else:
print('''Bulbasaur does not have enough Gold to buy that.''')
shop()
elif atk == '''sp defense kit 2''':
if gold >= 125:
sparmr += 5
gold -= 125
print('''Bulbasaur bought the Sp Defense Kit 2.\nBulbasaur now has ''', gold, ''' Gold.''')
shop()
else:
print('''Bulbasaur does not have enough Gold to buy that.''')
shop()
elif atk == '''sp defense kit 3''':
if gold >= 250:
sparmr += 10
gold -= 250
print('''Bulbasaur bought the Sp Defense Kit 3.\nBulbasaur now has ''', gold, ''' Gold.''')
shop()
else:
print('''Bulbasaur does not have enough Gold to buy that.''')
shop()
elif atk == '''speed kit 1''':
if gold >= 25:
speed += 1
gold -= 25
print('''Bulbasaur bought the Speed Kit 1.\nBulbasaur now has ''', gold, ''' Gold.''')
shop()
else:
print('''Bulbasaur does not have enough Gold to buy that.''')
shop()
elif atk == '''speed kit 2''':
if gold >= 125:
speed += 5
gold -= 125
print('''Bulbasaur bought the Speed Kit 2.\nBulbasaur now has ''', gold, ''' Gold.''')
shop()
else:
print('''Bulbasaur does not have enough Gold to buy that.''')
shop()
elif atk == '''speed kit 3''':
if gold >= 250:
speed += 10
gold -= 250
print('''Bulbasaur bought the Speed Kit 3.\nBulbasaur now has ''', gold, ''' Gold.''')
shop()
else:
print('''Bulbasaur does not have enough Gold to buy that.''')
shop()
elif atk == '''quit''':
win = 0
level += 10
print('''You have reached Level ''', level / 10, '''.\n''')
setVar()
#The function that runs the entire game- funny how simple you can make code with 'def' functions:
def runGame():
global hp, speed, pp1, pp2, pp3, pp4, spatk, ehp, eatk
if win == 0:
playerTurn()
enemyMove()
reportStats()
elif win == 1:
shop()
#The part which causes the whole game to go into effect- funny how it's so short and yet so important:
while loop == 1:
global hp, speed, pp1, pp2, pp3, pp4, spatk, ehp, eatk
runGame()
Last edited by maxskywalker (2011-07-24 21:02:15)
Offline
The level math thingy looks good.
Is there any command in there that's supposed to stop the shop?
Offline
Forgive the noob question, but what is the *.lower() method? Is it something built in to Python?
Also, my guess is that at the end of the battle, you set loop to 0. That will terminate your entire battle loop, won't it? I'm not sure why it's going back to the store at first glance though. Let me look through it in the debugger and see if I come up with anything.
Edit: Um, do you have another Python file somewhere you're importing? You don't actually define minDmg and maxDmg anywhere...
Last edited by Harakou (2011-07-12 10:28:22)
Offline
Idunno. I'm not very good at Python, but I can do some simple math programs. Sorry.
Offline
Harakou wrote:
Forgive the noob question, but what is the *.lower() method? Is it something built in to Python?
Also, my guess is that at the end of the battle, you set loop to 0. That will terminate your entire battle loop, won't it? I'm not sure why it's going back to the store at first glance though. Let me look through it in the debugger and see if I come up with anything.
Edit: Um, do you have another Python file somewhere you're importing? You don't actually define minDmg and maxDmg anywhere...
lower() makes sure there are no uppercase letters in the string. It's a rather useful method.
Offline
MaxtheWeirdo wrote:
Harakou wrote:
Forgive the noob question, but what is the *.lower() method? Is it something built in to Python?
Also, my guess is that at the end of the battle, you set loop to 0. That will terminate your entire battle loop, won't it? I'm not sure why it's going back to the store at first glance though. Let me look through it in the debugger and see if I come up with anything.
Edit: Um, do you have another Python file somewhere you're importing? You don't actually define minDmg and maxDmg anywhere...lower() makes sure there are no uppercase letters in the string. It's a rather useful method.
Oh, thanks. I'll keep that in mind for if I ever need it.
Offline
Harakou wrote:
Forgive the noob question, but what is the *.lower() method? Is it something built in to Python?
Also, my guess is that at the end of the battle, you set loop to 0. That will terminate your entire battle loop, won't it? I'm not sure why it's going back to the store at first glance though. Let me look through it in the debugger and see if I come up with anything.
Edit: Um, do you have another Python file somewhere you're importing? You don't actually define minDmg and maxDmg anywhere...
Sorry. I forgot to type that part. I actually lost the file, so I remade it but it was lacking a few things, still (like minDmg and maxDmg). I didn't mean to terminate the loop when you win. And there's a debugger? Oh, you mean that one. It only checks for syntax errors.
Offline
maxskywalker wrote:
Harakou wrote:
Forgive the noob question, but what is the *.lower() method? Is it something built in to Python?
Also, my guess is that at the end of the battle, you set loop to 0. That will terminate your entire battle loop, won't it? I'm not sure why it's going back to the store at first glance though. Let me look through it in the debugger and see if I come up with anything.
Edit: Um, do you have another Python file somewhere you're importing? You don't actually define minDmg and maxDmg anywhere...Sorry. I forgot to type that part. I actually lost the file, so I remade it but it was lacking a few things, still (like minDmg and maxDmg). I didn't mean to terminate the loop when you win. And there's a debugger? Oh, you mean that one. It only checks for syntax errors.
Open up the Python shell in IDLE, go to Debug > Debugger, then now you've enabled debug mode, open up your program.py file from the File menu. You can view variables, step from line to line, etc.
Offline
Harakou wrote:
maxskywalker wrote:
Harakou wrote:
Forgive the noob question, but what is the *.lower() method? Is it something built in to Python?
Also, my guess is that at the end of the battle, you set loop to 0. That will terminate your entire battle loop, won't it? I'm not sure why it's going back to the store at first glance though. Let me look through it in the debugger and see if I come up with anything.
Edit: Um, do you have another Python file somewhere you're importing? You don't actually define minDmg and maxDmg anywhere...Sorry. I forgot to type that part. I actually lost the file, so I remade it but it was lacking a few things, still (like minDmg and maxDmg). I didn't mean to terminate the loop when you win. And there's a debugger? Oh, you mean that one. It only checks for syntax errors.
Open up the Python shell in IDLE, go to Debug > Debugger, then now you've enabled debug mode, open up your program.py file from the File menu. You can view variables, step from line to line, etc.
Oh. Cool. Not the Ctrl+X (or Cmd+X on a mac) one.
Edit: I can't figure out how to use the Debugger.
Last edited by maxskywalker (2011-07-12 17:14:02)
Offline
Python seems so complicated..
Last edited by spongebob123 (2011-07-12 18:39:03)
Offline
The shop works on Python 3.2.1 on my Mac. I have make a Pokémon version of this, BTW.
http://scratch.mit.edu/forums/viewtopic.php?id=68432
Last edited by msdosdude (2011-07-13 09:28:38)
Offline
maxskywalker wrote:
Harakou wrote:
maxskywalker wrote:
Sorry. I forgot to type that part. I actually lost the file, so I remade it but it was lacking a few things, still (like minDmg and maxDmg). I didn't mean to terminate the loop when you win. And there's a debugger? Oh, you mean that one. It only checks for syntax errors.Open up the Python shell in IDLE, go to Debug > Debugger, then now you've enabled debug mode, open up your program.py file from the File menu. You can view variables, step from line to line, etc.
Oh. Cool. Not the Ctrl+X (or Cmd+X on a mac) one.
Edit: I can't figure out how to use the Debugger.
How to open it, or how to actually use it?
Offline
Well anyway, I made a quick tutorial on basic use of Python's debugger. You can find it here. (The video is unlisted, so no worries about inappropriate comments!)
Edit: Looks like Scratch automatically sends you to Youtube repeat now, so I guess just make sure you watch in HD so you can see what I'm doing.
Last edited by Harakou (2011-07-12 21:08:46)
Offline
spongebob123 wrote:
http://t3.gstatic.com/images?q=tbn:ANd9 … 6Oq8dV5R5X
Python seems so complicated..
And they say Python is the most fun and easy to use serious language. D:
Last edited by PW132 (2011-07-12 23:37:06)

Offline
spongebob123 wrote:
http://t3.gstatic.com/images?q=tbn:ANd9 … 6Oq8dV5R5X
Python seems so complicated..
Not really. Once you start to understand it, it's really simple. Like learning English for the first time.
Offline
Harakou wrote:
Well anyway, I made a quick tutorial on basic use of Python's debugger. You can find it here. (The video is unlisted, so no worries about inappropriate comments!)
Edit: Looks like Scratch automatically sends you to Youtube repeat now, so I guess just make sure you watch in HD so you can see what I'm doing.![]()
Okay, thanks! This should be really useful!
Offline
msdosdude wrote:
Code:
The shop works on Python 3.2.1 on my Mac. I have make a Pokémon version of this, BTW: [quote=Maxskywalker]##Importing## import random ########## ##Initiating Variables and Such Items## dmg = 0# dmg can also refer to choices such as menu selection and many other varying possibilites edmg = 0 weap = 0 minDmg = 0 maxDmg = 0 hp = 90 ehp = 45 mp = 3 shieldOn = 1 eshieldOn = 1 gold = 0 level = 1 win = 0 loop = 1 ########## input('''Hello and Welcome to the Pokémon Arena, Raichu!\n(Press the Enter Key to Continue)''') print('''Your Fight has begun!\n\n\t\tEngarde!\n''') while loop == 1: print('''You have ''', hp, '''HP.\nYou have ''', mp, '''MP.''') dmg = input('''>>> ''') if dmg == '''attack''': dmg = random.randint((1 + minDmg), (5 + maxDmg)) ehp -= (dmg + level + weap) // eshieldOn eshieldOn = 1 print('''You have attacked.''') print('''Snivy's HP:\n\t''', ehp) elif dmg == '''magic''': if mp > 0: dmg = random.randint(4, 9) ehp -= (dmg + level + weap) // eshieldOn mp -= 1 eshieldOn = 1 print('''You have used magic''') print('''Snivy's HP:\n\t''', ehp) elif mp == 0: print('''You do not have enough MP to use this ability.''') elif dmg == '''shield''': print('''You have raised your shield.''') shieldOn = 2 elif dmg == '''riches''': print('''Cheat Code detected''') print('''You have earned 100 Gold!''') gold += 100 else: print('''That is not a valid option. Your character will now pass.''') pass if ehp <= 0: print('''Congradulations! You have won!''') win = 1 elif hp <= 0: print('''You have lost!''') loop = 0 win = 0 edmg = random.randint(0, 10)# Here we set the enemy choice: attack, magic, or shield if loop == 1: if edmg < 7: hp -= 2 // shieldOn print('''Snivy has attacked.''') shieldOn = 1 elif edmg < 9 and edmg > 6: hp -= 4 // shieldOn print('''Snivy has used magic.''') elif edmg > 8: print('''Snivy has raised their shield.''') eshield = 2 else: print('''A bug in this program has been found. Please report the event to *name removed*.''') ##Ending Battle, Beginning Upgrade Stage## if win == 1: print('''\n\t\tWelcome to the shop! Feel free to look around.''') dmg = input(''' Diamond: +1 to average damage dealt, 75 Gold\n Balance: +1 to minimum damage, 60 Gold\n Weightened Blade: +1 to maximum damage, -1 to minimum damage, 45\n''') if dmg.lower() == '''diamond''': if gold >= 75: weap += 1 else: print('''You do not have enough Gold for that upgrade.''') elif dmg.lower() == '''balance''': if gold >= 60: minDmg += 1 else: print('''You do not have enough Gold for that upgrade.''') elif dmg.lower() == '''weightened blade''': if gold >= 45: maxDmg += 1 if minDmg > 0: minDmg -= 1 level += 1 ehp = 35 + (level * 5) hp = 90 mp = 3 win = 0
Yeah, I know. I just fixed it. I saw the Pokémon version that you made, by the way. I kinda wish that you would have waited, actually, because I'm working making chances for attacks to miss and save games. Well, you can still update your Pokémon Arena yourself.
Offline
maxskywalker wrote:
msdosdude wrote:
Code:
The shop works on Python 3.2.1 on my Mac. I have make a Pokémon version of this, BTW: [quote=Maxskywalker]##Importing## import random ########## ##Initiating Variables and Such Items## dmg = 0# dmg can also refer to choices such as menu selection and many other varying possibilites edmg = 0 weap = 0 minDmg = 0 maxDmg = 0 hp = 90 ehp = 45 mp = 3 shieldOn = 1 eshieldOn = 1 gold = 0 level = 1 win = 0 loop = 1 ########## input('''Hello and Welcome to the Pokémon Arena, Raichu!\n(Press the Enter Key to Continue)''') print('''Your Fight has begun!\n\n\t\tEngarde!\n''') while loop == 1: print('''You have ''', hp, '''HP.\nYou have ''', mp, '''MP.''') dmg = input('''>>> ''') if dmg == '''attack''': dmg = random.randint((1 + minDmg), (5 + maxDmg)) ehp -= (dmg + level + weap) // eshieldOn eshieldOn = 1 print('''You have attacked.''') print('''Snivy's HP:\n\t''', ehp) elif dmg == '''magic''': if mp > 0: dmg = random.randint(4, 9) ehp -= (dmg + level + weap) // eshieldOn mp -= 1 eshieldOn = 1 print('''You have used magic''') print('''Snivy's HP:\n\t''', ehp) elif mp == 0: print('''You do not have enough MP to use this ability.''') elif dmg == '''shield''': print('''You have raised your shield.''') shieldOn = 2 elif dmg == '''riches''': print('''Cheat Code detected''') print('''You have earned 100 Gold!''') gold += 100 else: print('''That is not a valid option. Your character will now pass.''') pass if ehp <= 0: print('''Congradulations! You have won!''') win = 1 elif hp <= 0: print('''You have lost!''') loop = 0 win = 0 edmg = random.randint(0, 10)# Here we set the enemy choice: attack, magic, or shield if loop == 1: if edmg < 7: hp -= 2 // shieldOn print('''Snivy has attacked.''') shieldOn = 1 elif edmg < 9 and edmg > 6: hp -= 4 // shieldOn print('''Snivy has used magic.''') elif edmg > 8: print('''Snivy has raised their shield.''') eshield = 2 else: print('''A bug in this program has been found. Please report the event to *name removed*.''') ##Ending Battle, Beginning Upgrade Stage## if win == 1: print('''\n\t\tWelcome to the shop! Feel free to look around.''') dmg = input(''' Diamond: +1 to average damage dealt, 75 Gold\n Balance: +1 to minimum damage, 60 Gold\n Weightened Blade: +1 to maximum damage, -1 to minimum damage, 45\n''') if dmg.lower() == '''diamond''': if gold >= 75: weap += 1 else: print('''You do not have enough Gold for that upgrade.''') elif dmg.lower() == '''balance''': if gold >= 60: minDmg += 1 else: print('''You do not have enough Gold for that upgrade.''') elif dmg.lower() == '''weightened blade''': if gold >= 45: maxDmg += 1 if minDmg > 0: minDmg -= 1 level += 1 ehp = 35 + (level * 5) hp = 90 mp = 3 win = 0Yeah, I know. I just fixed it. I saw the Pokémon version that you made, by the way. I kinda wish that you would have waited, actually, because I'm working making chances for attacks to miss and save games. Well, you can still update your Pokémon Arena yourself.
I will try to keep track with your code.
Offline
PW132 wrote:
spongebob123 wrote:
http://t3.gstatic.com/images?q=tbn:ANd9 … 6Oq8dV5R5X
Python seems so complicated..And they say Python is the most fun and easy to use serious language. D:
It is, unless you count BASIC.
Offline
msdosdude wrote:
maxskywalker wrote:
msdosdude wrote:
Yeah, I know. I just fixed it. I saw the Pokémon version that you made, by the way. I kinda wish that you would have waited, actually, because I'm working making chances for attacks to miss and save games. Well, you can still update your Pokémon Arena yourself.
I will try to keep track with your code. :)
Just Bookmark/Favorite this thread and check it every once in a while. Like a week minimum.
Offline
Harakou wrote:
PW132 wrote:
spongebob123 wrote:
http://t3.gstatic.com/images?q=tbn:ANd9 … 6Oq8dV5R5X
Python seems so complicated..And they say Python is the most fun and easy to use serious language. D:
It is, unless you count BASIC.
![]()
BASIC doesn't really work for large and complex games. Give me a version of my game in BASIC, and I might reconsider that remark.
Offline
maxskywalker wrote:
Harakou wrote:
PW132 wrote:
And they say Python is the most fun and easy to use serious language. D:It is, unless you count BASIC.
![]()
BASIC doesn't really work for large and complex games. Give me a version of my game in BASIC, and I might reconsider that remark.
Which is why I don't really think it's work counting. But that game in BASIC? Psh, that would be easy.
Offline
Harakou wrote:
maxskywalker wrote:
Harakou wrote:
It is, unless you count BASIC. :PBASIC doesn't really work for large and complex games. Give me a version of my game in BASIC, and I might reconsider that remark.
Which is why I don't really think it's work counting. But that game in BASIC? Psh, that would be easy. :P
Really? Easy? Then can you type it out for me? It would be nice to be able to effortlessly (or as close as you can get when you're using code) make simple games. My school math book had a little BASIC code, but it was just math functions.
Offline
maxskywalker wrote:
Harakou wrote:
maxskywalker wrote:
BASIC doesn't really work for large and complex games. Give me a version of my game in BASIC, and I might reconsider that remark.Which is why I don't really think it's work counting. But that game in BASIC? Psh, that would be easy.
![]()
Really? Easy? Then can you type it out for me? It would be nice to be able to effortlessly (or as close as you can get when you're using code) make simple games. My school math book had a little BASIC code, but it was just math functions.
Well, all the functions you used are pretty universal. It wouldn't be that hard to replicate using a form of BASIC. If I still had Small BASIC installed, I'd make a quick conversion, but I don't, and I'm not particularly familiar with the syntax since it's been so long since I last used it.
Offline