Beispiel #1
0
def addVisitReward(playerId,type):
    rewardInfo = {}
    if(type == 0):
        rewardInfo = FIRST_VISIT
    elif(type == 1):
        item = random_tool.getRandomItem('daily_visit_random_table',DAILY_VISIT)
        rewardInfo = item
    
    #print 'type=',type,' rewardinfo=',rewardInfo
    rewardType = rewardInfo['type']
    rewardNum = rewardInfo['num']
    reward = {rewardType:rewardNum}
    db_tool.addPropAndMoney(playerId,rewardType,rewardNum)
    return reward
Beispiel #2
0
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.'}