Exemplo n.º 1
0
	def loadInventory(this):
		try:
			fr = open(this.name + "_inventory.txt", "r")
		except IOError as e:
			print 'Error: file %s not found' % (this.name + "_inventory.txt")
			return False
		del this.inventory[:]
		# Load all the items in the inventory
		lines = fr.readlines()
		for i in range(len(lines)):
			# The inventory file should follow the following format
			# <ItemID> <equipped>
			id,equipped = lines[i].split()
			
			itm = item.getItem(int(id))
			itm.equipped = bool(int(equipped))
			if itm.equipped:
				this.player.weapon = itm
			
			this.inventory.append(itm)
		
		# Set rest of inventory to null; 32 is max inventory size
		for i in range(len(this.inventory), 32):
			this.inventory.append(item.nullitem)
		
		return True
Exemplo n.º 2
0
Arquivo: db.py Projeto: annProg/learn
def updateDB(hostid, applicationid, cmdbObj):
	db = init_DB()
	data = item.getItem(hostid, applicationid)
	for i in data:
		itemid = i['itemid']
		db[itemid] = {}
		db[itemid]['objid'] = cmdbObj['objid']
		db[itemid]['email'] = cmdbObj['alertemail']
		db[itemid]['phone'] = cmdbObj['alertphone']
		db[itemid]['httptestid'] = cmdbObj['httptestid']
		#print(itemid + ": " + str(db[itemid]))
	with open(file_db, 'w') as f:
		json.dump(db, f)
Exemplo n.º 3
0
def updateDB(hostid, applicationid, cmdbObj):
    db = init_DB()
    data = item.getItem(hostid, applicationid)
    for i in data:
        itemid = i['itemid']
        db[itemid] = {}
        db[itemid]['objid'] = cmdbObj['objid']
        db[itemid]['email'] = cmdbObj['alertemail']
        db[itemid]['phone'] = cmdbObj['alertphone']
        db[itemid]['httptestid'] = cmdbObj['httptestid']
        #print(itemid + ": " + str(db[itemid]))
    with open(file_db, 'w') as f:
        json.dump(db, f)
Exemplo n.º 4
0
                else:
                    print("You missed your punch!")
            elif command == "slam":
                if random.randint(1, 3) == 1:
                    print("You successfully slammed the enemy!")
                    tile.enemy.health -= 10
                else:
                    print(
                        "You missed the slam and took damage from hitting the floor!"
                    )
            elif command.startswith("use"):
                _, i = command.split(" ", 1)
                if user.hasItem(i):
                    print("You used a {}".format(i))
                    user.use(i)
                    tile.enemy.health -= item.getItem(i).damage
                else:
                    print("You dont have {}!".format(i))
            if tile.enemy.isAlive():
                user.health -= tile.enemy.damage
            elif tile.enemy.isDead():
                print(
                    "the enemy is now dead. If you want, you can search further."
                )

    elif command == "fight cultist":
        random.seed(datetime.now())

        while tile.cultist.isAlive() and user.isAlive():
            print("You have {} health.".format(user.health))
            print("The Cultist has {} health".format(tile.cultist.health))