def insertCharacterArenaInfo(characterId): """插入角色竞技场信息 """ datestr = datetime.date.today() sql = "insert into tb_arena(characterId,recorddate,ranking)\ values(%d,'%s',%d)" % (characterId, datestr, characterId - 1000000) dbpool.executeSQL(sql)
def insertCharacterArenaInfo(characterId): """插入角色竞技场信息 """ datestr = datetime.date.today() sql = "insert into tb_arena(characterId,recorddate,ranking)\ values(%d,'%s',%d)"%(characterId,datestr,characterId-1000000) dbpool.executeSQL(sql)
def insertBattleLog(characterId,tocharacterId,fname,tname,success,rankingChange): """插入战斗日志 """ sql = "insert into tb_arena_log(tiaozhan,yingzhan,\ tiaozhanname,yingzhanname,success,rankingChange)\ values(%d,%d,'%s','%s',%d,%d)"%(characterId,\ tocharacterId,fname,tname,success,rankingChange) dbpool.executeSQL(sql)
def insertBattleLog(characterId, tocharacterId, fname, tname, success, rankingChange): """插入战斗日志 """ sql = "insert into tb_arena_log(tiaozhan,yingzhan,\ tiaozhanname,yingzhanname,success,rankingChange)\ values(%d,%d,'%s','%s',%d,%d)" %(characterId,\ tocharacterId,fname,tname,success,rankingChange) dbpool.executeSQL(sql)
def updateMailInfo(mailId, prop): """更新邮件信息""" sql = util.forEachUpdateProps('tb_mail', prop, {'id': mailId}) count = dbpool.executeSQL(sql) if (count >= 1): return True return False
def updateMailInfo(mailId,prop): """更新邮件信息""" sql = util.forEachUpdateProps('tb_mail',prop, {'id':mailId}) count = dbpool.executeSQL(sql) if(count >= 1): return True return False
def deleteMail(mailId): """删除邮件""" sql = "DELETE FROM tb_mail WHERE id = %d"%mailId count = dbpool.executeSQL(sql) if count >= 1: return True return False
def deleteMail(mailId): """删除邮件""" sql = "DELETE FROM tb_mail WHERE id = %d" % mailId count = dbpool.executeSQL(sql) if count >= 1: return True return False
def UpdateGuYongState(characterId, tid, state): """更新好友的雇用状态 """ sql = "UPDATE `tb_friend` SET guyong = %d WHERE characterId=%d \ AND playerId =%d" % (state, characterId, tid) count = dbpool.executeSQL(sql) if count >= 1: return True return False
def UpdateGuYongState(characterId,tid,state): """更新好友的雇用状态 """ sql = "UPDATE `tb_friend` SET guyong = %d WHERE characterId=%d \ AND playerId =%d"%(state,characterId,tid) count = dbpool.executeSQL(sql) if count >= 1: return True return False
def addMail(title,senderId,sender,receiverId,content,mailtype): """添加邮件""" sql = "INSERT INTO tb_mail(title,senderId,sender,receiverId,\ `type`,content,sendTime) VALUES ('%s',%d,'%s',%d,%d,'%s',\ CURRENT_TIMESTAMP())"%(title,senderId,sender,receiverId,mailtype,content) count = dbpool.executeSQL(sql) if count >= 1: return True return False
def updateCharacterArenaInfo(characterId,props): """更新角色的竞技场信息 """ sqlstr = util.forEachUpdateProps('tb_arena', props,{'characterId':characterId}) count = dbpool.executeSQL(sqlstr) if count >= 1: return True else: return False
def deletePlayerFriend(characterId,friendId): """删除角色好友 @param friendId: int 好友编号 """ sql = 'delete from `tb_friend` where characterId=%d friendId = %d'%(characterId,friendId) count = dbpool.executeSQL(sql) if count>=1: return True return False
def deletePlayerFriend(characterId, friendId): """删除角色好友 @param friendId: int 好友编号 """ sql = 'delete from `tb_friend` where characterId=%d friendId = %d' % ( characterId, friendId) count = dbpool.executeSQL(sql) if count >= 1: return True return False
def updateCharacterArenaInfo(characterId, props): """更新角色的竞技场信息 """ sqlstr = util.forEachUpdateProps('tb_arena', props, {'characterId': characterId}) count = dbpool.executeSQL(sqlstr) if count >= 1: return True else: return False
def addMail(title, senderId, sender, receiverId, content, mailtype): """添加邮件""" sql = "INSERT INTO tb_mail(title,senderId,sender,receiverId,\ `type`,content,sendTime) VALUES ('%s',%d,'%s',%d,%d,'%s',\ CURRENT_TIMESTAMP())" % (title, senderId, sender, receiverId, mailtype, content) count = dbpool.executeSQL(sql) if count >= 1: return True return False
def addGuyongRecord(characterId,rolename,zyname,zyid,bresult,coinbound,huoli): """添加雇用记录 """ sql = "INSERT INTO tb_guyong_record (characterId,\ chaname,zyname,zyid,battleresult,coinbound,huoli) VALUES \ (%d,'%s','%s',%d,%d,%d,%d)"%((characterId,rolename,zyname,\ zyid,bresult,coinbound,huoli)) count = dbpool.executeSQL(sql) if count >= 1: return True return False
def updatePlayerDB(player): """更新角色的数据库信息""" characterId = player.baseInfo.id props = {'level':player.level.getLevel(),'coin':player.finance.getCoin(), 'exp':player.level.getExp(),'hp':player.attribute.getHp()} sqlstr = util.forEachUpdateProps('tb_character',props, {'id':characterId}) count = dbpool.executeSQL(sqlstr) if count >= 1: return True else: log.err(sqlstr) return False
def addGuyongRecord(characterId, rolename, zyname, zyid, bresult, coinbound, huoli): """添加雇用记录 """ sql = "INSERT INTO tb_guyong_record (characterId,\ chaname,zyname,zyid,battleresult,coinbound,huoli) VALUES \ (%d,'%s','%s',%d,%d,%d,%d)" %((characterId,rolename,zyname,\ zyid,bresult,coinbound,huoli)) count = dbpool.executeSQL(sql) if count >= 1: return True return False
def addFriend(characterId, playerId, friendType, isSheildedMail=0): """添加一个好友 @param characterId: int 角色的id @param playerId: int 好友的id @param friendType: int(1,2) 好友的类型 1:好友 2:仇敌 @param isSheildedMail:int 是否屏蔽邮件 0.不屏蔽邮件 1.屏蔽 """ sql = "insert into `tb_friend`(characterId,playerId,friendType,isSheildedMail)\ values(%d,%d,%d,%d)" % (characterId, playerId, friendType, isSheildedMail) count = dbpool.executeSQL(sql) if count >= 1: return True return False
def addFriend(characterId,playerId,friendType,isSheildedMail=0): """添加一个好友 @param characterId: int 角色的id @param playerId: int 好友的id @param friendType: int(1,2) 好友的类型 1:好友 2:仇敌 @param isSheildedMail:int 是否屏蔽邮件 0.不屏蔽邮件 1.屏蔽 """ sql = "insert into `tb_friend`(characterId,playerId,friendType,isSheildedMail)\ values(%d,%d,%d,%d)"%(characterId,playerId,friendType,isSheildedMail) count = dbpool.executeSQL(sql) if count>=1: return True return False
def updatePlayerDB(player): """更新角色的数据库信息""" characterId = player.baseInfo.id props = { 'level': player.level.getLevel(), 'coin': player.finance.getCoin(), 'exp': player.level.getExp(), 'hp': player.attribute.getHp() } sqlstr = util.forEachUpdateProps('tb_character', props, {'id': characterId}) count = dbpool.executeSQL(sqlstr) if count >= 1: return True else: log.err(sqlstr) return False