Beispiel #1
0
    def __init__(self, filename):
        self.name = filename
        self.title = ""
        self.tile = ["base.png", 0, 0]
        self.powerRange = 1
        self.damage = 1
        rawdata = data.loadText(os.path.join("powers", filename))
        for line in rawdata:
            splitLine = line.split("=", 1)
            if len(splitLine) < 2:
                data.warn("could not understand: " + line)
                continue
            splitLine[0] = splitLine[0].strip().lower()
            splitLine[1] = splitLine[1].strip()
            if splitLine[0] == "tile":
                tilePointer = splitLine[1].split(" ", 2)
                if len(tilePointer) < 3:
                    data.warn("not enough information: " + line)
                    continue
                self.tile[0] = tilePointer[0].strip()
                try:
                    self.tile[1] = int(tilePointer[1])
                    self.tile[2] = int(tilePointer[2])
                except ValueError:
                    data.warn("xy coords not a number: " + line)
                    self.tile[1] = 0
                    self.tile[2] = 0
                    continue
            elif splitLine[0] == "name":
                self.title = splitLine[1]
            elif splitLine[0] == "range":
                try:
                    self.powerRange = int(splitLine[1])
                except ValueError:
                    data.warn("power range not a number: " + line)
                    self.powerRange = 1
                    continue
            elif splitLine[0] == "damage":
                try:
                    self.damage = int(splitLine[1])
                except ValueError:
                    data.warn("damage not a number: " + line)
                    self.damage = 1
                    continue
            else:
                data.warn("I don't understand: " + line)

        data.trace("    name: " + self.name)
        data.trace("    title: " + self.title)
        data.trace("    tile: " + repr(self.tile))
        data.trace("    range: " + repr(self.powerRange))
        data.trace("    damage: " + repr(self.damage))
Beispiel #2
0
    def __init__(self, filename):
        self.name = filename
        self.walkable = True
        self.picture = ["base.png", 0, 0]
        self.canEat = False
        self.armor = 0
        self.replace = "replacethis.txt"
        self.symbol = "_"
        rawdata = data.loadText(os.path.join("tiletypes", filename))
        for line in rawdata:
            splitLine = line.split("=", 1)
            if len(splitLine) < 2:
                data.warn("could not understand: " + line)
                continue
            splitLine[0] = splitLine[0].strip().lower()
            splitLine[1] = splitLine[1].strip()
            if splitLine[0] == "walkable":
                self.walkable = data.strToBool(splitLine[1])
                if self.walkable == None:
                    self.walkable = False
                    data.warn("walkable not true or false: " + line)
            elif splitLine[0] == "tile":
                tilePointer = splitLine[1].split(" ", 2)
                if len(tilePointer) < 3:
                    data.warn("not enough information: " + line)
                    continue
                self.picture[0] = tilePointer[0].strip()
                try:
                    self.picture[1] = int(tilePointer[1])
                    self.picture[2] = int(tilePointer[2])
                except ValueError:
                    data.warn("xy coords not a number: " + line)
                    continue
            elif splitLine[0] == "caneat":
                self.canEat = data.strToBool(splitLine[1])
                if self.canEat == None:
                    self.canEat = False
                    data.warn("canEat not true or false: " + line)
            elif splitLine[0] == "armor":
                self.armor = data.strToInt(splitLine[1])
                if self.armor == None:
                    self.armor = 0
                    data.warn("armor not a number: " + line)
            elif splitLine[0] == "replace":
                self.replace = splitLine[1]
            elif splitLine[0] == "symbol":
                if len(splitLine[1]) != g.symbolLength:
                    data.warn("symbol wrong length: " + line)
                    continue
                self.symbol = splitLine[1]
            else:
                data.warn("I don't understand: " + line)

        data.trace("    name: " + self.name)
        data.trace("    walkable: " + str(self.walkable))
        data.trace("    picture: " + repr(self.picture))
        data.trace("    canEat: " + str(self.canEat))
        data.trace("    armor: " + str(self.armor))
        data.trace("    replace: " + self.replace)
