wolfman456
New Coder
HI,
This is my first post, I have read several post at this point and it looks like you are all a very helpful group and I hope you all are able to assist me and that I will be able to help others in the future. The following project is my first attempt to right a project completely from scratch and it has gotten a bit out of hand.
This code started as a choose your own adventure, but I wanted to added some elements based on D&D to it, which has resulted in it spanning three self created modules now. As I don't want to give a wall of code, I will try to do this piece meal but if I am not giving enough information please let me know.
[CODE lang="python" title="gamefuction.py"]from character import Monster, character
import random
from random import randint
import items
#Combat Function
class Die:
# a class to represent rolls
def __init__(self, sides=20):
self.sides = sides
def roll(self):
#roll the dice
return random.randint(1, self.sides)
def PlayerAttack():
roll= Die(20) + items.wBonus
if roll >= character.Monster.ac:
print('You Hit')
items.weapons.damage - Monster.hp
else:
print('You missed')
def MonsterAttack():
roll= Die(20)
if roll >= character.adventurer.ac:
print('You were hit')
character.Monster.damage - character.adventurer.hp
else:
print('That was close')
[/CODE]
Above is the combat function for this game, I have two issues hear, one I don't know how to implement it in to the main game when a player chooses a path that would result in combat. The second having to do with how to pull the right monster or monster, for the combat for that particular round. The final issue is more on the character side so to try and not ask to much at once I will leave this issues for another post, unless someone tells me they need the monster code as that is part of the same module as the character.
I am sorry for any rambling here, and will work to be more concise in the future. Thank you in advance for any assistance.
This is my first post, I have read several post at this point and it looks like you are all a very helpful group and I hope you all are able to assist me and that I will be able to help others in the future. The following project is my first attempt to right a project completely from scratch and it has gotten a bit out of hand.
This code started as a choose your own adventure, but I wanted to added some elements based on D&D to it, which has resulted in it spanning three self created modules now. As I don't want to give a wall of code, I will try to do this piece meal but if I am not giving enough information please let me know.
[CODE lang="python" title="gamefuction.py"]from character import Monster, character
import random
from random import randint
import items
#Combat Function
class Die:
# a class to represent rolls
def __init__(self, sides=20):
self.sides = sides
def roll(self):
#roll the dice
return random.randint(1, self.sides)
def PlayerAttack():
roll= Die(20) + items.wBonus
if roll >= character.Monster.ac:
print('You Hit')
items.weapons.damage - Monster.hp
else:
print('You missed')
def MonsterAttack():
roll= Die(20)
if roll >= character.adventurer.ac:
print('You were hit')
character.Monster.damage - character.adventurer.hp
else:
print('That was close')
[/CODE]
Above is the combat function for this game, I have two issues hear, one I don't know how to implement it in to the main game when a player chooses a path that would result in combat. The second having to do with how to pull the right monster or monster, for the combat for that particular round. The final issue is more on the character side so to try and not ask to much at once I will leave this issues for another post, unless someone tells me they need the monster code as that is part of the same module as the character.
I am sorry for any rambling here, and will work to be more concise in the future. Thank you in advance for any assistance.
Last edited by a moderator: