Beispiel #1
0
def buyAuction(db,conn,playerId,transaction_id,buyer_name):
    
    player = db_tool.__getPlayerById(playerId)
    playerId = player['id']
    returnVal = {}
    
    transaction= __lockTransactionById(db,conn,transaction_id)
    if transaction:
        number = transaction['number']
        price = transaction['price']
        seller_id = transaction['user_id']
        
        seller = db_tool.__getPlayerById(seller_id)

        player['gb']-=price
        if(player['gb']>=0):
            tax_rate=1/0.05
            tax=int((price+tax_rate-1)/tax_rate)
            seller_income=price-tax;
            
            #修改卖家gb
            db_tool.__updatePlayer(seller_id,{'gb':seller['gb']+seller_income})
            #修改买家gb及背包
            db_tool.__updatePlayer(playerId,{'gb':player['gb']})
            props = db_tool.getAllProp(playerId)
            db_tool.__addPropItem(props,transaction['prop_id'],number)
            db_tool.saveAllProp(playerId,props)
            #删除记录
            __delLockTransactionItem(db,conn,transaction_id)
            
            log_info = {}
            log_info['player_id'] = playerId
            log_info['price'] = price
            log_info['buyer'] = buyer_name
            log_info['number'] = number
            log_info['prop_id'] = transaction['prop_id']
            auctionEvent(log_info,seller_id)
            
            returnVal['status'] = 1
            returnVal['bag'] = db_tool.getAllProp(playerId)
            returnVal['player'] = player
            returnVal['cost']=price
            returnVal['auctionId'] = transaction_id
            returnVal['auctionStatus'] = player_module.getAuctionStatus(seller_id)
            return returnVal
        else:
            return {'status':0,'error_type':100,'msg':'Not enough money'}
    else:
        return {'status':0,'error_type':1,'auctionId':transaction_id,'msg':'Can not find the Transaction by id '+str(transaction_id)}
Beispiel #2
0
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
Beispiel #3
0
def purchaseResponse(serverInfo,parm):
    returnVal = purchase.purchaseResponse(parm['buyer_id'],parm['u_id'],parm['u_name'],parm['auction_id'])
    returnVal['auctionStatus'] = player_module.getAuctionStatus(parm['buyer_id'])
    return returnVal
Beispiel #4
0
def cancelPurchase(serverInfo,purchaseId):
    returnVal = purchase.cancelPurchase(serverInfo['playerId'],purchaseId)
    returnVal['auctionStatus'] = player_module.getAuctionStatus(serverInfo['playerId'])
    return returnVal
Beispiel #5
0
def launchPurchase(serverInfo,parm):
    returnVal = purchase.launchPurchase(serverInfo['playerId'],parm)
    returnVal['auctionStatus'] = player_module.getAuctionStatus(serverInfo['playerId'])
    return returnVal
Beispiel #6
0
def cancelAuction(serverInfo,id):
    returnVal = auction.cancelAuction(serverInfo['playerId'],id)
    returnVal['auctionStatus'] = player_module.getAuctionStatus(serverInfo['playerId'])
    return returnVal
Beispiel #7
0
def Auction(serverInfo,param):
    returnVal = auction.Auction(serverInfo['playerId'],param)
    returnVal['auctionStatus'] = player_module.getAuctionStatus(serverInfo['playerId'])
    return returnVal