def init(serverInfo,is_fan): playerId = serverInfo['playerId'] sns_id = serverInfo['sns_id'] #add weekly reward daily_reward.getWeeklyReward(playerId) #add daily reward (notice: update last_login_time) dailyReward = daily_reward.getDailyReward(playerId,is_fan); #add festival reward festivalDailyReward = daily_reward.getFestivalDailyReward(playerId) #get player info player = db_tool.__getPlayerById(playerId) if not player: return {'status':0,'msg':'player not exist'} time_now = int(time.time()) player_module.__updateEnergy(player) returnVal = {'status':1} returnVal['player'] = player #returnVal['map'] = db_tool.getMapsbyPlayerId(playerId) returnVal['map_level'] = item.getHabitatInfo(playerId) returnVal['searcher'] = search_team.getSearchTeamDetail(playerId) returnVal['bag'] = db_tool.getAllProp(playerId) returnVal['bagMax'] = prop.getBagCapacity(playerId) returnVal['collection'] = collection.getCollection(playerId) returnVal['time_now']=time_now returnVal['box_status']=user_box.getUserBoxStatus(sns_id) returnVal['daily_reward']=dailyReward returnVal['festival_daily_reward']=festivalDailyReward returnVal['daily_task']=daily_task.getTaskInfo(playerId) returnVal['level_task']=level_task.getLevelTaskInfo(playerId) returnVal['produce']=produce.getProduceInfo(playerId) returnVal['invite_info']=invite.getInviteInfo(sns_id) returnVal['system_reward']=system_reward.getSystemRewardInfo(playerId) returnVal['auctionStatus'] = player_module.getAuctionStatus(playerId) returnVal['alchemy']=alchemy.getAlchemyInfo(playerId) returnVal['event_num']=interaction_event.getEventCount(playerId) returnVal['exchange_task']=exchange_task.getExchangeTaskInfo(playerId) returnVal['explore_start']=explore_team.isExploreStart(playerId) returnVal['life_tree'] = life_tree.getLifeTreeInfo(playerId) returnVal['interval_box'] = interval_box.getIntervalBoxInfo(playerId) return returnVal
def startExchangeTask(playerId): propDict = db_tool.getAllProp(playerId) player = db_tool.__getPlayerById(playerId) player = player_module.__updateEnergy(player) taskInfo = getExchangeTask(playerId) taskId = taskInfo['task_id'] if not EXCHANGE_TASK_CONFIG.has_key(taskId): return {'status':0,'msg':'没有相应的兑换任务 '+str(taskId)} needDefinitonList = EXCHANGE_TASK_CONFIG[taskId]['needDefinitonID'] if not checkBag(playerId,needDefinitonList,propDict): return {'status':0,'msg':'不满足兑换条件 '+str(taskId)} rewardList = EXCHANGE_TASK_CONFIG[taskId]['reward'] rewardGb = 0 rewardExp = 0 rewardEnergy = 0 rewardDefinitionId = 0 for reward in rewardList: rewardType = reward['type'] rewardNum = reward['num'] #金币 if rewardType == 2: rewardGb = rewardNum player['gb'] += rewardNum #经验 if rewardType == 3: rewardExp = rewardNum player['exp'] += rewardNum #能量 elif rewardType == 4: rewardEnergy = rewardNum player['energy'] += rewardNum #物品 else: rewardDefinitionId = rewardType db_tool.__addPropItem(propDict,rewardType,rewardNum) #更新player db_tool.__updatePlayer(playerId,{'gb':player['gb'],'exp':player['exp'],'energy':player['energy'],'last_energy_time':player['last_energy_time']}) db_tool.saveAllProp(playerId,propDict) #更新兑换状态 updTaskInfo = {} updTaskInfo['status'] = 1 updateExchangeTask(playerId,updTaskInfo) return {'status':1,'reward':rewardList,'player':player,'bag':propDict}
def usePropInBag(playerId,prop_id): propDict = db_tool.getAllProp(playerId) prop_id=str(prop_id) if propDict.has_key(prop_id) and propDict[prop_id] >0 : player = db_tool.__getPlayerById(playerId) player = player_module.__updateEnergy(player) boxItem = {} #能量道具 if prop_id == '2010' or prop_id == '2011' or prop_id == '2012': player['energy'] += PROP_CONFIG[int(prop_id)]['num'] db_tool.__updatePlayer(player['id'],{'energy':player['energy'],'last_energy_time':player['last_energy_time']}) #VIP道具 elif prop_id == '2001' or prop_id == '2002' or prop_id == '2003': time_now = int(time.time()) if player['vip'] > time_now: player['vip'] += PROP_CONFIG[int(prop_id)]['period'] else: player['vip'] = time_now + PROP_CONFIG[int(prop_id)]['period'] db_tool.__updatePlayer(player['id'],{'vip':player['vip']}) #材料包 elif prop_id == '3001' or prop_id == '3002' or prop_id == '3003': props = PROP_CONFIG[int(prop_id)]['items'] for item in props: db_tool.__addPropItem(propDict,item['type'],item['num']) #神秘箱子 elif prop_id == '4000' or prop_id == '4010': random_table_key = 'magic_box_random_table_'+prop_id boxItem = random_tool.getRandomItem(random_table_key,MAGIC_BOX[int(prop_id)]) db_tool.__addPropItem(propDict,boxItem['type'],boxItem['num']) else: return {'status':0,'msg':'未配置效果物品 ['+str(prop_id)+'].'} propDict[prop_id]-=1 db_tool.saveAllProp(player['id'],propDict) #有箱子信息 if boxItem: return {'status':1,'player':player,'bag':propDict,'time_now':int(time.time()),'prop_id':prop_id,'box_item_type':boxItem['type'],'box_item_num':boxItem['num']} else: return {'status':1,'player':player,'bag':propDict,'time_now':int(time.time()),'prop_id':prop_id} else: return {'status':0,'msg':'Can not find ['+str(prop_id)+'] in bag.'}