Example #1
0
def do_milestone_rune(c, mile):
  """Give out 30/N points for the Nth time a player finds a rune, and also give out banners."""
  # Check if this player already found this kind of rune. Remember the db
  # is already updated, so for the first rune the count will be 1.
  rune = loaddb.extract_rune(mile['milestone'])
  num_rune = query.player_count_runes(c, mile['name'], rune)
  rune_points = (30 + num_rune - 1) / num_rune
  assign_points(c, "rune:" + rune, mile['name'], rune_points)
  player = mile['name']
  runes_found = query.player_count_distinct_runes(c, player)
  if runes_found == crawl.NRUNES:
    banner.award_banner(c, player, 'ashenzari', 3)
  elif runes_found >= 5:
    banner.award_banner(c, player, 'ashenzari', 2)
  if rune == 'golden' and num_rune == 1:
    banner.award_banner(c, player, 'fedhas', 2)
  if nemelex.is_nemelex_choice(mile['char'], mile['time']):
    ban = 'nemelex:' + mile['char']
    banner.award_banner(c, player, ban, 2)
  if not query.did_reach_d14(c, player, mile['start'], mile['time']):
    if mile['urune'] >= 4:
      banner.award_banner(c, player, 'the_shining_one', 3)
    elif mile['urune'] >= 2:
      banner.award_banner(c, player, 'the_shining_one', 2)
    else:
      banner.award_banner(c, player, 'the_shining_one', 1)
Example #2
0
def crunch_misc(c, g):
  player = g['name']
  ktyp = g['ktyp']


  if g['sc'] >= 27000000:
    banner.award_banner(c, player, 'okawaru', 3)
  elif g['sc'] >= 9000000:
    banner.award_banner(c, player, 'okawaru', 2)
  elif g['sc'] >= 1000000:
    banner.award_banner(c, player, 'okawaru', 1)

  if g['goldfound'] >= 1000:
    banner.award_banner(c, player, 'gozag', 1)

  if g['xl'] >= 9 and nemelex.is_nemelex_choice(g['char'],g['start']):
    banner.award_banner(c, player, 'nemelex', 1)
  if g['xl'] >= 9 and query.check_xl9_streak(c, player, g['start']):
    banner.award_banner(c, player, 'cheibriados', 1)
  if g['sc'] >= 1000:
    og = query.previous_combo_highscore(c, g)
    if og and og[0] != player and og[1] >= 1000 and og[1] < g['sc']:
      banner.award_banner(c, player, 'dithmenos', 1)

  killer = loaddb.strip_unique_qualifier(g.get('killer') or '')
Example #3
0
def do_milestone_rune(c, mile):
  """Give out 30/N points for the Nth time a player finds a rune, and also give out banners."""
  # Check if this player already found this kind of rune. Remember the db
  # is already updated, so for the first rune the count will be 1.
  rune = loaddb.extract_rune(mile['milestone'])
  num_rune = query.player_count_runes(c, mile['name'], rune)
  rune_points = (30 + num_rune - 1) / num_rune
  assign_points(c, "rune:" + rune, mile['name'], rune_points)
  player = mile['name']
  runes_found = query.player_count_distinct_runes(c, player)
  if runes_found == crawl.NRUNES:
    banner.award_banner(c, player, 'ashenzari', 3)
  elif runes_found >= 5:
    banner.award_banner(c, player, 'ashenzari', 2)
  if rune == 'golden' and num_rune == 1:
    banner.award_banner(c, player, 'fedhas', 2)
  if nemelex.is_nemelex_choice(mile['char'], mile['time']):
    ban = 'nemelex:' + mile['char']
    banner.award_banner(c, player, ban, 2)
  if not query.did_reach_d14(c, player, mile['start'], mile['time']):
    if mile['urune'] == 4:
      assign_points(c, 'vow_of_courage', player, 25)
      banner.award_banner(c, player, 'the_shining_one', 3)
    elif mile['urune'] >= 2:
      banner.award_banner(c, player, 'the_shining_one', 2)
    else:
      banner.award_banner(c, player, 'the_shining_one', 1)
  if not query.game_did_visit_lair(c, mile['name'], mile['start'], mile['time']):
    banner.award_banner(c, mile['name'], 'kikubaaqudgha', 2)
  if query.time_from_str(mile['time']) - query.time_from_str(mile['start']) <= datetime.timedelta(hours=27):
    banner.award_banner(c, mile['name'], 'vehumet', 1)
  if query.is_unbeliever(c, mile):
    banner.award_banner(c, mile['name'], 'lugonu', 2)
Example #4
0
def crunch_misc(c, g):
  player = g['name']
  ktyp = g['ktyp']

  if g['xl'] >= 13:
    banner.award_banner(c, player, 'okawaru', 1)

  if g['goldfound'] >= 1000:
    banner.award_banner(c, player, 'gozag', 1)

  if g['xl'] >= 9 and nemelex.is_nemelex_choice(g['char'],g['start']):
    ban = 'nemelex:' + g['char']
    banner.award_banner(c, player, ban, 1)
  if g['xl'] >= 9 and query.check_xl9_streak(c, player, g['start']):
    banner.award_banner(c, player, 'cheibriados', 1)
  if g['sc'] >= 1000:
    og = query.previous_combo_highscore(c, g)
    if og and og[0] != player and og[1] >= 1000 and og[1] < g['sc']:
      banner.award_banner(c, player, 'dithmenos', 1)

  killer = loaddb.strip_unique_qualifier(g.get('killer') or '')
  if uniq.is_uniq(killer):
    query_do(c,
             '''INSERT INTO deaths_to_uniques
                            (player, uniq, start_time, end_time)
                     VALUES (%s, %s, %s, %s)''',
             player.lower(), killer, g['start'], g['end'])
    cuniqdeaths = query.count_deaths_to_distinct_uniques(c, player)
    olduniqdeaths = query.lookup_deaths_to_distinct_uniques(c, player)
    if cuniqdeaths > olduniqdeaths:
      query.update_deaths_to_distinct_uniques(c, player, cuniqdeaths,
                                              g['end'])
Example #5
0
def crunch_misc(c, g):
  player = g['name']
  ktyp = g['ktyp']

  if ktyp != 'winning':
    query.kill_active_streak(c, player)

  if g['goldspent'] == 0 and g['gold'] >= 1000:
    banner.award_banner(c, player, 'sif', 1)
  if g['xl'] >= 9 and nemelex.is_nemelex_choice(g['char'],g['start']):
    ban = 'nemelex:' + g['char']
    banner.award_banner(c, player, ban, 1)
  if g['xl'] >= 9 and query.check_xl9_streak(c, player, g['start']):
    banner.award_banner(c, player, 'cheibriados', 1)
  if g['sc'] >= 1000:
    og = query.previous_combo_highscore(c, g)
    if og and og[0] != player and og[1] >= 1000 and og[1] < g['sc']:
      banner.award_banner(c, player, 'trog', 1)
  #check_fedhas_banner(c, g)

  killer = loaddb.strip_unique_qualifier(g.get('killer') or '')
  if uniq.is_uniq(killer):
    query_do(c,
             '''INSERT INTO deaths_to_uniques
                            (player, uniq, start_time, end_time)
                     VALUES (%s, %s, %s, %s)''',
             player, killer, g['start'], g['end'])
    cuniqdeaths = query.count_deaths_to_distinct_uniques(c, player)
    olduniqdeaths = query.lookup_deaths_to_distinct_uniques(c, player)
    if cuniqdeaths > olduniqdeaths:
      query.update_deaths_to_distinct_uniques(c, player, cuniqdeaths,
                                              g['end'])
