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


Python Activity.get_player_activity方法代码示例

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


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

示例1: challenge_count

# 需要导入模块: from models import Activity [as 别名]
# 或者: from models.Activity import get_player_activity [as 别名]
def challenge_count(player, days=None):
    """
     Return the count of challenges played by player in the last x _days_.
     All challenges if days == None
    """
    if not days:
        return Activity.get_player_activity(player).filter(action__contains='chall').count()
    start = datetime.now() - timedelta(days=days)
    return Activity.get_player_activity(player).filter(
            action__contains='chall', timestamp__gte=start).count()
开发者ID:AndreiRO,项目名称:wouso,代码行数:12,代码来源:achievements.py

示例2: refused_challenges

# 需要导入模块: from models import Activity [as 别名]
# 或者: from models.Activity import get_player_activity [as 别名]
def refused_challenges(player):
    """
     Return the count of refused challenges in the last week
    """
    start = datetime.now() + timedelta(days=-7)
    return Activity.get_player_activity(player).filter(action__contains='chall-refused', timestamp__gte=start,
                                                       user_from=player).count()
开发者ID:Sendroiu,项目名称:wouso,代码行数:9,代码来源:achievements.py

示例3: wrong_first_qotd

# 需要导入模块: from models import Activity [as 别名]
# 或者: from models.Activity import get_player_activity [as 别名]
def wrong_first_qotd(player):
    """
     Check if the first answer to qotd was a wrong answer.
    """
    activities = Activity.get_player_activity(player).filter(action__contains='qotd')
    if not activities.count() == 1:
        return False
    if activities[0].action == 'qotd-wrong':
        return True
    return False
开发者ID:anaion,项目名称:wouso,代码行数:12,代码来源:achievements.py

示例4: challenges_played_today

# 需要导入模块: from models import Activity [as 别名]
# 或者: from models.Activity import get_player_activity [as 别名]
def challenges_played_today(player):
    """
     Return the count of challenges played today
    """
    today = datetime.now().date()
    activities = Activity.get_player_activity(player).filter(action__contains='chall', timestamp__gte=today)
    result = 0
    for a in activities:
        if not 'refused' in a.action:
            result += 1
    return result
开发者ID:AndreiRO,项目名称:wouso,代码行数:13,代码来源:achievements.py

示例5: consecutive_qotd_correct

# 需要导入模块: from models import Activity [as 别名]
# 或者: from models.Activity import get_player_activity [as 别名]
def consecutive_qotd_correct(player):
    """
     Return the count of correct qotd in a row
    """
    activities = Activity.get_player_activity(player).filter(action__contains = 'qotd').order_by('-timestamp')[:12]
    result = 0
    for i in activities:
        if 'correct' in i.action:
            result +=1
        else:
            return result
    return result
开发者ID:ciprianf,项目名称:wouso,代码行数:14,代码来源:achievements.py

示例6: consecutive_chall_won

# 需要导入模块: from models import Activity [as 别名]
# 或者: from models.Activity import get_player_activity [as 别名]
def consecutive_chall_won(player):
    """
     Return the count of won challenges in a row
     Maximum: 10 (last ten)
    """
    activities = Activity.get_player_activity(player).filter(action__contains='chall').order_by('-timestamp')[:10]
    result = 0
    for i in activities:
        if 'won' in i.action and i.user_from.id == player.id:
            result += 1
        else:
            return result

    return result
开发者ID:anaion,项目名称:wouso,代码行数:16,代码来源:achievements.py

示例7: challenge_count

# 需要导入模块: from models import Activity [as 别名]
# 或者: from models.Activity import get_player_activity [as 别名]
def challenge_count(player):
    """
     Return the count of challenges played by player.
    """
    return Activity.get_player_activity(player).filter(action__contains='chall').count()
开发者ID:anaion,项目名称:wouso,代码行数:7,代码来源:achievements.py


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