[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

Re: [pygame] Text-Based RPG



Kris Schnee wrote:

What's different about the tavern versus a regular room? Most likely it's just some variables that you might as well put into a single Room class. For instance, if a room can be light or dark, you could give the Room class a "light" variable by putting in the __init__ function: self.light = options.get("light",True) ## Which makes True the default value


Or:

class Room(object):
    name = 'Room'
    light = 1


class Tavern(Room):
    name = 'Tavern'
    light = 0


Then, at startup time, store the type of the room in the data, so you know which variable to instantiate at startup time.

It's a matter of preference, but I don't like stuffing data into variables on __init__ unless I have to.