Exemplo n.º 1
0
def main(loginName, userId):
    Login.wap_login(php_host, loginName, 'c13579')
    count = getmatch()  #0
    con = math.floor(count / 5000)
    A = lambda x: x if x <= 5000 else x % 5000
    nowcon = A(count)
    print('第%s轮,当前为:%s,总数量:%s' % (con + 1, nowcon, count))
    update_prize()
    for x in prize_list:
        prizeId = x['prizeId']
        condition = [int(y) for y in x['condition'].split(',')]
        for z in condition:
            if nowcon >= z:
                print(prize_name[str(prizeId)])
                break
    url = php_host + '/?act=act_springfestival&st=start_firecracker&useMatchCount={useMatchCount}'.format(
        useMatchCount=useMatchCount)
    result = Urlpost.post(url).read()
    print('\n%s' % Urlpost.jsondecode(result))
    re = json.loads(result.decode())
    code = re['code']
    if code == 6:  #鞭炮数量不足
        play_game(3)
        main(loginName, userId)
    elif code == 9:  #火柴数量不足,测试购买免费火柴
        print('buy')
        buy_match(1)
        time.sleep(1)
        update_prize()
        main(loginName, userId)
    elif code == 3:
        time.sleep(1)
        main(loginName, userId)
    else:  #火柴数量不足,测试购买收费火柴
        buy_match(1)
Exemplo n.º 2
0
def play_game(count=10):
    A = lambda self, x, n: x if n <= 0 else self(
        self,
        Urlpost.jsondecode(
            Urlpost.post(php_host + '/?act=game_niuniu&st=play&amount={amount}'
                         .format(amount=amount)).read()),
        n=n - 1)
    A(A, amount, count)
Exemplo n.º 3
0
def newyearSquib():  #燃放鞭炮接口
    url = host + '/newyearSquib.do'
    userId = int(input('\tuserId:'))
    actNo = input('\tactNo:')
    useMatchCount = int(input('\tuseMatchCount:'))
    userType = input('\tuserType:')
    channel = int(input('\tchannel:'))
    trackCode = input('\ttrackCode:')
    gameId = int(input('\tgameId:'))
    data = parse.urlencode({
        'data':
        json.dumps({
            'body': {
                'userId': userId,
                'actNo': actNo,
                'useMatchCount': useMatchCount,
                'userType': userType,
                'channel': channel,
                'trackCode': trackCode,
                'gameId': gameId
            }
        })
    })
    re = Urlpost.post(url, data)
    return re
Exemplo n.º 4
0
def buy_match(ufrom=0):  #ufrom:0:免费;1:收费
    ukField = 'TT'.join(str(x) for x in random.sample(range(1000), 5))
    data = parse.urlencode({
        'data':
        json.dumps({
            'body': {
                'userId': userId,
                'actNo': 'SNAC100254',
                'from': ufrom,
                'ukField': ukField,
                'addCount': 10
            }
        })
    })
    re = Urlpost.post(java_host + '/addMatchCount.do', data)
    result = Urlpost.jsondecode(re.read())
    return result
Exemplo n.º 5
0
def getFirecrackerRank():  #获取燃放鞭炮排行信息接口
    url = host + '/getFirecrackerRank.do'
    userId = int(input('\tuserId:'))
    actNo = input('\tactNo:')
    data = parse.urlencode(
        {'data': json.dumps({'body': {
            'userId': userId,
            'actNo': actNo
        }})})
    re = Urlpost.post(url, data)
    return re
Exemplo n.º 6
0
def getMatchCount():  #获取用户火柴个数接口
    url = host + '/getMatchCount.do'
    userId = int(input('\tuserId:'))
    actNo = input('\tactNo:')
    data = parse.urlencode(
        {'data': json.dumps({'body': {
            'userId': userId,
            'actNo': actNo
        }})})
    re = Urlpost.post(url, data)
    return re
Exemplo n.º 7
0
def getUserFirecrackerRecord():  #获取用户赠送鞭炮记录
    url = host + '/getUserFirecrackerRecord.do'
    userId = int(input('\tuserId:'))
    actNo = input('\tactNo:')
    data = parse.urlencode(
        {'data': json.dumps({'body': {
            'userId': userId,
            'actNo': actNo
        }})})
    re = Urlpost.post(url, data)
    return re
Exemplo n.º 8
0
def getUserPrizeTotal():  #获取用户获奖列表
    url = host + '/getUserPrizeTotal.do'
    userId = int(input('\tuserId:'))
    actNo = input('\tactNo:')
    data = parse.urlencode(
        {'data': json.dumps({'body': {
            'userId': userId,
            'actNo': actNo
        }})})
    re = Urlpost.post(url, data)
    return re
Exemplo n.º 9
0
 def post(self, url, data=None):
     result = Urlpost.post(url, data)
     try:
         result = Urlpost.jsondecode(result.read())
         return result
     except Exception as e:
         result = Urlpost.post(self.host + result['Location'])
         result = Urlpost.post(self.host + result['Location'])
         result = Urlpost.jsondecode(Urlpost.post(url, data).read())
         return result
Exemplo n.º 10
0
def getFirecrackerCount():  #获取用户鞭炮个数接口
    url = host + '/getFirecrackerCount.do'
    userId = int(input('\tuserId:'))
    actNo = input('\tactNo:')
    useStatus = int(input('\tuseStatus:'))
    data = parse.urlencode({
        'data':
        json.dumps({
            'body': {
                'userId': userId,
                'actNo': actNo,
                'useStatus': useStatus
            }
        })
    })
    re = Urlpost.post(url, data)
    return re
Exemplo n.º 11
0
def addMatchCount():  #添加用户火柴个数接口
    url = host + '/addMatchCount.do'
    userId = int(input('\tuserId:'))
    actNo = input('\tactNo:')
    ufrom = int(input('\tfrom:'))
    ukField = input('\tukField:')
    addCount = int(input('\taddCount:'))
    data = parse.urlencode({
        'data':
        json.dumps({
            'body': {
                'userId': userId,
                'actNo': actNo,
                'from': ufrom,
                'ukField': ukField,
                'addCount': addCount
            }
        })
    })
    re = Urlpost.post(url, data)
    return re
Exemplo n.º 12
0
def update_prize():
    url = java_host + '/updateSquibPrize.do'
    data = parse.urlencode({'data': json.dumps({'body': {}})})
    re = Urlpost.post(url, data)
    result = Urlpost.jsondecode(re.read())
    return result
Exemplo n.º 13
0
def updateSquibPrize():  #跑批更新奖池接口
    url = host + '/updateSquibPrize.do'
    re = Urlpost.post(url)
    return re