当前位置: 首页>>代码示例>>Python>>正文


Python Match.mode方法代码示例

本文整理汇总了Python中models.Match.mode方法的典型用法代码示例。如果您正苦于以下问题:Python Match.mode方法的具体用法?Python Match.mode怎么用?Python Match.mode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在models.Match的用法示例。


在下文中一共展示了Match.mode方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: single_match

# 需要导入模块: from models import Match [as 别名]
# 或者: from models.Match import mode [as 别名]
def single_match(raw, mid):
    m = Match(id=mid)
    match_incr()
    if raw[0][0]['officl'] == "1" and raw[0][0]['cas'] == "1":
        # m.mode = 'cs'
        m.mode = 2
    elif raw[0][0]['officl'] == "1" and raw[0][0]['cas'] == "0":
        # m.mode = "rnk"
        m.mode = 1
    else:
        # m.mode = "acc"
        m.mode = 3
    m.version = raw[3][0]['version']
    m.map_used = raw[3][0]['map']
    m.length = raw[3][0]['time_played']
    # '2014-07-27 01:31:18'
    unaware_date = datetime.strptime(raw[3][0]['mdt'], '%Y-%m-%d %H:%M:%S')
    m.date = utc.localize(unaware_date)
    pitems = {}
    for p in raw[1]:
        items = []
        for item in range(1, 7):
            if p['slot_' + str(item)]:
                items.append(int(p['slot_' + str(item)]))
        pitems[p['account_id']] = items
    for p in raw[2]:
        if p['account_id'] not in pitems:
            pitems[p['account_id']] = []
        m.players.append(PlayerMatch(
            player_id=int(p['account_id']),
            nickname=p['nickname'],
            clan_id=int(p['clan_id']),
            hero_id=int(p['hero_id']),
            position=int(p['position']),
            items=pitems[p['account_id']],
            team=int(p['team']),
            level=int(p['level']),
            win=bool(int(p['wins'])),
            concedes=int(p['concedes']),
            concedevotes=int(p['concedevotes']),
            buybacks=int(p['buybacks']),
            discos=int(p['discos']),
            kicked=int(p['kicked']),
            mmr_change=float(p['amm_team_rating']),
            herodmg=int(p['herodmg']),
            kills=int(p['herokills']),
            assists=int(p['heroassists']),
            deaths=int(p['deaths']),
            kdr=div(p['herokills'], p['deaths']),
            goldlost2death=int(p['goldlost2death']),
            secs_dead=int(p['secs_dead']),
            cs=int(p['teamcreepkills']) + int(p['neutralcreepkills']),
            bdmg=p['bdmg'],
            denies=p['denies'],
            exp_denied=p['exp_denied'],
            gpm=divmin(p['gold'], m.length),
            xpm=divmin(p['exp'], m.length),
            apm=divmin(p['actions'], m.length),
            consumables=int(p['consumables']),
            wards=int(p['wards'])
        ))
    return m
开发者ID:Klaudit,项目名称:honbot-django,代码行数:64,代码来源:matches.py


注:本文中的models.Match.mode方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。