def stealSearchTeam(db, conn, param): playerId = param["player_id"] playerName = param["player_name"] playerPic = param["player_pic"] friendId = param["friend_id"] friendPlayer = db_tool.__getPlayerById(friendId) if not friendPlayer or player_module.isVIP(friendPlayer): return {"status": 0, "error_type": 2, "msg": "friend is null or is vip"} searchInfo = lockSearchTeamById(db, conn, friendId) if not searchInfo or searchInfo["blue_box"] != 1: searchInfo = getSearchTeamDetail(friendId) return { "status": 0, "error_type": 1, "searcher": searchInfo, "msg": "searchInfo is done or stealed by other friend", } number = searchInfo["number"] searchTypeId = searchInfo["type"] areaId = searchInfo["area"] searchStartTime = searchInfo["last_start_time"] needTime = SEARCH_TYPE[searchTypeId]["time"] * 3600 time_now = int(time.time()) if (searchStartTime + needTime) > time_now: return {"status": 0, "msg": "need more time for searchInfo"} # 记录好友信息 friendsInfo = {} friendsInfo["id"] = playerId friendsInfo["name"] = playerName friendsInfo["pic"] = playerPic updateInfo = {} updateInfo["friends"] = db_tool.__dictToString(friendsInfo) updateInfo["number"] = number - 1 updateInfo["blue_box"] = 2 updateSearchTeamInfoForLock(db, conn, friendId, updateInfo) # 更新背包信息 propDict = db_tool.getAllProp(playerId) prop_id, num = odds.getItemByArea(areaId) db_tool.__addPropItem(propDict, prop_id, num) db_tool.saveAllProp(playerId, propDict) searchInfo = getSearchTeamDetail(friendId) # 添加交互日志 log_info = {} log_info["player_id"] = playerId log_info["player_name"] = playerName log_info["prop_id"] = prop_id interaction_event.writeInteractionEventLog(log_info, friendId, 1) return {"status": 1, "definitionId": prop_id, "bag": propDict, "searcher": searchInfo}
def helpAlchemy(db,conn,playerId,snsName,snsPic,friendId): player = db_tool.__getPlayerById(playerId) sns_id = player['sns_id'] #正在或等待炼化的信息 alchemyInfoList = getAlchemyInfo(friendId) #正在炼化的信息 active_alchemy = {} time_now = int(time.time()) for alchemy in alchemyInfoList: #分钟转换成秒 needTime = ALCHEMY_CONFIG[alchemy['id']]['time']*60 alchemyTime = alchemy['time'] totalCostTime = alchemyTime+needTime #正在炼化的信息 if time_now < totalCostTime: active_alchemy = alchemy break if not active_alchemy: return {'status':0,'msg':'no active_alchemy info'} helpUserInfo = str(playerId)+'#'+snsName+'#'+snsPic friends = active_alchemy['friends'] #默认空 if friends == '': friendsList = [] else: friendsList = friends.split('@') if helpUserInfo not in friendsList: friendsList.append(helpUserInfo) active_alchemy['friends'] = '@'.join(friendsList) updateAlchemy(friendId,alchemyInfoList) #添加交互日志 log_info = {} log_info['player_id'] = playerId log_info['player_name'] = snsName interaction_event.writeInteractionEventLog(log_info,friendId,2) return {'status':1,'alchemyInfo':alchemyInfoList}
def helpHarvest(db,conn,playerId,param): playerId = param['player_id'] playerName = param['player_name'] playerPic = param['player_pic'] friendId = param['friend_id'] itemId = param['id'] mapItem = db_tool.lockItem(db,conn,friendId,itemId) if not mapItem: return {'status':0,'msg':'no such item'} definitionId = item_module.getDrawIdByMixId(mapItem['definitionId']) friends = mapItem['friends'] if friends: return {'status':0,'msg':'has helped by others'} player = db_tool.__getPlayerById(playerId) #消耗免费能量 player['help_energy'] -= 1 if player['help_energy'] < 0: return {'status':0,'msg':'not enough helpEnergy'} #获得的GB addGb = DRAWING_CONFIG[definitionId]['harvest']['income']/4 player['gb'] += addGb #获得奖励 db_tool.__updatePlayer(player['id'],{'gb':player['gb'],'help_energy':player['help_energy']}) #记录好友信息 friendsInfo = {} friendsInfo['id'] = playerId friendsInfo['name'] = playerName friendsInfo['pic'] = playerPic updateInfo = {'friends':db_tool.__dictToString(friendsInfo)} db_tool.updateItemById(db,conn,friendId,itemId,updateInfo) #添加交互日志 log_info = {} log_info['player_id'] = playerId log_info['player_name'] = playerName interaction_event.writeInteractionEventLog(log_info,friendId,4) return {'status':1,'gb':addGb,'playerInfo':player,'id':itemId}
def helpProduce(db,conn,playerId,snsName,snsPic,friendId,machineId): time_now = int(time.time()) produceList = getProduceList(friendId) if not produceList.has_key(str(machineId)): return {'status':0,'msg':'no produce machineId for help'} produce_start_time = produceList[str(machineId)]['startTime'] produce_id = produceList[str(machineId)]['produceId'] produce_friends = produceList[str(machineId)]['friends'] #是否有好友帮助 if produce_friends: return {'status':0,'msg':'helpProduce completed'} produce_circle = PRODUCE_CONFIG[produce_id]['time']*60 helpUserInfo = str(playerId)+'#'+snsName+'#'+snsPic #剩余时间 remainTime = produce_circle-(time_now-produce_start_time) #减去总时间的10% subtractTime = produce_circle/10 #subtractTime = int(math.ceil(remainTime*0.1)) if remainTime < subtractTime: produce_start_time -= remainTime else: produce_start_time -= subtractTime produceList[str(machineId)]['friends'] = helpUserInfo produceList[str(machineId)]['startTime'] = produce_start_time updateProduce(friendId,produceList) #添加交互日志 log_info = {} log_info['player_id'] = playerId log_info['player_name'] = snsName interaction_event.writeInteractionEventLog(log_info,friendId,3) return {'status':1,'pid':machineId,'produce':produceList[str(machineId)]}