Beispiel #3
0
    def __init__(self, filename):
        self.name = filename
        self.picture = ["base.png", 0, 0]
        self.statType = "melee"
        self.statStrength = 1
        self.symbol = "?"
        self.levelRange = [1, 1]
        rawdata = data.loadText(os.path.join("creatures", filename))
        for line in rawdata:
            splitLine = line.split("=", 1)
            if len(splitLine) < 2:
                data.warn("could not understand: " + line)
                continue
            splitLine[0] = splitLine[0].strip().lower()
            splitLine[1] = splitLine[1].strip()
            if splitLine[0] == "tile":
                tilePointer = splitLine[1].split(" ", 2)
                if len(tilePointer) < 3:
                    data.warn("not enough information: " + line)
                    continue
                self.picture[0] = tilePointer[0].strip()
                try:
                    self.picture[1] = int(tilePointer[1])
                    self.picture[2] = int(tilePointer[2])
                except ValueError:
                    data.warn("xy coords not a number: " + line)
                    self.picture[1] = 0
                    self.picture[2] = 0
                    continue
            elif splitLine[0] == "symbol":
                if len(splitLine[1]) != g.symbolLength:
                    data.warn("symbol wrong length: " + line)
                    continue
                self.symbol = splitLine[1]
            elif splitLine[0] == "stats":
                statPointer = splitLine[1].split(" ", 1)
                if len(statPointer) < 2:
                    data.warn("not enough information: " + line)
                    continue
                self.statType = statPointer[0]
                if not self.statType in statTypes:
                    data.warn("stat type does not exist: " + line)
                    continue
                try:
                    self.statStrength = int(statPointer[1])
                except ValueError:
                    data.warn("stat strength not a number: " + line)
                    self.statStrength = 1
                    continue
            elif splitLine[0] == "level":
                statPointer = splitLine[1].split("-", 1)
                if len(statPointer) < 2:
                    data.warn("not enough information: " + line)
                    continue
                try:
                    self.levelRange[0] = int(statPointer[0])
                    self.levelRange[1] = int(statPointer[1])
                except ValueError:
                    data.warn("level range not a number: " + line)

            else:
                data.warn("I don't understand: " + line)

        data.trace("    name: " + self.name)
        data.trace("    picture: " + repr(self.picture))
Beispiel #4
0
	def __init__(self, filename):
		self.name = filename
		self.walkable = True
		self.picture = ["base.png", 0, 0]
		self.canEat = False
		self.armor = 0
		self.replace = "replacethis.txt"
		self.symbol="_"
		rawdata = data.loadText(os.path.join("tiletypes",filename))
		for line in rawdata:
			splitLine = line.split("=", 1)
			if len(splitLine) < 2:
				data.warn("could not understand: "+line)
				continue
			splitLine[0] = splitLine[0].strip().lower()
			splitLine[1] = splitLine[1].strip()
			if splitLine[0] == "walkable":
				self.walkable = data.strToBool(splitLine[1])
				if self.walkable == None:
					self.walkable = False
					data.warn("walkable not true or false: "+line)
			elif splitLine[0] == "tile":
				tilePointer = splitLine[1].split(" ", 2)
				if len(tilePointer) < 3:
					data.warn("not enough information: "+line)
					continue
				self.picture[0] = tilePointer[0].strip()
				try:
					self.picture[1] = int(tilePointer[1])
					self.picture[2] = int(tilePointer[2])
				except ValueError:
					data.warn("xy coords not a number: "+line)
					continue
			elif splitLine[0] == "caneat":
				self.canEat = data.strToBool(splitLine[1])
				if self.canEat == None:
					self.canEat = False
					data.warn("canEat not true or false: "+line)
			elif splitLine[0] == "armor":
				self.armor = data.strToInt(splitLine[1])
				if self.armor == None:
					self.armor = 0
					data.warn("armor not a number: "+line)
			elif splitLine[0] == "replace":
				self.replace = splitLine[1]
			elif splitLine[0] == "symbol":
				if len(splitLine[1]) != g.symbolLength:
					data.warn("symbol wrong length: "+line)
					continue
				self.symbol=splitLine[1]
			else:
				data.warn("I don't understand: "+line)
				
		data.trace("    name: "+self.name)
		data.trace("    walkable: "+str(self.walkable))
		data.trace("    picture: "+repr(self.picture))
		data.trace("    canEat: "+str(self.canEat))
		data.trace("    armor: "+str(self.armor))
		data.trace("    replace: "+self.replace)
