def processFile(filename,old_md5,rowid,url):
	# with open(filename,'rb') as f:
	# 	md5_info = md5(f)
	# replaced by zipuploads method
	zfile = zopen(filename)
	memfile = io.BytesIO()
	memfile.write(zfile.read())
	zfile.close()
	md5_info = md5(memfile)
	save = savefile(memfile.getvalue(), True)
	player_info = playerInfo(save)
	farm_info = getFarmInfo(save)
	try:
		print(md5_info,old_md5)
		assert md5_info == old_md5
	except AssertionError:
		return False
		print(filename,'failed md5')
	columns = []
	values = []
	for key in player_info.keys():
		if type(player_info[key]) == list:
			for i,item in enumerate(player_info[key]):
				columns.append(key.replace(' ','_') + unicode(i))
				values.append(unicode(item))
		elif type(player_info[key]) == dict:
			for subkey in player_info[key]:
				if type(player_info[key][subkey]) == dict:
					for subsubkey in player_info[key][subkey]:
						columns.append((key+subkey+subsubkey).replace(' ','_'))
						values.append((player_info[key][subkey][subsubkey]))
				else:
					columns.append((key + subkey).replace(' ','_'))
					values.append(unicode(player_info[key][subkey]))
		else:
			columns.append(key)
			values.append(unicode(player_info[key]))
	columns.append('farm_info')
	values.append(json.dumps(farm_info))
	columns.append('failed_processing')
	values.append(None)

	colstring = ''
	for c in columns:
		colstring += c+', '
	colstring = colstring[:-2]
	questionmarks = ((sqlesc+',')*len(values))[:-1]
	try:
		connection = connect_db()
		cur = connection.cursor()
		cur.execute('UPDATE playerinfo SET ('+colstring+') = ('+questionmarks+') WHERE id='+sqlesc,(tuple(values+[rowid])))
		cur.execute('INSERT INTO todo (task, playerid) VALUES ('+sqlesc+','+sqlesc+')',('process_image',rowid))
		connection.commit()
		connection.close()
		return True
	except (sqlite3.OperationalError, psycopg2.ProgrammingError) as e:
		cur.execute('INSERT INTO errors (ip, time, notes) VALUES ('+sqlesc+','+sqlesc+','+sqlesc+')',('reprocessEntry.py', time.time(),unicode(e)+' '+unicode([columns,values])))
		connection.commit()
		return False
def main():
    filelocation = './saves/Sketchy_116441313'
    player = playerInfo(filelocation)
    player_img = generateAvatar(player)
    portrait_info = json.loads(player['portrait_info'])
    generateFamilyPortrait(player_img, portrait_info['partner'],
                           portrait_info['cat'],
                           portrait_info['children']).save('test.png')