Example #6
0
def do_milestone_rune(c, mile):
  """Give out 30/N points for the Nth time a player finds a rune, and also give out banners."""
  # Check if this player already found this kind of rune. Remember the db
  # is already updated, so for the first rune the count will be 1.
  rune = loaddb.extract_rune(mile['milestone'])
  num_rune = query.player_count_runes(c, mile['name'], rune)
  rune_points = (30 + num_rune - 1) / num_rune
  assign_points(c, "rune:" + rune, mile['name'], rune_points)
  player = mile['name']
  runes_found = query.player_count_distinct_runes(c, player)
  if mile['dur'] <= 4860:
    banner.award_banner(c, mile['name'], 'makhleb', 2)
  if runes_found == crawl.NRUNES:
    banner.award_banner(c, player, 'ashenzari', 3)
  elif runes_found >= 5:
    banner.award_banner(c, player, 'ashenzari', 2)
  if rune == 'golden' and num_rune == 1:
    banner.award_banner(c, player, 'fedhas', 2)
  if nemelex.is_nemelex_choice(mile['char'], mile['time']):
    ban = 'nemelex:' + mile['char']
    banner.award_banner(c, player, ban, 2)
  if not query.did_enter_branch(c, 'Depths', player, mile['start'], mile['time']):
    if mile['urune'] == 6:
      assign_points(c, 'vow_of_courage', player, 25)
      banner.award_banner(c, player, 'the_shining_one', 3)
    elif mile['urune'] >= 4:
      banner.award_banner(c, player, 'the_shining_one', 2)
  #if query.time_from_str(mile['time']) - query.time_from_str(mile['start']) <= datetime.timedelta(hours=27):
  #  banner.award_banner(c, mile['name'], 'oldbanner', 1)
  if query.is_unbeliever(c, mile):
    banner.award_banner(c, mile['name'], 'trog', 2)
  if mile['urune'] == 1:
    if rune != 'slimy':
      if mile['potionsused'] == 0 and mile['scrollsused'] == 0:
        banner.award_banner(c, mile['name'], 'vehumet', 3)
Example #7
0
def do_milestone_rune(c, mile):
  """Give out 24/N points for the Nth time a player finds a rune, and also give out banners."""
  # Check if this player already found this kind of rune. Remember the db
  # is already updated, so for the first rune the count will be 1.
  rune = loaddb.extract_rune(mile['milestone'])
  num_rune = query.player_count_runes(c, mile['name'], rune)
  rune_points = (24 + num_rune - 1) / num_rune
  assign_points(c, "rune:" + rune, mile['name'], rune_points)
  player = mile['name']
  runes_found = query.player_count_distinct_runes(c, player)
  if mile['dur'] <= 4860:
    banner.award_banner(c, mile['name'], 'makhleb', 2)
  if runes_found == crawl.NRUNES:
    banner.award_banner(c, player, 'ashenzari', 3)
  elif runes_found >= 5:
    banner.award_banner(c, player, 'ashenzari', 2)
  if rune == 'golden' and num_rune == 1:
    banner.award_banner(c, player, 'fedhas', 2)
  if rune == 'silver' and num_rune == 1:
    banner.award_banner(c, player, 'gozag', 2)

  # The abyssal rune is the only rune that the player can get before the iron
  # rune for Avarice 3.
  if rune == 'iron' and mile['urune'] <= 2:
    other_rune_branches = ['Vaults', 'Shoals', 'Snake', 'Spider', 'Swamp', 'Slime', 'Pan', 'Coc', 'Geh', 'Tar']
    eligible = True
    for br in other_rune_branches:
      if query.did_enter_branch(c, br, player, mile['start'], mile['time']):
        eligible = False
        break
    if eligible:
      assign_points(c, 'avarice', player, 25, False)
      banner.award_banner(c, player, 'gozag', 3)

  if nemelex.is_nemelex_choice(mile['char'], mile['time']):
    ban = 'nemelex:' + mile['char']
    banner.award_banner(c, player, ban, 2)
  if not query.did_enter_branch(c, 'Depths', player, mile['start'], mile['time']):
    if mile['urune'] == 6:
      assign_points(c, 'vow_of_courage', player, 25, False)
      banner.award_banner(c, player, 'the_shining_one', 3)
    elif mile['urune'] >= 4:
      banner.award_banner(c, player, 'the_shining_one', 2)
  #if query.time_from_str(mile['time']) - query.time_from_str(mile['start']) <= datetime.timedelta(hours=27):
  #  banner.award_banner(c, mile['name'], 'oldbanner', 1)
  if query.is_unbeliever(c, mile):
    banner.award_banner(c, mile['name'], 'trog', 2)
  if mile['urune'] == 1:
    if rune != 'slimy' and rune != 'abyssal':
      if mile['potionsused'] == 0 and mile['scrollsused'] == 0:
        assign_points(c, 'ascetic', player, 25, False)
        banner.award_banner(c, mile['name'], 'ru', 3)
    if mile['xl'] < 14:
      if not query.did_sacrifice(c, 'experience', mile['name'], mile['start'], mile['time']):
        banner.award_banner(c, mile['name'], 'vehumet', 2)
