示例#1
0
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()
示例#2
0
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()
示例#3
0
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()
示例#4
0
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()
示例#5
0
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
示例#6
0
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
示例#7
0
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
示例#8
0
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
示例#9
0
def consecutive_qotd_correct(player):
    """
     Return the count of correct qotd in a row
     Maximum: 10 (last ten)
    """
    activities = Activity.get_player_activity(player).filter(action__contains = 'qotd').order_by('-timestamp')[:10]
    result = 0
    for i in activities:
        if 'correct' in i.action:
            result += 1
        else:
            return result
    return result
示例#10
0
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
示例#11
0
def challenge_count(player):
    """
     Return the count of challenges played by player.
    """
    return Activity.get_player_activity(player).filter(action__contains='chall').count()