Re: Issues with if and elif statements in 3.3

2013-08-08 Thread Kris Mesenbrink
WOW as if it was something as easy as that,i had been looking for  awhile on 
what i was doing wrong. as it seems i just don't know my way around if 
statements at all, thank a bunch for this. makes everything else i have been 
code work

thanks again
-- 
http://mail.python.org/mailman/listinfo/python-list


back with more issues

2013-08-11 Thread Kris Mesenbrink
import random

def player():
hp = 10
speed = 5
attack = random.randint(0,5)

def monster ():
hp = 10
speed = 4

def battle(player):
print ("a wild mosnter appered!")
print ("would you like to battle?")
answer = input()
if answer == ("yes"):
return player(attack)
else:
print("nope")


battle()


++

this was a variation on a code that you guys already had helped me with,in the 
long run i plan to incorporate them together but as it stand i don't know how 
to call a specific variable from one function (attack from player) to use in 
another function (battle). what i want is to be able to use the variables from 
both player and monster to use in battle. any idea's?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: back with more issues

2013-08-11 Thread Kris Mesenbrink
the idea was to store variables for later use, but you are correct i don't 
understand functions or if that is even the best way to do it. i guess i'd want 
to be able to call the HP and ATTACK variables of player for when the battle 
gets called. i would then use the variables in battle to figure out who would 
win. is there a better way to store these variables in the functions? i also 
read somewhere about classes but that makes even less sense to me.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: back with more issues

2013-08-11 Thread Kris Mesenbrink
darn i was hoping i could put off learning classes for a bit, but it seems that 
is not the case. i have tested it a bit and it seems to be working correctly 
now.


import random

class player():
hp = 10
speed = 5
attack = random.randint(0,5)

print (player.attack)

+++

i know it's not nearly as complicated as your examples but it seems to work. 
the self part of it always eluded me and continues to do so. and just so you 
know im learning through codecademy.com , it's based on python 2.7 and im 
trying to code in 3.3. but thanks for your help again and classes are starting 
(i think) to make some sort of sense.i'll have to reread both replies over and 
over again but it looks like a lot of useful info is there. but is the example 
i posted sorta right? i know i left the self part out but i think im on the 
right track.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: back with more issues

2013-08-12 Thread Kris Mesenbrink
import random

class player():
hp = 10
attack = random.randint(0,5)

class monster():
hp = 10
attack = random.randint(0,4)


def battle():
print ("a wild mosnter appered!")
print ("would you like to battle?")
answer = input()
if answer == ("yes"):
while monster.hp >=0:
print ("you do", player.attack, "damage")
monster.hp -= player.attack
print (monster.hp)
elif answer == ("no"):
print ("you run away")
else:
print("you stand there")



battle()




Hello! just wanted to show you guys how its coming together, im starting to 
understand it abit more (hopefully it's right) at the moment it seems to only 
roll the attack once and uses that value but that's another issue all together 
that i bother you with (yet anyway).

thanks again guys you are awesome
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: back with more issues

2013-08-12 Thread Kris Mesenbrink
the Classes and __init__ still don't make much sense actually. i have tried and 
tried again to make it generate numbers between 0 and 5 in a while statement 
but it just doesn't seem to be working. 

import random


class Player():
hp = 10
def __init__(self, patt):
self.att = random.randint(0,5)



while Player.hp == 10:
print (Player.__init__)

atm it seems to be printing "" 
over and over again, i don't mind the repetition but from my understanding 
there should be numbers there. numbers that change. crazy frustrating that i 
just don't understand how this works.
-- 
http://mail.python.org/mailman/listinfo/python-list