0930ac8855b75aa7c11605d2c389c3a5

here is the task, I don't want anyone to do the coding for me. I just would really love if I got a starting point on how to begin this code. thank you. oh and this is in python program.

Hello Zahra!

I would make a Game class that holds the characters. Then I would make the characters that generates the attributes. The attributes are generated by rolling a dice.

Something like this:

# python 2 code


import random
class Dice(object):
    __slots__=("sides",)
    def __init__(self,sides):
        self.sides=sides
    def roll(self):
        return random.randint(1,self.sides)

class Charachter(object):
    def __init__(self, name):
        self.name=name
        self.attributes={"strength":0, "skill":0}
        self.reset_attributes()

    def reset_attributes(self):
        for k in self.attributes.keys():
             self.attributes[k]=10+Dice(12).roll()//Dice(4).roll()

    def __str__(self):
         ret=""
         for k,v in self.attributes.iteritems():
              ret+="%s : %s\n" % (k,v)
         return ret

class Game(object):
    def __init__(self):
        self.charachters=dict()

    def generate_charachters(self):
        self.charachters["Bilbo"]=Charachter("Bilbo")

if __name__ == "__main__":
    g=Game()
    g.generate_charachters()
    for ch,attrs in g.charachters.iteritems():
         print ch
         print attrs

Next I would make a method in the charachter class that outputs the character data in some standardized way, possible a dictionary containing name and a dictionary of attributes. Then I would make the game class generate the two characters and save the data of the characters into a file.

The next move is to load the characters from this file...

This question has already been answered. Start a new discussion instead.