Ejemplo n.º 1
0
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}
Ejemplo n.º 2
0
def addExploreEventLog(leader,type,info):
    time_now = int(time.time())
    eventInfo = {}
    eventInfo['leader_id'] = leader
    eventInfo['type'] = type
    eventInfo['create_time'] = time_now
    eventInfo['info'] = db_tool.__dictToString(info)
    eventInfo['status'] = 0
    saveExploreEventLog(eventInfo)
Ejemplo n.º 3
0
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}
Ejemplo n.º 4
0
def writeGiftEventLog(db,conn,log_info,playerId):
    time_now = int(time.time())
    log_str = db_tool.__dictToString(log_info)
    db.execute("INSERT INTO gift_event_log(player_id,info,create_time) VALUES(%s,%s,%s)",(playerId,log_str,time_now))
    conn.commit()
Ejemplo n.º 5
0
def writeInteractionEventLog(db,conn,log_info,playerId,type):
    time_now = int(time.time())
    log_str = db_tool.__dictToString(log_info)
    db.execute("INSERT INTO interaction_event_log(player_id,info,create_time,type) VALUES(%s,%s,%s,%s)",(playerId,log_str,time_now,type))
    conn.commit()