示例#1
0
class Config(UserDict):

    def __init__(self):
        UserDict.__init__(self)
        self.dict_file = DictFile("./data/profiles/config.mkm")
        temp = self.dict_file.read()
        for key, value in temp.items():
            self[key] = value

    def save(self):
        self.dict_file.change(self)
        self.dict_file.write()
示例#2
0
class Level(UserDict):
    def __init__(self,file):
        """
        Class used to as a placeholder
        for level data
        """
        UserDict.__init__(self)
        self.level = DictFile(os.path.join("./data/levels/",file))
        temp = self.level.read()
        for k,v in temp.items():
            self[k] = v
        self.map = self.get_map(self["map"])

    def get_map(self,file):
        """
        Loads a map (which is saved as an XML file)
        """
        doc = xml.dom.minidom.parse(os.path.join("./data/levels/",file))
        map = []

        for node in doc.getElementsByTagName("tile"):
             ipos = [int(node.getAttribute("tx")), int(node.getAttribute("ty"))]
             pos = [int(node.getAttribute("x")), int(node.getAttribute("y"))]
             n = (ipos[1]/32*9+ipos[0]/32)
             temp = tiles.Tile(pos, (ipos[0], ipos[1], 32, 32), n)
             map.append(temp)

        return map
示例#3
0
class Level(UserDict):
    def __init__(self, file):
        """
        Class used to as a placeholder
        for level data
        """
        UserDict.__init__(self)
        self.level = DictFile(os.path.join("./data/levels/", file))
        temp = self.level.read()
        for k, v in temp.items():
            self[k] = v
        self.map = self.get_map(self["map"])

    def get_map(self, file):
        """
        Loads a map (which is saved as ASCII text)
        and returns a 2D array
        """
        temp = open(os.path.join("./data/levels/", file), "r")
        map = []
        data = temp.read()
        for y in data.split("\n"):
            x = []
            x = y.split("-")
            map.append(x)
        temp.close()
        return map
示例#4
0
 def __init__(self, name):
     """
     Class which serves as a placeholder for
     player's data
     """
     UserDict.__init__(self)
     self.dict_file = DictFile(name)
     temp = self.dict_file.read()
     for key, value in temp.items():
         self[key] = value
     self.buying = False
     self.passed = 0
     self.killed = 0
     self.lpassed = 0
     self.newa = False
     self.lost = False
     self.passed = 0
     self.failed = 0
     self.collected = 0
     self.charges = 0
     self.hasscroll = 0
     self.tw = 0
     self.sp = 0
     self.paused = 1
     self["magicka"] = 0
示例#5
0
 def __init__(self,file):
     """
     Class used to as a placeholder
     for level data
     """
     UserDict.__init__(self)
     self.level = DictFile(os.path.join("./data/levels/",file))
     temp = self.level.read()
     for k,v in temp.items():
         self[k] = v
     self.map = self.get_map(self["map"])
示例#6
0
 def __init__(self, name):
     """
     Class which serves as a placeholder for
     player's data
     """
     UserDict.__init__(self)
     self.dict_file = DictFile(name)
     temp = self.dict_file.read()
     for key, value in temp.items():
         self[key] = value
     self.buying = False
示例#7
0
class Player(UserDict):

    def __init__(self, name):
        """
        Class which serves as a placeholder for
        player's data
        """
        UserDict.__init__(self)
        self.dict_file = DictFile(name)
        temp = self.dict_file.read()
        for key, value in temp.items():
            self[key] = value
        self.buying = False

    def save(self):
        """
        Saves all changes made to the player
        dictionary (self)
        """
        self.dict_file.change(self)
        self.dict_file.write()
示例#8
0
 def __init__(self):
     UserDict.__init__(self)
     self.dict_file = DictFile("./data/profiles/config.mkm")
     temp = self.dict_file.read()
     for key, value in temp.items():
         self[key] = value
示例#9
0
class Player(UserDict):

    def __init__(self, name):
        """
        Class which serves as a placeholder for
        player's data
        """
        UserDict.__init__(self)
        self.dict_file = DictFile(name)
        temp = self.dict_file.read()
        for key, value in temp.items():
            self[key] = value
        self.buying = False
        self.passed = 0
        self.killed = 0
        self.lpassed = 0
        self.newa = False
        self.lost = False
        self.passed = 0
        self.failed = 0
        self.collected = 0
        self.charges = 0
        self.hasscroll = 0
        self.tw = 0
        self.sp = 0
        self.paused = 1
        self["magicka"] = 0

    def debonus(self):
        self["powerup"] = 'None'

    def reset(self):
        self.buying = False
        self.passed = 0
        self.lpassed = False
        self.paused = 1
        self.killed = 0
        self.passed = 0
        self.charges = 0
        self.lost = False
        self.sp = 0
        self.tw = 0
        self.collected = 0
        self.hasscroll = 0
        self["retries"] += self.failed
        self.failed = 0
        self["magicka"] = 0

    def reward(self, prize, prizet):
        if prize == "gold":
            self["gold"]+=prizet
        else:
            pass

    def save(self):
        """
        Saves all changes made to the player
        dictionary (self)
        """
        self.dict_file.change(self)
        self.dict_file.write()