def savePartner(self): for partner in self.partners: tableName = "player_partner" fields = [] fields.append('level') fields.append('hadBeenUnlocked') fields.append('hp') fields.append('sleep') fields.append('order_num') values = [] values.append(partner.partner_level) values.append(partner.hadBeenUnlocked) values.append(partner.hp) values.append(partner.sleep) values.append(partner.order) condition = "player_id = '%s' and partner_id = '%s'"%(self.player_id,partner.partner_id) db_Manager.updateDataAtTable(tableName,fields,values,condition) # selected partner tableName = "player_selected_partner" fields = [] values = [] condition = "player_id = '%s'" % self.player_id for index in range(10): fields.append("%s" % index) if len(self.selected_partners) -1 < index: values.append(-1) else: values.append(self.selected_partners[index]) db_Manager.updateDataAtTable(tableName,fields,values,condition)
def addNocachePlayerResource(self,playerid,type,value,rankNum): tableName = "player_base_info" filedName = "cash" if type == 1: filedName = "pvp_medal" elif type == 2: filedName = "gem" elif type == 3: filedName = "revive" elif type == 4: filedName = "cash" else: print("not conifg this resource %s"%type) return selectField = filedName condition = "playerid = %s" %playerid data = db_Manager.selectDataFromTable(tableName,selectField,condition) oldValue = int(data[0][0]) newValue = oldValue + value insertField = [] insertField.append(filedName) insertField.append('lastTimedRewardDatetime') insertField.append('last_timed_reward_ranknum') insertValue = [] insertValue.append(newValue) insertValue.append(GameTools.getDateTimeNowString()) insertValue.append(rankNum) db_Manager.updateDataAtTable(tableName,insertField,insertValue,condition)
def updateMaxRankNum(): tableName = "id_info" fields = [] values = [] fields.append('rank_max_id') values.append(max_rankNum) db_Manager.updateDataAtTable(tableName, fields, values)
def updateRankMaxNum(self): from managers.player_data_manager import playerDataManager tableName = "id_info" fields = [] values = [] fields.append('rank_max_id') values.append(self.rank_max_num) condition = "server_id = '%s'" % playerDataManager.server_id db_Manager.updateDataAtTable(tableName,fields,values,condition)
def updatePlayerMaxID(self,maxID): tableName = 'id_info' fields = [] values = [] fields.append('player_max_id') fields.append('server_id') values.append(self.player_max_id) values.append(self.server_id) condition = "server_id = '%s'" % self.server_id db_Manager.updateDataAtTable(tableName,fields,values,condition)
def saveSkill(self): for skill in self.skills: tableName = "player_skill" fields = [] fields.append('level') fields.append('last_use_time') values = [] values.append(skill.skillLevel) values.append(skill.last_use_time) condition = "player_id = '%s' and skill_id = '%s'"%(self.player_id,skill.skillID) db_Manager.updateDataAtTable(tableName,fields,values,condition)
def saveSceneInfo(self): for sceneid,sceneInfo in self.scenesInfo.items(): tableName = "player_scene" fields = [] fields.append("big_luck_num") fields.append("small_luck_num") values = [] values.append(sceneInfo.big_luck_num) values.append(sceneInfo.small_luck_num) condition = "player_id = '%s' and scene_id = '%s'"%(self.player_id,sceneid) db_Manager.updateDataAtTable(tableName,fields,values,condition)
def savePvpBuffs(self): buffs = self.pvpBuffs saveStr = '' for index in range(len(buffs)): buff = buffs[index] if index == 0: saveStr = "%s" % buff else: saveStr = "%s,%s"%(saveStr,buff) tableName = 'player_pvp_buffs' fields = [] fields.append('buffstr') values = [] values.append(saveStr) condition = "playerid = '%s'" % self.player_id db_Manager.updateDataAtTable(tableName,fields,values,condition)
def save(self): tableName = "table_account_cdkey" fields = [] fields.append('is_use') fields.append('usedtime') fields.append('use_udid') values = [] values.append(int(self.is_use)) values.append(self.usedtime) values.append(self.use_udid) conditions = "id = %d" %self.id try: db_Manager.updateDataAtTable(tableName,fields,values,conditions) return True except: return False
def pvpWin(self,attackerID,targetID): attackerNum = self.getRankNumByPlayerid(attackerID) targetNum = self.getRankNumByPlayerid(targetID) self.rank[attackerNum] = targetID self.rank[targetNum] = attackerID tableName = "player_ranking" fileds = [] fileds.append('playerid') values = [] values.append(targetID) condition = "rank_num = '%s'" % attackerNum db_Manager.updateDataAtTable(tableName,fileds,values,condition) values = [] values.append(attackerID) condition = "rank_num = '%s'" % targetNum db_Manager.updateDataAtTable(tableName,fileds,values,condition)
def saveData2DB(self): self.login_days_check() tableName = 'player_base_info' fields = [] fields.append('playerid') fields.append('pvp_medal') fields.append('gem') fields.append('revive') fields.append('cash') fields.append('game_level') fields.append('game_wave') fields.append('chanllenge_date') fields.append('chanllenge_num') fields.append('avatorid') fields.append('lootEquipLevel') fields.append('is_brush') fields.append('last_cmd_time') fields.append('random_reward_num') fields.append('random_reward_date') fields.append('lastTimedRewardDatetime') fields.append('last_timed_reward_ranknum') fields.append('buy_del_challenge_cd_num') fields.append('daily_datetime') fields.append('add_chanllenge_num') fields.append('awake_spell_num') fields.append('last_free_draw_datetime') fields.append('recharge_total_num') fields.append('recharge_get_gifts_status') fields.append('last_login_date') fields.append('login_num') fields.append('login_get_gifts_status') fields.append('tutorial') values = [] values.append(self.player_id) values.append(self.pvp_medal) values.append(self.gems) values.append(self.revial) values.append(self.cash) values.append(self.game_level) values.append(self.game_wave) values.append(self.change_date) values.append(self.chanllenge_num) values.append((self.avatorid)) values.append(self.lootEquipLevel) values.append(self.isBrush) values.append(self.last_cmd_time) values.append(self.random_reward_num) values.append(self.random_rweard_date) values.append(self.last_timed_reward_datetime) values.append(self.last_timed_reward_ranknum) values.append(self.buy_del_challenge_cd_num) values.append(self.daily_datetime) values.append(self.add_chanllenge_num) values.append(self.awake_spell_num) values.append(self.last_free_draw_datetime) values.append(self.recharge_total_num) values.append(json.dumps(self.recharge_get_gifts_status)) values.append(self.last_login_date) values.append(self.login_num) values.append(json.dumps(self.login_get_gifts_status)) values.append(json.dumps({ "1":self.Tutor1Finished, "2":self.Tutor2Finished, "3":self.Tutor3Finished, "4":self.Tutor4Finished, "5":self.Tutor5Finished, "6":self.Tutor6Finished, "7":self.Tutor7Finished })) conditions = "playerid = '%s'" % self.player_id db_Manager.updateDataAtTable(tableName, fields,values,conditions) self.saveEquipments() self.saveSkill() self.savePartner() self.saveSceneInfo() self.savePvpBuffs()
def saveEquipments(self): posList = [] for index in range(12): # for index in range(6): posList.append(index) # posList.append(10) for pos,equipment in self.equipments.items(): posList.remove(pos) tableName = "player_equip" fields = [] fields.append('equipmentid') fields.append('equipment_quality') fields.append('equipment_level') fields.append('id') fields.append('game_level') fields.append('upgrade_cost') fields.append('buftype1') fields.append('bufvalue1') fields.append('buftype2') fields.append('bufvalue2') fields.append('buftype3') fields.append('bufvalue3') fields.append('buftype4') fields.append('bufvalue4') fields.append('buftype5') fields.append('bufvalue5') fields.append('bufbasetype1') fields.append('bufbasevalue1') fields.append('bufbasetype2') fields.append('bufbasevalue2') fields.append('bufbasetype3') fields.append('bufbasevalue3') fields.append('bufbasetype4') fields.append('bufbasevalue4') fields.append('bufbasetype5') fields.append('bufbasevalue5') values = [] values.append(equipment.equipmentid) values.append(equipment.equipment_quality) values.append(equipment.equipment_level) values.append(equipment.id) values.append(equipment.game_level) values.append(equipment.upgradeCost) for buf in equipment.bufList: values.append(buf.bufType) values.append(buf.bufValue) for buf in equipment.bufBaseList: values.append(buf.bufType) values.append(buf.bufValue) condition = "player_id = %s and pos = %s " %(self.player_id, pos) db_Manager.updateDataAtTable(tableName, fields, values, condition) for emptyPos in posList: tableName = "player_equip" fields = [] values = [] fields.append('equipmentid') values.append(-1) condition = "player_id = %s and pos = %s " %(self.player_id, emptyPos) db_Manager.updateDataAtTable(tableName, fields, values, condition)