davidtcalabrese / minnetonka

a project to practice collaboration on github
0 stars 1 forks source link

create Class "Player" #15

Closed davidtcalabrese closed 3 years ago

davidtcalabrese commented 3 years ago

The Player Class will instantiate a new player for each game. This will be used to track state. Can also add methods to player - not sure what yet. I'm a little rusty with this stuff.

davidtcalabrese commented 3 years ago

The dictionary idea to track state would be easier but it's not really how it should be done.

I'm going to need to do some research here. I've really forgotten how to work with objects in a class-based language.

so far I have a defined a class with a single attribute (tipsy) and a single method (check_state). when check_state is called it will return the status off all the attributes in case we end up with a bunch and the player gets confused and needs reminding.

We can add a list attirbute to class to store inventory and another method to check that. However, I really am struggling with the class basics so I thought we'd just start with a very simple class. It would look something like this:

class Player:

    # init method
    def __init__(self, tipsy):
        self.tipsy = tipsy

    def check_state(self):
        return f'''
            tipsy: {self.tipsy}
        '''

Then in start() we would instantiate a new player for each game which would look something like this

player_object = Player(false)

Except I get an error here (" unresolved reference 'false' ").

I think maybe boolean class attributes are handled differently.

This one may take awhile but I think it's probably the ideal way for managing state in our game and would open up other opportunities down the road as well.