Beispiel #3
0
def file_uploaded(inputfile):
	memfile = io.BytesIO()
	inputfile.save(memfile)
	md5_info = md5(memfile)
	try:
		player_info = playerInfo(memfile.getvalue(),True)
	except defusedxml.common.EntitiesForbidden:
		error = "I don't think that's very funny"
		return {'type':'render','target':'index.html','parameters':{"error":error}}
		return render_template("index.html", error=error,blogposts=get_blogposts(5), recents=get_recents(), processtime=round(time.time()-start_time,5))
	except IOError:
		error = "Savegame failed sanity check (if you think this is in error please let us know)"
		g.db = connect_db()
		cur = g.db.cursor()
		cur.execute('INSERT INTO errors (ip, time, notes) VALUES ('+app.sqlesc+','+app.sqlesc+','+app.sqlesc+')',(request.environ['REMOTE_ADDR'],time.time(),'failed sanity check '+str(secure_filename(inputfile.filename))))
		g.db.commit()
		g.db.close()
		return {'type':'render','target':'index.html','parameters':{"error":error}}
		return render_template("index.html", error=error,blogposts=get_blogposts(5), recents=get_recents(), processtime=round(time.time()-start_time,5))
	except AttributeError as e:
		error = "Not valid save file - did you select file 'SaveGameInfo' instead of 'playername_number'?"
		return {'type':'render','target':'index.html','parameters':{"error":error}}
		return render_template("index.html", error=error,blogposts=get_blogposts(5), recents=get_recents(), processtime=round(time.time()-start_time,5))
	except ParseError as e:
		error = "Not well-formed xml"
		return {'type':'render','target':'index.html','parameters':{"error":error}}
		return render_template("index.html", error=error,blogposts=get_blogposts(5),recents=get_recents(), processtime=round(time.time()-start_time,5))
	dupe = is_duplicate(md5_info,player_info)
	if dupe != False:
		session[dupe[0]] = md5_info
		session[dupe[0]+'del_token'] = dupe[1]
		return {'type':'redirect','target':'display_data','parameters':{"url":dupe[0]}}
		return redirect(url_for('display_data',url=dupe[0]))
	else:
		farm_info = getFarmInfo(memfile.getvalue(),True)
		outcome, del_token, rowid, error = insert_info(player_info,farm_info,md5_info)
		if outcome != False:
			filename = os.path.join(app.config['UPLOAD_FOLDER'],outcome)
			with open(filename,'wb') as f:
				f.write(memfile.getvalue())
			series_id = add_to_series(rowid,player_info['uniqueIDForThisGame'],player_info['name'],player_info['farmName'])
			owner_id = get_logged_in_user()
			g.db = connect_db()
			cur = g.db.cursor()
			cur.execute('UPDATE playerinfo SET savefileLocation='+app.sqlesc+', series_id='+app.sqlesc+', owner_id='+app.sqlesc+' WHERE url='+app.sqlesc+';',(filename,series_id,owner_id,outcome))
			g.db.commit()
			g.db.close()
		process_queue()
		memfile.close()
	if outcome != False:
		session[outcome] = md5_info
		session[outcome+'del_token'] = del_token
		return {'type':'redirect','target':'display_data','parameters':{"url":outcome}}
		return redirect(url_for('display_data',url=outcome))
Beispiel #4
0
def processFile(filename,old_md5,rowid,url):
	with open(filename,'rb') as f:
		md5_info = md5(f)
	player_info = playerInfo(filename)
	farm_info = getFarmInfo(filename)
	try:
		assert md5_info == old_md5
	except AssertionError:
		return False
		print filename,'failed md5'
	columns = []
	values = []
	for key in player_info.keys():
		if type(player_info[key]) == list:
			for i,item in enumerate(player_info[key]):
				columns.append(key.replace(' ','_') + str(i))
				values.append(str(item))
		elif type(player_info[key]) == dict:
			for subkey in player_info[key]:
				if type(player_info[key][subkey]) == dict:
					for subsubkey in player_info[key][subkey]:
						columns.append((key+subkey+subsubkey).replace(' ','_'))
						values.append((player_info[key][subkey][subsubkey]))
				else:
					columns.append((key + subkey).replace(' ','_'))
					values.append(str(player_info[key][subkey]))
		else:
			columns.append(key)
			values.append(str(player_info[key]))
	columns.append('farm_info')
	values.append(json.dumps(farm_info))
	columns.append('failed_processing')
	values.append(None)

	colstring = ''
	for c in columns:
		colstring += c+', '
	colstring = colstring[:-2]
	questionmarks = ((sqlesc+',')*len(values))[:-1]
	try:
		connection = connect_db()
		cur = connection.cursor()
		cur.execute('UPDATE playerinfo SET ('+colstring+') = ('+questionmarks+') WHERE id='+sqlesc,(tuple(values+[rowid])))
		cur.execute('INSERT INTO todo (task, playerid) VALUES ('+sqlesc+','+sqlesc+')',('process_image',rowid))
		connection.commit()
		connection.close()
		return True
	except (sqlite3.OperationalError, psycopg2.ProgrammingError) as e:
		cur.execute('INSERT INTO errors (ip, time, notes) VALUES ('+sqlesc+','+sqlesc+','+sqlesc+')',('reprocessEntry.py', time.time(),str(e)+' '+str([columns,values])))
		connection.commit()
		return False
Beispiel #5
0
def main():
	from playerInfo import playerInfo
	# player = playerInfo('./save/Crono_116230451')
	player = playerInfo('./saves/Sketchy_116441313')
	generateAvatar(player).save('test.png')
def main():
	filelocation = './saves/Sketchy_116441313'
	player = playerInfo(filelocation)
	player_img = generateAvatar(player)
	portrait_info = json.loads(player['portrait_info'])
	generateFamilyPortrait(player_img, portrait_info['partner'], portrait_info['cat'], portrait_info['children']).save('test.png')