Example #8
0
def do_milestone_rune(c, mile):
    """Give out 24/N points for the Nth time a player finds a rune, and also give out banners."""
    # Check if this player already found this kind of rune. Remember the db
    # is already updated, so for the first rune the count will be 1.
    rune = loaddb.extract_rune(mile["milestone"])
    num_rune = query.player_count_runes(c, mile["name"], rune)
    rune_points = (24 + num_rune - 1) / num_rune
    assign_points(c, "rune:" + rune, mile["name"], rune_points)
    player = mile["name"]
    runes_found = query.player_count_distinct_runes(c, player)
    if mile["dur"] <= 4860:
        banner.award_banner(c, mile["name"], "makhleb", 2)
    if runes_found == crawl.NRUNES:
        banner.award_banner(c, player, "ashenzari", 3)
    elif runes_found >= 5:
        banner.award_banner(c, player, "ashenzari", 2)
    if rune == "golden" and num_rune == 1:
        banner.award_banner(c, player, "fedhas", 2)
    if rune == "silver" and num_rune == 1:
        banner.award_banner(c, player, "gozag", 2)

    # The abyssal rune is the only rune that the player can get before the iron
    # rune for Avarice 3.
    if rune == "iron" and mile["urune"] <= 2:
        other_rune_branches = ["Vaults", "Shoals", "Snake", "Spider", "Swamp", "Slime", "Pan", "Coc", "Geh", "Tar"]
        eligible = True
        for br in other_rune_branches:
            if query.did_enter_branch(c, br, player, mile["start"], mile["time"]):
                eligible = False
                break
        if eligible:
            assign_points(c, "avarice", player, 25, False)
            banner.award_banner(c, player, "gozag", 3)

    if nemelex.is_nemelex_choice(mile["char"], mile["time"]):
        ban = "nemelex:" + mile["char"]
        banner.award_banner(c, player, ban, 2)
    if not query.did_enter_branch(c, "Depths", player, mile["start"], mile["time"]):
        if mile["urune"] == 6:
            assign_points(c, "vow_of_courage", player, 25, False)
            banner.award_banner(c, player, "the_shining_one", 3)
        elif mile["urune"] >= 4:
            banner.award_banner(c, player, "the_shining_one", 2)
    # if query.time_from_str(mile['time']) - query.time_from_str(mile['start']) <= datetime.timedelta(hours=27):
    #  banner.award_banner(c, mile['name'], 'oldbanner', 1)
    if query.is_unbeliever(c, mile):
        banner.award_banner(c, mile["name"], "trog", 2)
    if mile["urune"] == 1:
        if rune != "slimy" and rune != "abyssal":
            if mile["potionsused"] == 0 and mile["scrollsused"] == 0:
                assign_points(c, "ascetic", player, 25, False)
                banner.award_banner(c, mile["name"], "ru", 3)
        if mile["xl"] < 14:
            if not query.did_sacrifice(c, "experience", mile["name"], mile["start"], mile["time"]):
                banner.award_banner(c, mile["name"], "vehumet", 2)
Example #9
0
def act_on_milestone(c, mile):
    """This function takes a milestone line, which is a string composed of key/
  value pairs separated by colons, and parses it into a dictionary.
  Then, depending on what type of milestone it is (key "type"), another
  function may be called to finish the job on the milestone line. Milestones
  have the same broken :: behavior as logfile lines, yay."""

    player = game_player(mile)

    if mile['xl'] >= 13:
        banner.award_banner(c, player, 'okawaru', 1)

    if mile['goldfound'] >= 1000:
        banner.award_banner(c, player, 'gozag', 1)

    if mile['xl'] >= 9 and nemelex.is_nemelex_choice(mile['char'],
                                                     mile['start']):
        ban = 'nemelex:' + mile['char']
        banner.award_banner(c, player, ban, 1)

    # hack to handle milestones with no potions_used/scrolls_used fields
    if not mile.has_key('potionsused'):
        mile['potionsused'] = -1
        mile['scrollsused'] = -1

    miletype = milestone_type(mile)
    if miletype == 'uniq' and not milestone_desc(mile).startswith('banished '):
        do_milestone_unique(c, mile)
    elif miletype == 'rune':
        do_milestone_rune(c, mile)
    elif miletype == 'ghost':
        do_milestone_ghost(c, mile)
    elif miletype == 'br.enter':
        do_milestone_br_enter(c, mile)
    elif miletype == 'br.end':
        do_milestone_br_end(c, mile)
    elif miletype == 'god.maxpiety':
        do_milestone_max_piety(c, mile)
    elif miletype == 'zig':
        do_milestone_zig(c, mile)
    elif miletype == 'zig.exit':
        do_milestone_zig_exit(c, mile)
    elif miletype == 'abyss.enter':
        do_milestone_abyss_enter(c, mile)
    elif miletype == 'abyss.exit':
        do_milestone_abyss_exit(c, mile)
    elif miletype == 'god.mollify':
        do_milestone_mollify(c, mile)
Example #10
0
def act_on_milestone(c, mile):
  """This function takes a milestone line, which is a string composed of key/
  value pairs separated by colons, and parses it into a dictionary.
  Then, depending on what type of milestone it is (key "type"), another
  function may be called to finish the job on the milestone line. Milestones
  have the same broken :: behavior as logfile lines, yay."""

  player = game_player(mile)

  if mile['xl'] >= 13:
    banner.award_banner(c, player, 'okawaru', 1)

  if mile['goldfound'] >= 1000:
    banner.award_banner(c, player, 'gozag', 1)

  if mile['xl'] >= 9 and nemelex.is_nemelex_choice(mile['char'],mile['start']):
    ban = 'nemelex:' + mile['char']
    banner.award_banner(c, player, ban, 1)

  # hack to handle milestones with no potions_used/scrolls_used fields
  if not mile.has_key('potionsused'):
    mile['potionsused'] = -1
    mile['scrollsused'] = -1

  miletype = milestone_type(mile)
  if miletype == 'uniq' and not milestone_desc(mile).startswith('banished '):
    do_milestone_unique(c, mile)
  elif miletype == 'rune':
    do_milestone_rune(c, mile)
  elif miletype == 'ghost':
    do_milestone_ghost(c, mile)
  elif miletype == 'br.enter':
    do_milestone_br_enter(c, mile)
  elif miletype == 'br.end':
    do_milestone_br_end(c, mile)
  elif miletype == 'god.maxpiety':
    do_milestone_max_piety(c, mile)
  elif miletype == 'zig':
    do_milestone_zig(c, mile)
  elif miletype == 'zig.exit':
    do_milestone_zig_exit(c, mile)
  elif miletype == 'abyss.enter':
    do_milestone_abyss_enter(c, mile)
  elif miletype == 'abyss.exit':
    do_milestone_abyss_exit(c, mile)
  elif miletype == 'god.mollify':
    do_milestone_mollify(c, mile)
