# -*- coding:utf-8 -*-
import daiwan
import time
class Actor(object):
def __init__(self, name, area):
self.ranks = []
self.name = name
self.area_id = areas[area]
tmp = daiwan.getUserArea(self.name)
for x in tmp['data']:
if x['area_id'] == self.area_id:
# 1 钻石 6 大师 0 王者
if x['tier'] in (1, 6, 0):
self.qquin = x['qquin']
else:
print('\n 测试版本只允许分析钻石以上段位!')
input()
exit()
return
print('\n 玩家 ID 不存在!')
input()
exit()
areas = {}
judgements = ['挂机局', '浪输局', '甩锅局']
def init():
daiwan.init('API 账号', 'API 密码')
daiwan.getToken()
tmp = daiwan.getArea()
for x in tmp:
areas[x['name']] = int(x['id'])
def isActor(name, area):
jd = 0
person = Actor(name, area)
print('\n 分析中 0%', end='\r')
p = 1
while True:
tmp = daiwan.getCombatList(person.qquin, person.area_id, p)
for x in tmp:
if x['game_type'] == '4' and x['game_mode'] == '4':
person.ranks.append(x)
if len(person.ranks) >= 10:
break
else:
p += 1
players = {}
b = 0
i = 0
all = len(person.ranks)
for combat in person.ranks:
i += 1
tmp = daiwan.getGameDetail(person.qquin, person.area_id, combat['game_id'])
time.sleep(0.5)
for player in tmp['data'][0]['battle']['gamer_records']:
if combat['result'] == '胜利' and player['winclass'] == 'active' and player['qquin'] != person.qquin:
if player['name'] not in players:
players[player['name']] = 1
else:
players[player['name']] += 1
elif combat['result'] == '失败' and player['winclass'] == 'active':
if player['name'] not in players:
players[player['name']] = 1
else:
players[player['name']] += 1
if combat['result'] == '失败' and combat['judgement'] in judgements:
b += 1
percent = (i / all) * 100
print('分析中 %d%%' % percent, end='\r')
a = max(players.values())
rate = (a * 0.02 + b * 0.01) * 100
print('%s 是演员的可能性为 %d%%' % (person.name, rate))
init()
print(
'''
=======================================================
LOL 演员识别器
本程序采用作者自创的非科学算法,纯属娱乐!
=======================================================
'''
)
name = input('请输入玩家 ID :')
area = input('请输入玩家所在大区:')
isActor(name, area)
input()
识别算法是自己瞎编的。。。新手,感觉自己的代码有点乱。。
这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。
V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。
V2EX is a community of developers, designers and creative people.