Beispiel #5
0
	def __init__(self, filename):
		self.name = filename
		self.picture = ["base.png", 0, 0]
		self.statType = "melee"
		self.statStrength = 1
		self.symbol="?"
		self.levelRange = [1, 1]
		rawdata = data.loadText(os.path.join("creatures",filename))
		for line in rawdata:
			splitLine = line.split("=", 1)
			if len(splitLine) < 2:
				data.warn("could not understand: "+line)
				continue
			splitLine[0] = splitLine[0].strip().lower()
			splitLine[1] = splitLine[1].strip()
			if splitLine[0] == "tile":
				tilePointer = splitLine[1].split(" ", 2)
				if len(tilePointer) < 3:
					data.warn("not enough information: "+line)
					continue
				self.picture[0] = tilePointer[0].strip()
				try:
					self.picture[1] = int(tilePointer[1])
					self.picture[2] = int(tilePointer[2])
				except ValueError:
					data.warn("xy coords not a number: "+line)
					self.picture[1] = 0
					self.picture[2] = 0
					continue
			elif splitLine[0] == "symbol":
				if len(splitLine[1]) != g.symbolLength:
					data.warn("symbol wrong length: "+line)
					continue
				self.symbol=splitLine[1]
			elif splitLine[0] == "stats":
				statPointer = splitLine[1].split(" ", 1)
				if len(statPointer) < 2:
					data.warn("not enough information: "+line)
					continue
				self.statType = statPointer[0]
				if not self.statType in statTypes:
					data.warn("stat type does not exist: "+line)
					continue
				try:
					self.statStrength = int(statPointer[1])
				except ValueError:
					data.warn("stat strength not a number: "+line)
					self.statStrength = 1
					continue
			elif splitLine[0] == "level":
				statPointer = splitLine[1].split("-", 1)
				if len(statPointer) < 2:
					data.warn("not enough information: "+line)
					continue
				try:
					self.levelRange[0] = int(statPointer[0])
					self.levelRange[1] = int(statPointer[1])
				except ValueError:
					data.warn("level range not a number: "+line)
				
			else:
				data.warn("I don't understand: "+line)
				
		data.trace("    name: "+self.name)
		data.trace("    picture: "+repr(self.picture))
Beispiel #6
0
	def __init__(self, filename):
		self.name = filename
		self.title = ""
		self.tile = ["base.png", 0, 0]
		self.powerRange = 1
		self.damage = 1
		rawdata = data.loadText(os.path.join("powers",filename))
		for line in rawdata:
			splitLine = line.split("=", 1)
			if len(splitLine) < 2:
				data.warn("could not understand: "+line)
				continue
			splitLine[0] = splitLine[0].strip().lower()
			splitLine[1] = splitLine[1].strip()
			if splitLine[0] == "tile":
				tilePointer = splitLine[1].split(" ", 2)
				if len(tilePointer) < 3:
					data.warn("not enough information: "+line)
					continue
				self.tile[0] = tilePointer[0].strip()
				try:
					self.tile[1] = int(tilePointer[1])
					self.tile[2] = int(tilePointer[2])
				except ValueError:
					data.warn("xy coords not a number: "+line)
					self.tile[1] = 0
					self.tile[2] = 0
					continue
			elif splitLine[0] == "name":
				self.title=splitLine[1]
			elif splitLine[0] == "range":
				try:
					self.powerRange = int(splitLine[1])
				except ValueError:
					data.warn("power range not a number: "+line)
					self.powerRange = 1
					continue
			elif splitLine[0] == "damage":
				try:
					self.damage = int(splitLine[1])
				except ValueError:
					data.warn("damage not a number: "+line)
					self.damage = 1
					continue
			else:
				data.warn("I don't understand: "+line)
				
		data.trace("    name: "+self.name)
		data.trace("    title: "+self.title)
		data.trace("    tile: "+repr(self.tile))
		data.trace("    range: "+repr(self.powerRange))
		data.trace("    damage: "+repr(self.damage))