Example #11
0
def act_on_milestone(c, mile):
    """This function takes a milestone line, which is a string composed of key/
  value pairs separated by colons, and parses it into a dictionary.
  Then, depending on what type of milestone it is (key "type"), another
  function may be called to finish the job on the milestone line. Milestones
  have the same broken :: behavior as logfile lines, yay."""

    player = game_player(mile)

    if mile["xl"] >= 13:
        banner.award_banner(c, player, "okawaru", 1)

    if mile["goldfound"] >= 1000:
        banner.award_banner(c, player, "gozag", 1)

    if mile["xl"] >= 9 and nemelex.is_nemelex_choice(mile["char"], mile["start"]):
        ban = "nemelex:" + mile["char"]
        banner.award_banner(c, player, ban, 1)

    # hack to handle milestones with no potions_used/scrolls_used fields
    if not mile.has_key("potionsused"):
        mile["potionsused"] = -1
        mile["scrollsused"] = -1

    miletype = milestone_type(mile)
    if miletype == "uniq" and not milestone_desc(mile).startswith("banished "):
        do_milestone_unique(c, mile)
    elif miletype == "rune":
        do_milestone_rune(c, mile)
    elif miletype == "ghost":
        do_milestone_ghost(c, mile)
    elif miletype == "br.enter":
        do_milestone_br_enter(c, mile)
    elif miletype == "br.end":
        do_milestone_br_end(c, mile)
    elif miletype == "god.maxpiety":
        do_milestone_max_piety(c, mile)
    elif miletype == "zig":
        do_milestone_zig(c, mile)
    elif miletype == "zig.exit":
        do_milestone_zig_exit(c, mile)
    elif miletype == "abyss.enter":
        do_milestone_abyss_enter(c, mile)
    elif miletype == "abyss.exit":
        do_milestone_abyss_exit(c, mile)
    elif miletype == "god.mollify":
        do_milestone_mollify(c, mile)
Example #12
0
def crunch_misc(c, g):
    player = g["name"]
    ktyp = g["ktyp"]

    if g["xl"] >= 13:
        banner.award_banner(c, player, "okawaru", 1)

    if g["goldfound"] >= 1000:
        banner.award_banner(c, player, "gozag", 1)

    if g["xl"] >= 9 and nemelex.is_nemelex_choice(g["char"], g["start"]):
        ban = "nemelex:" + g["char"]
        banner.award_banner(c, player, ban, 1)
    if g["xl"] >= 9 and query.check_xl9_streak(c, player, g["start"]):
        banner.award_banner(c, player, "cheibriados", 1)
    if g["sc"] >= 1000:
        og = query.previous_combo_highscore(c, g)
        if og and og[0] != player and og[1] >= 1000 and og[1] < g["sc"]:
            banner.award_banner(c, player, "dithmenos", 1)

    killer = loaddb.strip_unique_qualifier(g.get("killer") or "")
    if uniq.is_uniq(killer):
        query_do(
            c,
            """INSERT INTO deaths_to_uniques
                            (player, uniq, start_time, end_time)
                     VALUES (%s, %s, %s, %s)""",
            player.lower(),
            killer,
            g["start"],
            g["end"],
        )
        cuniqdeaths = query.count_deaths_to_distinct_uniques(c, player)
        olduniqdeaths = query.lookup_deaths_to_distinct_uniques(c, player)
        if cuniqdeaths > olduniqdeaths:
            query.update_deaths_to_distinct_uniques(c, player, cuniqdeaths, g["end"])
Example #13
0
def crunch_winner(c, game, filename):
  """A game that wins could assign a variety of irrevocable points for a
  variety of different things. This function needs to calculate them all."""

  player = game['name']
  charabbrev = game_character(game)
  game_start = game_start_time(game)
  game_end = game_end_time(game)

  if game['dur'] <= 10800:
    banner.award_banner(c, player, 'makhleb', 3)

  if game['sk'] == 'Invocations':
    banner.award_banner(c, player, 'qazlal', 2)
    if query.player_count_invo_titles(c, player) >= 3:
      banner.award_banner(c, player, 'qazlal', 3)

  if query.check_ru_abandonment_game(c, player, game_start_time(game)):
    banner.award_banner(c, player, 'lugonu', 3)

  if not query.game_did_visit_lair(c, player, game_start_time(game)):
    if not query.game_did_visit_branch(c, player, game_start_time(game)):
      banner.award_banner(c, player, 'kikubaaqudgha', 3)

  if game['race'] != 'Gnoll' and game['sklev'] < 20:
    if not query.did_worship_god(c, 'Ashenzari', player, game['start'], game['end']):
      if game['sklev'] < 13:
        banner.award_banner(c, player, 'sif', 3)
      else:
        banner.award_banner(c, player, 'sif', 2)

  if game['xl'] < 19:
    if not query.did_sacrifice(c, 'experience', player, game['start'], game['end']) and not query.did_worship_god(c, 'Hepliaklqana',
                      game['name'], game['start'], game['end']) and not game['race'] == 'Felid':
      banner.award_banner(c, player, 'vehumet', 3)

  #cutoff = query.time_from_str(game['end']) - datetime.timedelta(hours=27)
  #if query.time_from_str(game['start']) > cutoff:
  #  if query.count_wins(c, player = game['name'], before = game_end, after = cutoff) > 0:
  #    banner.award_banner(c, player, 'oldbanner', 3)
  #  else:
  #    banner.award_banner(c, player, 'oldbanner', 2)

  ogame = query.previous_combo_highscore(c, game)
  if ogame and ogame[0] != player and ogame[2] == 'winning' and ogame[1] < game['sc']:
    banner.award_banner(c, player, 'dithmenos', 2)
  if game['sc'] >= 10000000:
    ogame = query.previous_species_highscore(c, game)
    if ogame and ogame[1] >= 10000000 and ogame[1] < game['sc'] and ogame[0] != player:
      banner.award_banner(c, player, 'dithmenos', 3)
    ogame = query.previous_class_highscore(c, game)
    if ogame and ogame[1] >= 10000000 and ogame[1] < game['sc'] and ogame[0] != player:
      banner.award_banner(c, player, 'dithmenos', 3)

  debug("%s win (%s), runes: %d" % (player, charabbrev, game.get('urune') or 0))

  if nemelex.is_nemelex_choice(charabbrev, game_end) \
       and not nemelex.player_has_nemelex_win(c, player, charabbrev):
    nemelex.award_nemelex_win(c, game, filename)
    banner.award_banner(c, player, 'nemelex', 3)

  if query.is_unbeliever(c, game):
    banner.award_banner(c, player, 'trog', 3)

  if query.did_use_ecumenical_altar(c, game['name'], game['start'], game['end']) \
      and not query.did_renounce_god(c, game['name'], game['start'], game['end']):
    banner.award_banner(c, game['name'], 'hepliaklqana', 3)

  if is_all_runer(game):
    all_allruners = number_of_allruners_before(c, game)

  previous_wins = query.count_wins(c, before = game_end)

  my_wins = query.get_winning_games(c, player = game['name'],
                                    before = game_end)
  n_my_wins = len(my_wins)

  if n_my_wins == 0:
    # First win!
    query.assign_nonrep_win(c, game['name'], 1)
  else:
    for x in my_wins:
      if repeat_race_class(x['charabbrev'], game['char']) == 0:
        query.assign_nonrep_win(c, game['name'], 2)

  did_streak = query.win_is_streak(c, game['name'], game_start)
  if did_streak:
    # Award banner.
    banner.award_banner(c, player, 'cheibriados', 2)

  game_god = query.get_game_god(c, game)
  banner_god = game_god.lower().replace(' ', '_')
  if (not game_god == 'faithless'):
    query.record_won_god(c, game['name'], game_god)