Beispiel #7
0
def main():
    from playerInfo import playerInfo
    # player = playerInfo('./save/Crono_116230451')
    player = playerInfo('./saves/Sketchy_116441313')
    generateAvatar(player).save('test.png')
Beispiel #8
0
    def move(self, parameter):
        parameter[0].position += parameter[1]

        if parameter[0].position >= 100:
            pass

        targetPlayer = parameter[0]
        nowTile = self.gameInfo.gameMap.map[parameter[0].position]

        if nowTile.isOpen is False:
            nowTile.isOpen = True

        addMana = nowTile.mana

        for i in targetPlayer.state:
            if i[0] == 'overLoad':
                addMana = 0

        targetPlayer.mana += addMana
        if targetPlayer.mana > 5:
            targetPlayer.mana = 5

        for i in self.gameInfo.player:
            if i.position == targetPlayer.position:
                if i.playerNum != targetPlayer.playerNum:
                    self.messageManager.send("battle", (targetPlayer, i))
                    return

        if nowTile.state[0] == 'move':
            if nowTile.state[1] == 'push':
                self.move((targetPlayer, nowTile.state[2]))
            elif nowTile.state[1] == 'portal':
                self.move(
                    (targetPlayer, nowTile.state[2] - targetPlayer.position))
            elif nowTile.state[1] == 'player':
                pass

        elif nowTile.state[0] == 'battle':
            battleTarget = playerInfo.playerInfo('monster', '', 9)
            if nowTile.state[1] == 'wolf':
                battleTarget.playerType = 'wolf'
                battleTarget.hp = 30
                battleTarget.battleDice = 6
                battleTarget.battleDiceNum = 1
            elif nowTile.state[1] == 'dragon':
                battleTarget.playerType = 'dragon'
                battleTarget.hp = 100
                battleTarget.battleDice = 6
                battleTarget.battleDiceNum = 2
            elif nowTile.state[1] == 'bee':
                battleTarget.playerType = 'bee'
                battleTarget.hp = 20
                battleTarget.battleDice = 4
                battleTarget.battleDiceNum = 1
            elif nowTile.state[1] == 'ice':
                battleTarget.playerType = 'ice'
                battleTarget.hp = 20
                battleTarget.battleDice = 4
                battleTarget.battleDiceNum = 2
            elif nowTile.state[1] == 'boom':
                battleTarget.playerType = 'boom'
                battleTarget.hp = 1
                battleTarget.battleDice = 6
                battleTarget.battleDiceNum = 1
            elif nowTile.state[1] == 'tiger':
                battleTarget.playerType = 'tiger'
                battleTarget.hp = 40
                battleTarget.battleDice = 12
                battleTarget.battleDiceNum = 1
            self.messageManager.send('battle', (targetPlayer, battleTarget))
        elif nowTile.state[0] == 'heal':
            targetPlayer.hp += nowTile.state[2]
            if targetPlayer.hp > 100:
                targetPlayer.hp = 100
        elif nowTile.state[0] == 'trap':
            if nowTile.state[1] == 'poison':
                targetPlayer.state.append(['poison', 3, nowTile.state[2]])
            elif nowTile.state[1] == 'overLoad':
                targetPlayer.state.append(['overLoad', 1])
                targetPlayer.mana = 0
            elif nowTile.state[1] == 'atomic':
                targetPlayer.state.append(['atomic', 2])
Beispiel #9
0
pygame.init()
fpsClock = pygame.time.Clock()

windowSurfaceObj = pygame.display.set_mode((640, 480))
pygame.display.set_caption('test')


def quit(i):
    sys.exit()


mapMaker = mapMaker.mapMaker()

gameMap = mapMaker.create()
player = []
player.append(playerInfo.playerInfo('wizard', 'pc', 0))
player.append(playerInfo.playerInfo('wizard', 'pc', 1))
turn = turnInfo.turnInfo(player[0])

gameInfo = gameInfo.gameInfo(gameMap, player, turn)

messageManager = messageManager.messageManager()

messageManager.listen('quit', quit)

gameManager = gameManager.gameManager(messageManager, gameInfo)
turnManager = turnManager.turnManager(messageManager, gameInfo)
battleManager = battleManager.battleManager(messageManager, gameInfo)

screenList = []