# author: Jingke
import requests
import time
from drawLottery import DrawLottery, url_lottery
class Gift():
def __init__(self, gift, sum, matchInfoId, userId):
self.gift = gift
self.sum = sum
self.matchInfoId = matchInfoId
self.userId = userId
def gift_info(self):
a = b = c = d = e = f = g = h = 0
goal_result = DrawLottery.lottery_request(url_lottery['goal_init_url'], self.matchInfoId, userId='')
list_result = DrawLottery.lottery_request(url_lottery['drawLottery_list_url'], self.matchInfoId,
self.userId)
i = 1
try:
assert goal_result['code'] == 200
assert list_result['code'] == 200
except:
print('error:' + '%s' % goal_result)
print('error:' + '%s' % list_result)
else:
while i <= self.sum:
draw_result = DrawLottery.lottery_request(url_lottery['draw_lottery_url'], self.matchInfoId,
self.userId)
# print('%i' %i + '%s' %draw_result)
if draw_result['data']['hit'] == False:
a += 1
elif draw_result['data']['position'] == 1:
b += 1
elif draw_result['data']['position'] == 2:
c += 1
elif draw_result['data']['position'] == 3:
d += 1
elif draw_result['data']['position'] == 4:
print('%s' % i + '%s' % draw_result)
e += 1
elif draw_result['data']['position'] == 5:
f += 1
elif draw_result['data']['position'] == 6:
g += 1
else:
h += 1
i += 1
print('%s' % self.gift[0] + ':' + '{:.2f}%'.format(a / 100 * 100))
print('%s' % self.gift[1] + ':' + '{:.2f}%'.format(b / 100 * 100))
print('%s' % self.gift[2] + ':' + '{:.2f}%'.format(c / 100 * 100))
print('%s' % self.gift[3] + ':' + '{:.2f}%'.format(d / 100 * 100))
print('%s' % self.gift[4] + ':' + '{:.2f}%'.format(e / 100 * 100))
print('%s' % self.gift[5] + ':' + '{:.2f}%'.format(f / 100 * 100))
print('%s' % self.gift[6] + ':' + '{:.2f}%'.format(g / 100 * 100))
print('%s' % self.gift[7] + ':' + '{:.2f}%'.format(h / 100 * 100))
if __name__ == '__main__':
# gift_lucky = ['No_gift', '8_discount', 'x1', '28_crad', '60_card', '5_bean', '10_bean', '18-58_coupon']
gift_vip = ['No_gift', '1_discount', 'x3', '28_crad', '60_card', '15_bean', '58_bean', '18-58_coupon']
gift = Gift(gift_vip, 101, 6058, 203579) # 203885 jiangzhuxjianjing ; 203579钻石
gift.gift_info()
转盘抽奖概率自动化测试
©著作权归作者所有,转载或内容合作请联系作者
- 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
- 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
- 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
推荐阅读更多精彩内容
- /* 经典的概率算法, $proArr是一个预先设置的数组, 假设数组为:array(100,200,300,40...
- /* *经典的概率算法, *$proArr是一个预先设置的数组, *假设数组为:array(100,200,300...