Example #14
0
def do_milestone_rune(c, mile):
  """Give out banners for certain special rune finds."""
  # Check if this player already found this kind of rune. Remember the db
  # is already updated, so for the first rune the count will be 1.
  rune = loaddb.extract_rune(mile['milestone'])
  num_rune = query.player_count_runes(c, mile['name'], rune)
  player = mile['name']
  runes_found = query.player_count_distinct_runes(c, player)
  if mile['dur'] <= 4860:
    banner.award_banner(c, mile['name'], 'makhleb', 2)
  if runes_found == crawl.NRUNES:
    banner.award_banner(c, player, 'ashenzari', 3)
  elif runes_found >= 5:
    banner.award_banner(c, player, 'ashenzari', 2)
  if rune == 'golden' and num_rune == 1:
    banner.award_banner(c, player, 'fedhas', 2)
  if rune == 'silver' and num_rune == 1:
    banner.award_banner(c, player, 'gozag', 2)
  did_ecu = query.did_use_ecumenical_altar(c, mile['name'], mile['start'],
		mile['time'])
  did_renounce = query.did_renounce_god(c, mile['name'], mile['start'],
			mile['time'])
  if (did_ecu and not did_renounce):
    banner.award_banner(c, player, 'hepliaklqana', 2)

  # The abyssal rune is the only rune that the player can get before the iron
  # rune for Avarice 3.
  if rune == 'iron' and mile['urune'] <= 2:
    other_rune_branches = ['Vaults', 'Shoals', 'Snake', 'Spider', 'Swamp', 'Slime', 'Pan', 'Coc', 'Geh', 'Tar']
    eligible = True
    for br in other_rune_branches:
      if query.did_enter_branch(c, br, player, mile['start'], mile['time']):
        eligible = False
        break
    if eligible:
      banner.award_banner(c, player, 'gozag', 3)

  if nemelex.is_nemelex_choice(mile['char'], mile['time']):
    banner.award_banner(c, player, 'nemelex', 2)
  if not query.did_enter_branch(c, 'Depths', player, mile['start'], mile['time']):
    if mile['urune'] == 6:
      banner.award_banner(c, player, 'the_shining_one', 3)
    elif mile['urune'] >= 4:
      banner.award_banner(c, player, 'the_shining_one', 2)
  #if query.time_from_str(mile['time']) - query.time_from_str(mile['start']) <= datetime.timedelta(hours=27):
  #  banner.award_banner(c, mile['name'], 'oldbanner', 1)
  if query.is_unbeliever(c, mile):
    banner.award_banner(c, mile['name'], 'trog', 2)
  if rune != 'slimy' and rune != 'abyssal':
    if mile['potionsused'] == 0 and mile['scrollsused'] == 0:
      banner.award_banner(c, mile['name'], 'ru', 3)
  if mile['urune'] == 1:
    if mile['xl'] < 14:
      if not query.did_sacrifice(c, 'experience', mile['name'], mile['start'], mile['time']) and not query.did_worship_god(c, 'Hepliaklqana',
                      mile['name'], mile['start'], mile['time']) and not mile['race'] == 'Felid':
        banner.award_banner(c, mile['name'], 'vehumet', 2)

  if mile['br'] in [ 'Shoals', 'Slime', 'Snake', 'Spider', 'Swamp'] and mile['turn'] - query.branch_end_turn(c, mile['br'], mile['name'], mile['start']) <= 810:
      banner.award_banner(c, mile['name'], 'uskayaw', 1)
  if rune == 'silver' and mile['turn'] - query.branch_end_turn(c, 'Vaults', mile['name'], mile['start']) <= 540:
      banner.award_banner(c, mile['name'], 'uskayaw', 2)
Example #15
0
def crunch_winner(c, game):
  """A game that wins could assign a variety of irrevocable points for a
  variety of different things. This function needs to calculate them all."""

  player = game['name']
  charabbrev = game_character(game)
  game_start = game_start_time(game)
  game_end = game_end_time(game)

  # 20 clan points for first win for a particular combo in the tournament.
  if query.first_win_for_combo(c, charabbrev, game_end):
    assign_team_points(c, "combo_first_win:" + charabbrev, player, 20)

  # Award Okawaru banners for wins.
  banner.award_banner(c, player, 'okawaru', 2)
  if game['turn'] < 50000:
    banner.award_banner(c, player, 'okawaru', 3)

  if game['dur'] <= 10800:
    banner.award_banner(c, player, 'makhleb', 3)

  if game['sk'] == 'Invocations':
    banner.award_banner(c, player, 'qazlal', 2)
    if query.player_count_invo_titles(c, player) >= 3:
      banner.award_banner(c, player, 'qazlal', 3)

  #gods_abandoned = query.count_gods_abandoned(c, player, game_start_time(game))
  #if gods_abandoned >= 9:
  #  assign_points(c, 'heretical_win', player, 25)
  #  banner.award_banner(c, player, 'lugonu', 3)
  #elif gods_abandoned >= 3:
  #  banner.award_banner(c, player, 'lugonu', 2)

  if query.check_ru_abandonment_game(c, player, game_start_time(game)):
    banner.award_banner(c, player, 'lugonu', 3)

  if not query.game_did_visit_lair(c, player, game_start_time(game)):
    if not query.game_did_visit_branch(c, player, game_start_time(game)):
      # 50 bonus points for winning without doing any branches.
      assign_points(c, 'branchless_win', player, 50, False)
      # And the banner:
      banner.award_banner(c, player, 'kikubaaqudgha', 3)
    # else:
      # Just 20 bonus points for winning without doing Lair.
      # assign_points(c, 'lairless_win', player, 20)

  if game['sklev'] < 20:
    if not query.did_worship_god(c, 'Ashenzari', player, game['start'], game['end']):
      if game['sklev'] < 13:
        banner.award_banner(c, player, 'sif', 3)
      else:
        banner.award_banner(c, player, 'sif', 2)

  if game['xl'] < 19:
    if not query.did_sacrifice(c, 'experience', player, game['start'], game['end']):
      assign_points(c, 'ruthless_efficiency', player, 25, False)
      banner.award_banner(c, player, 'vehumet', 3)

  #cutoff = query.time_from_str(game['end']) - datetime.timedelta(hours=27)
  #if query.time_from_str(game['start']) > cutoff:
  #  if query.count_wins(c, player = game['name'], before = game_end, after = cutoff) > 0:
  #    banner.award_banner(c, player, 'oldbanner', 3)
  #  else:
  #    banner.award_banner(c, player, 'oldbanner', 2)

  ogame = query.previous_combo_highscore(c, game)
  if ogame and ogame[0] != player and ogame[2] == 'winning' and ogame[1] < game['sc']:
    banner.award_banner(c, player, 'dithmenos', 2)
  if game['sc'] >= 10000000:
    ogame = query.previous_species_highscore(c, game)
    if ogame and ogame[1] >= 10000000 and ogame[1] < game['sc'] and ogame[0] != player:
      banner.award_banner(c, player, 'dithmenos', 3)
    ogame = query.previous_class_highscore(c, game)
    if ogame and ogame[1] >= 10000000 and ogame[1] < game['sc'] and ogame[0] != player:
      banner.award_banner(c, player, 'dithmenos', 3)

  debug("%s win (%s), runes: %d" % (player, charabbrev, game.get('urune') or 0))

  if nemelex.is_nemelex_choice(charabbrev, game_end):
    ban = 'nemelex:' + charabbrev
    if banner.count_recipients(c, ban, 3) < 8:
      if not banner.player_has_banner(c, player, ban, 3):
        query.assign_stepdown_points(c, ban, player, 75)
        banner.award_banner(c, player, ban, 3)

  if query.is_unbeliever(c, game):
    banner.award_banner(c, player, 'trog', 3)

  if query.did_use_ecumenical_altar(c, game['name'], game['start'], game['end']) \
      and not query.did_renounce_god(c, game['name'], game['start'], game['end']):
    banner.award_banner(c, game['name'], 'hepliaklqana', 3)

  if is_all_runer(game):
    all_allruners = number_of_allruners_before(c, game)
    assign_points(c, "nth_allrune_win:%d" % (all_allruners + 1),
                  game['name'],
                  get_points(all_allruners, 200, 100, 50))

    # If this is my first all-rune win, 50 points!
    #if query.count_wins(c, player = game['name'],
    #                    runes = query.MAX_RUNES,
    #                    before = game_end) == 0:
    #  assign_points(c, "my_1st_all_rune_win", game['name'], 50)

  previous_wins = query.count_wins(c, before = game_end)
  assign_points(c,
                "nth_win:%d" % (previous_wins + 1),
                game['name'], get_points(previous_wins, 200, 100, 50))

  my_wins = query.get_winning_games(c, player = game['name'],
                                    before = game_end)
  n_my_wins = len(my_wins)

  if n_my_wins == 0:
    # First win!
    assign_points(c, "my_1st_win", game['name'], 100)

  else:
    # If the new win is a different race/class from a previous win, bonus!
    for x in my_wins:
      if repeat_race_class(x['charabbrev'], game['char']) == 0:
        assign_points(c, "my_2nd_win_norep", game['name'], 50, False)

  did_streak = query.win_is_streak(c, game['name'], game_start)
  if did_streak:
    # Award banner.
    banner.award_banner(c, player, 'cheibriados', 2)

  # Assign points for new personal records.
  assign_points(c, 'my_low_turncount_win', game['name'], 5000000/game['turn'], False)
  assign_points(c, 'my_low_realtime_win', game['name'], 1250000/game['dur'], False)
  assign_points(c, 'my_highscore_win', game['name'], game['sc']/120000, False)

  # Assign race/class points, based on the games won before the start
  # of the given win.
  game_start = game_start_time(game)
  wins_before = query.count_wins(c, before=game_start)
  species_wins_before = query.count_wins(c, before=game_start, raceabbr=game['char'][0:2])
  class_wins_before = query.count_wins(c, before=game_start, classabbr=game['char'][2:])
  query.assign_stepdown_points(c, 'species_win:' + game['char'][0:2], game['name'], query.race_formula(wins_before, species_wins_before), False)
  query.assign_stepdown_points(c, 'background_win:' + game['char'][2:], game['name'], query.class_formula(wins_before, class_wins_before), False)
  # and gods also
  game_god = query.get_game_god(c, game)
  banner_god = game_god.lower().replace(' ', '_')
  if (not game_god == 'faithless'):
    query.record_won_god(c, game['name'], game['end'], game_god)
    god_wins_before = query.count_god_wins(c, game_god, game_start)
    query.assign_stepdown_points(c, 'god_win:' + banner_god, game['name'], query.god_formula(wins_before, god_wins_before), False)
Example #16
0
def crunch_winner(c, game):
  """A game that wins could assign a variety of irrevocable points for a
  variety of different things. This function needs to calculate them all."""

  player = game['name']
  charabbrev = game_character(game)
  game_start = game_start_time(game)
  game_end = game_end_time(game)

  # 20 clan points for first win for a particular combo in the tournament.
  if query.first_win_for_combo(c, charabbrev, game_end):
    assign_team_points(c, "combo_first_win:" + charabbrev, player, 20)

  # Award Okawaru banners for wins.
  banner.award_banner(c, player, 'okawaru', 2)
  if (game['turn'] < 50000):
    banner.award_banner(c, player, 'okawaru', 3)

  if game['dur'] <= 10800:
    banner.award_banner(c, player, 'makhleb', 3)

  if game['sk'] == 'Invocations':
    banner.award_banner(c, player, 'qazlal', 2)
    if query.player_count_invo_titles(c, player) >= 3:
      banner.award_banner(c, player, 'qazlal', 3)

  #gods_abandoned = query.count_gods_abandoned(c, player, game_start_time(game))
  #if gods_abandoned >= 9:
  #  assign_points(c, 'heretical_win', player, 25)
  #  banner.award_banner(c, player, 'lugonu', 3)
  #elif gods_abandoned >= 3:
  #  banner.award_banner(c, player, 'lugonu', 2)

  if query.check_ru_abandonment_game(c, player, game_start_time(game)):
    banner.award_banner(c, player, 'lugonu', 3)

  if not query.game_did_visit_lair(c, player, game_start_time(game)):
    if not query.game_did_visit_branch(c, player, game_start_time(game)):
      # 50 bonus points for winning without doing any branches.
      assign_points(c, 'branchless_win', player, 50, False)
      # And the banner:
      banner.award_banner(c, player, 'kikubaaqudgha', 3)
    # else:
      # Just 20 bonus points for winning without doing Lair.
      # assign_points(c, 'lairless_win', player, 20)

  if game['sklev'] < 20:
    if not query.did_worship_god(c, 'Ashenzari', player, game['start'], game['end']):
      if game['sklev'] < 13:
        banner.award_banner(c, player, 'sif', 3)
      else:
        banner.award_banner(c, player, 'sif', 2)

  if game['xl'] < 19:
    if not query.did_sacrifice(c, 'experience', player, game['start'], game['end']):
      assign_points(c, 'ruthless_efficiency', player, 25, False)
      banner.award_banner(c, player, 'vehumet', 3)

  #cutoff = query.time_from_str(game['end']) - datetime.timedelta(hours=27)
  #if query.time_from_str(game['start']) > cutoff:
  #  if query.count_wins(c, player = game['name'], before = game_end, after = cutoff) > 0:
  #    banner.award_banner(c, player, 'oldbanner', 3)
  #  else:
  #    banner.award_banner(c, player, 'oldbanner', 2)

  ogame = query.previous_combo_highscore(c, game)
  if ogame and ogame[0] != player and ogame[2] == 'winning' and ogame[1] < game['sc']:
    banner.award_banner(c, player, 'dithmenos', 2)
  if game['sc'] >= 10000000:
    ogame = query.previous_species_highscore(c, game)
    if ogame and ogame[1] >= 10000000 and ogame[1] < game['sc'] and ogame[0] != player:
      banner.award_banner(c, player, 'dithmenos', 3)
    ogame = query.previous_class_highscore(c, game)
    if ogame and ogame[1] >= 10000000 and ogame[1] < game['sc'] and ogame[0] != player:
      banner.award_banner(c, player, 'dithmenos', 3)

  debug("%s win (%s), runes: %d" % (player, charabbrev, game.get('urune') or 0))

  if nemelex.is_nemelex_choice(charabbrev, game_end):
    ban = 'nemelex:' + charabbrev
    if banner.count_recipients(c, ban, 3) < 8:
      if not banner.player_has_banner(c, player, ban, 3):
        query.assign_stepdown_points(c, ban, player, 75)
        banner.award_banner(c, player, ban, 3)

  if query.is_unbeliever(c, game):
    banner.award_banner(c, player, 'trog', 3)

  if is_all_runer(game):
    all_allruners = number_of_allruners_before(c, game)
    assign_points(c, "nth_allrune_win:%d" % (all_allruners + 1),
                  game['name'],
                  get_points(all_allruners, 200, 100, 50))

    # If this is my first all-rune win, 50 points!
    #if query.count_wins(c, player = game['name'],
    #                    runes = query.MAX_RUNES,
    #                    before = game_end) == 0:
    #  assign_points(c, "my_1st_all_rune_win", game['name'], 50)

  previous_wins = query.count_wins(c, before = game_end)
  assign_points(c,
                "nth_win:%d" % (previous_wins + 1),
                game['name'], get_points(previous_wins, 200, 100, 50))

  my_wins = query.get_winning_games(c, player = game['name'],
                                    before = game_end)
  n_my_wins = len(my_wins)

  if n_my_wins == 0:
    # First win!
    assign_points(c, "my_1st_win", game['name'], 100)

  else:
    # If the new win is a different race/class from a previous win, bonus!
    for x in my_wins:
      if repeat_race_class(x['charabbrev'], game['char']) == 0:
        assign_points(c, "my_2nd_win_norep", game['name'], 50, False)

  did_streak = query.win_is_streak(c, game['name'], game_start)
  if did_streak:
    # Award banner.
    banner.award_banner(c, player, 'cheibriados', 2)

  # Assign points for new personal records.
  assign_points(c, 'my_low_turncount_win', game['name'], 5000000/game['turn'], False)
  assign_points(c, 'my_low_realtime_win', game['name'], 1250000/game['dur'], False)
  assign_points(c, 'my_highscore_win', game['name'], game['sc']/120000, False)

  # Assign race/class points, based on the games won before the start
  # of the given win.
  game_start = game_start_time(game)
  wins_before = query.count_wins(c, before=game_start)
  species_wins_before = query.count_wins(c, before=game_start, raceabbr=game['char'][0:2])
  class_wins_before = query.count_wins(c, before=game_start, classabbr=game['char'][2:])
  query.assign_stepdown_points(c, 'species_win:' + game['char'][0:2], game['name'], query.race_formula(wins_before, species_wins_before), False)
  query.assign_stepdown_points(c, 'background_win:' + game['char'][2:], game['name'], query.class_formula(wins_before, class_wins_before), False)
  # and gods also
  game_god = query.get_game_god(c, game)
  banner_god = game_god.lower().replace(' ', '_')
  if (not game_god == 'faithless'):
    query.record_won_god(c, game['name'], game['end'], game_god)
    god_wins_before = query.count_god_wins(c, game_god, game_start)
    query.assign_stepdown_points(c, 'god_win:' + banner_god, game['name'], query.god_formula(wins_before, god_wins_before), False)
Example #17
0
def crunch_winner(c, game):
  """A game that wins could assign a variety of irrevocable points for a
  variety of different things. This function needs to calculate them all."""

  player = game['name']
  charabbrev = game_character(game)
  game_end = game_end_time(game)

  # 20 clan points for first win for a particular combo in the tournament.
  if query.first_win_for_combo(c, charabbrev, game_end):
    assign_team_points(c, "combo_first_win:" + charabbrev, player, 20)

  # Award Okawaru banners for wins.
  banner.award_banner(c, player, 'okawaru', 2)
  if (game['turn'] < 50000):
    banner.award_banner(c, player, 'okawaru', 3)

  if not query.game_did_visit_lair(c, player, game_start_time(game)):
    # assign_points(c, 'lairless_win', player, 20)
    if not query.game_did_visit_branch(c, player, game_start_time(game)):
      # 50 bonus points for winning without doing any branches.
      assign_points(c, 'branchless_win', player, 50)
      # And the banner:
      banner.award_banner(c, player, 'kikubaaqudgha', 3)
    else:
      banner.award_banner(c, player, 'kikubaaqudgha', 2)

  ogame = query.previous_combo_highscore(c, game)
  if ogame and ogame[0] != player and ogame[2] == 'winning' and ogame[1] < game['sc']:
    banner.award_banner(c, player, 'trog', 2)
  if game['sc'] >= 10000000:
    ogame = query.previous_species_highscore(c, game)
    if ogame and ogame[1] >= 10000000 and ogame[1] < game['sc'] and ogame[0] != player:
      banner.award_banner(c, player, 'trog', 3)
    ogame = query.previous_class_highscore(c, game)
    if ogame and ogame[1] >= 10000000 and ogame[1] < game['sc'] and ogame[0] != player:
      banner.award_banner(c, player, 'trog', 3)

  debug("%s win (%s), runes: %d" % (player, charabbrev, game.get('urune') or 0))

  if nemelex.is_nemelex_choice(charabbrev, game_end):
    ban = 'nemelex:' + charabbrev
    if banner.count_recipients(c, ban, 3) < 5:
      if not banner.player_has_banner(c, player, ban, 3):
        assign_points(c, ban, player, 75)
        banner.award_banner(c, player, ban, 3)

  if is_all_runer(game):
    all_allruners = number_of_allruners_before(c, game)
    assign_points(c, "nth_all_rune_win:%d" % (all_allruners + 1),
                  game['name'],
                  get_points(all_allruners, 200, 100, 50))

    # If this is my first all-rune win, 50 points!
    #if query.count_wins(c, player = game['name'],
    #                    runes = query.MAX_RUNES,
    #                    before = game_end) == 0:
    #  assign_points(c, "my_1st_all_rune_win", game['name'], 50)

  previous_wins = query.count_wins(c, before = game_end)
  assign_points(c,
                "nth_win:%d" % (previous_wins + 1),
                game['name'], get_points(previous_wins, 200, 100, 50))

  my_wins = query.get_winning_games(c, player = game['name'],
                                    before = game_end)
  n_my_wins = len(my_wins)

  repeated = 0
  if n_my_wins > 0:
    repeated = repeat_race_class([x['charabbrev'] for x in my_wins],
                                 game['char'])

  if n_my_wins == 0:
    # First win! I bet you don't have a streak
    assign_points(c, "my_1st_win", game['name'], 100)

  elif n_my_wins == 1 and repeated == 0:
    # Second win! If neither repeated race or class, bonus!
    assign_points(c, "my_2nd_win_norep", game['name'], 50)

  #else:
    # Any win gets 10 points at this point.
    #assign_points(c, "my_win", game['name'], 10)

  streak_wins = query.wins_in_streak_before(c, game['name'], game_end)
  debug("%s win (%s), previous games in streak: %s" %
        (game['name'], game['char'], streak_wins))
  if not streak_wins:
    query.kill_active_streak(c, player)
    streak_len = -1
  else:
    # Award banner.
    banner.award_banner(c, player, 'cheibriados', 2)
    # This length could be 1 even though it involves at least two games, beware!
    streak_len = compute_streak_length(streak_wins, game['char'])
    if len(streak_wins) >= 2:
      if compute_streak_length(streak_wins[-2:], game['char']) == 3:
        banner.award_banner(c, player, 'cheibriados', 3)
    streak_species = 'streak_species:'+(game['char'][0:2])
    streak_class = 'streak_class:'+(game['char'][2:])
    # 75 points for streak games, but only if they are with a new race and class.
    assign_points(c, streak_species, game['name'], 60, False)
    assign_points(c, streak_class, game['name'], 30, False)
  query.update_active_streak(c, player, game_end, streak_len)

  if streak_len > 1:
    # Update the streaks table. We're still in the logfile transaction
    # here, so it's safe.
    if streak_len > loaddb.longest_streak_count(c, game['name']):
      loaddb.update_streak_count(c, game, streak_len)

  # Assign points for new personal records.
  assign_points(c, 'my_low_turncount_win', game['name'], 5000000/game['turn'], False)
  assign_points(c, 'my_low_realtime_win', game['name'], 1250000/game['dur'], False)
  assign_points(c, 'my_highscore_win', game['name'], game['sc']/120000, False)

  # Assign race/class points, based on the games won before the start
  # of the given win.
  game_start = game_start_time(game)
  wins_before = query.count_wins(c, before=game_start)
  species_wins_before = query.count_wins(c, before=game_start, raceabbr=game['char'][0:2])
  class_wins_before = query.count_wins(c, before=game_start, classabbr=game['char'][2:])
  assign_points(c, 'species_win:' + game['char'][0:2], game['name'], query.race_formula(wins_before, species_wins_before), False)
  assign_points(c, 'class_win:' + game['char'][2:], game['name'], query.class_formula(wins_before, class_wins_before), False)
  # and gods also
  game_god = query.get_game_god(c, game)
  banner_god = game_god.lower().replace(' ', '_')
  if (not game_god == 'faithless'):
    query.record_won_god(c, game['name'], game['end'], game_god)
    god_wins_before = query.count_god_wins(c, game_god, game_start)
    assign_points(c, 'god_win:' + banner_god, game['name'], query.god_formula(wins_before, god_wins_before), False)
  if game['goldspent'] == 0:
    if game_god == 'No God':
      banner.award_banner(c, game['name'], 'sif', 3)
    else:
      banner.award_banner(c, game['name'], 'sif', 2)
Example #18
0
def do_milestone_rune(c, mile):
  """Give out 24/N points for the Nth time a player finds a rune, and also give out banners."""
  # Check if this player already found this kind of rune. Remember the db
  # is already updated, so for the first rune the count will be 1.
  rune = loaddb.extract_rune(mile['milestone'])
  num_rune = query.player_count_runes(c, mile['name'], rune)
  rune_points = (24 + num_rune - 1) / num_rune
  assign_points(c, "rune:" + rune, mile['name'], rune_points)
  player = mile['name']
  runes_found = query.player_count_distinct_runes(c, player)
  if mile['dur'] <= 4860:
    banner.award_banner(c, mile['name'], 'makhleb', 2)
  if runes_found == crawl.NRUNES:
    banner.award_banner(c, player, 'ashenzari', 3)
  elif runes_found >= 5:
    banner.award_banner(c, player, 'ashenzari', 2)
  if rune == 'golden' and num_rune == 1:
    banner.award_banner(c, player, 'fedhas', 2)
  if rune == 'silver' and num_rune == 1:
    banner.award_banner(c, player, 'gozag', 2)
  did_ecu = query.did_use_ecumenical_altar(c, mile['name'], mile['start'],
		mile['time'])
  did_renounce = query.did_renounce_god(c, mile['name'], mile['start'],
			mile['time'])
  if (did_ecu and not did_renounce):
    banner.award_banner(c, player, 'hepliaklqana', 2)

  # The abyssal rune is the only rune that the player can get before the iron
  # rune for Avarice 3.
  if rune == 'iron' and mile['urune'] <= 2:
    other_rune_branches = ['Vaults', 'Shoals', 'Snake', 'Spider', 'Swamp', 'Slime', 'Pan', 'Coc', 'Geh', 'Tar']
    eligible = True
    for br in other_rune_branches:
      if query.did_enter_branch(c, br, player, mile['start'], mile['time']):
        eligible = False
        break
    if eligible:
      assign_points(c, 'avarice', player, 25, False)
      banner.award_banner(c, player, 'gozag', 3)

  if nemelex.is_nemelex_choice(mile['char'], mile['time']):
    ban = 'nemelex:' + mile['char']
    banner.award_banner(c, player, ban, 2)
  if not query.did_enter_branch(c, 'Depths', player, mile['start'], mile['time']):
    if mile['urune'] == 6:
      assign_points(c, 'vow_of_courage', player, 25, False)
      banner.award_banner(c, player, 'the_shining_one', 3)
    elif mile['urune'] >= 4:
      banner.award_banner(c, player, 'the_shining_one', 2)
  #if query.time_from_str(mile['time']) - query.time_from_str(mile['start']) <= datetime.timedelta(hours=27):
  #  banner.award_banner(c, mile['name'], 'oldbanner', 1)
  if query.is_unbeliever(c, mile):
    banner.award_banner(c, mile['name'], 'trog', 2)
  if mile['urune'] == 1:
    if rune != 'slimy' and rune != 'abyssal':
      if mile['potionsused'] == 0 and mile['scrollsused'] == 0:
        assign_points(c, 'ascetic', player, 25, False)
        banner.award_banner(c, mile['name'], 'ru', 3)
    if mile['xl'] < 14:
      if not query.did_sacrifice(c, 'experience', mile['name'], mile['start'], mile['time']):
        banner.award_banner(c, mile['name'], 'vehumet', 2)