Beispiel #1
0
def make4FluffCharacters():
    newCharacter0 = Character(CharacterSheet('Bunemaster Thorn',
                                  12,
                                  4,
                                  0,
                                  5,
                                  0,
                                  0,
                                  3,
                                  0,
                                  0,
                                  3,
                                  2,
                                  'base'))
    newCharacter1 = Character(CharacterSheet('Red Scorpion',
                                  12,
                                  4,
                                  1,
                                  4,
                                  1,
                                  1,
                                  1,
                                  1,
                                  1,
                                  1,
                                  3,
                                  'base'))
    newCharacter2 = Character(CharacterSheet('Steelhorns',
                                  16,
                                  3,
                                  1,
                                  4,
                                  3,
                                  0,
                                  0,
                                  3,
                                  0,
                                  0,
                                  3,
                                  'base'))
    newCharacter3 = Character(CharacterSheet('Tonan of the Wild',
                                  12,
                                  4,
                                  1,
                                  5,
                                  1,
                                  2,
                                  0,
                                  1,
                                  2,
                                  0,
                                  3,
                                  'base'))
    return {newCharacter0.name: newCharacter0,
            newCharacter1.name: newCharacter1,
            newCharacter2.name: newCharacter2,
            newCharacter3.name: newCharacter3,}
Beispiel #2
0
def test_average_spell_schools(raw_spell, character, average_spell_school):
    character = Character(morgue_filepath=f"support/{character}.txt",
                          local_mode=True)
    spell = SpellFactory(raw_spell).new()
    spell_calculator = SpellCalculator(character=character, spell=spell)
    result = spell_calculator._average_spell_schools()
    assert round(result, 2) == average_spell_school
Beispiel #3
0
def save_a_buncha_info(character_name):
    character = Character(name=character_name)
    morgue_db = MorgueDB(character_name)
    morgue_file = character.s3_morgue_file()
    morgue_parser = MorgueParser(morgue_file)
    try:
        runes = morgue_parser.runes()
        if runes:
            nice_runes = [rune.strip() for rune in runes.split(",")]
            morgue_db.save_stuff("SS", "runes", nice_runes)

        xl_level = fetch_xl_level(morgue_file)
        if xl_level:
            morgue_db.save_stuff("S", "xl", xl_level.strip())

        weapons = fetch_weapons(morgue_file)
        if weapons:
            morgue_db.save_stuff("SS", "weapons", weapons)

        # gods = fetch_altars(morgue_file)
        # morgue_db.save_stuff("SS", "gods", gods)

        armour = fetch_armour(morgue_file)
        if armour:
            morgue_db.save_stuff("SS", "armour", armour)
    except Exception as e:
        print(f"Error in save_a_buncha_info by we are ok: {e}")
Beispiel #4
0
def test_creating_new_weapon(raw_weapon, name, enchantment, weapon_type):
    character = Character(morgue_filepath="support/GucciMane.txt",
                          local_mode=True)
    weapon = WeaponFactory.new(character, raw_weapon)

    assert weapon.name == name
    assert weapon.enchantment == enchantment
    assert weapon.weapon_type == weapon_type
Beispiel #5
0
def weapons(name):
    character = Character(name=name)
    formatter = Formatter(character)
    msg = formatter.print_weapons()
    if msg:
        send_chat_to_stream(msg)
        return " ".join(msg)
    else:
        return "No Weapons Found!"
Beispiel #6
0
def test_morgue_file_from_s3(mocker):
    character = Character(name="beginbot")
    mocker.patch.object(character, "s3_morgue_file")

    expected_morgue_file = "Cool Morgue file"
    character.s3_morgue_file.return_value = expected_morgue_file
    morgue_file = character.morgue_file()
    character.s3_morgue_file.assert_called()
    assert morgue_file == expected_morgue_file
Beispiel #7
0
def armour(name):
    character = Character(name=name)
    formatter = Formatter(character)
    msg = formatter.print_armour()
    if msg:
        send_chat_to_stream(msg)
        return " ".join(msg)
    else:
        return "No Armour Found!"
Beispiel #8
0
def stalk_character(event):
    if "character" in event.keys():
        character_name = event["character"]
    elif "CHARACTER" in os.environ:
        character_name = os.environ.get("CHARACTER", None)
    else:
        character_name = "beginbot"

    character = Character(name=character_name)
    morgue_saver(character, character.non_saved_morgue_file())
Beispiel #9
0
def test_spell_calculator():
    character = Character(morgue_filepath="support/sunspire.txt",
                          local_mode=True)
    raw_spell = (
        "Ignite Poison            Fire/Tmut/Pois #######.     1%          3    None"
    )
    spell = SpellFactory(raw_spell).new()
    spell_calculator = SpellCalculator(character=character, spell=spell)
    result = spell_calculator.max_power()
    assert result == 119.04000000000002
Beispiel #10
0
def test_skills():
    character = Character(morgue_filepath="support/GucciMane.txt",
                          local_mode=True)
    expected_skills = [
        " + Level 2.9 Dodging",
        " - Level 2.4 Stealth",
        " + Level 3.5 Spellcasting",
        " + Level 4.6 Conjurations",
    ]
    assert character.skills() == expected_skills
Beispiel #11
0
def process_s3_event(event):
    character_name = event["s3"]["object"]["key"].split("/")[0]
    save_a_buncha_info(character_name)

    # How do we stop this in certain scenarios
    character = Character(name=character_name)

    if character_name not in BAN_LIST:
        send_morguefile_notification(character)
    else:
        print(f"Not sending notification for {character_name} new Morgue File")
Beispiel #12
0
def stalk(event):
    print(json.dumps(event))
    character = event.get("character", None)

    if character and character != "None":
        stalk_character(event)
    else:
        characters_to_stalk = fetch_characters()

        for character_name in characters_to_stalk:
            character = Character(name=character_name)
            morgue_saver(character, character.non_saved_morgue_file())
Beispiel #13
0
    def fetch(self):
        characters = fetch_characters()

        for character_name in characters:
            character = Character(name=character_name)
            morgue_db = MorgueDB(character_name)
            morgue_parser = MorgueParser(character.non_saved_morgue_file())
            runes = morgue_parser.runes()
            if runes:
                nice_runes = [rune.strip() for rune in runes.split(",")]
                print(f"\033[37mSaving {character_name}'s runes\033[0m")
                morgue_db.save_stuff("SS", "runes", nice_runes)
Beispiel #14
0
def test_initializing_an_invalid_weapon_type():
    character = Character(morgue_filepath="support/GucciMane.txt",
                          local_mode=True)

    with pytest.raises(KeyError) as exc:
        full_name = "Not a real +0 weapon"
        Weapon(full_name=full_name,
               name="fake",
               enchantment=0,
               character=character)
    exception_msg = exc.value.args[0]
    assert exception_msg == f"Error Looking Up Weapon Type: {full_name}, fake"
Beispiel #15
0
    def load_next_battle(self, name=None):
        if name is None:
            opponent_names = list(self.opponents.keys())
            name = opponent_names[opponent_names.index(self.opponent.name) + 1]

        self.next_battle = Battle(self, self.opponents[name](self))
        if name == "Spook Dog":
            opponent = Character(self, name, 200, 150)
            opponent.ghost_dog_stage = 1     # Variable showing which frame of idle movement the ghost dog is in
            opponent.ghost_dog_glide_x = 930
            opponent.started_glowing = False
            opponent.ghost_dog_attack_time = self.fps/2
            opponent.already_clawed = False
Beispiel #16
0
def test_morgue_file_from_crawl_server(mocker):
    character = Character(name="beginbot")
    mocker.patch.object(character, "s3_morgue_file")
    mocker.patch.object(character, "fetch_online_morgue")

    expected_morgue_file = "Online Morgue"
    character.s3_morgue_file.return_value = None
    character.fetch_online_morgue.return_value = expected_morgue_file
    morgue_file = character.morgue_file()

    character.s3_morgue_file.assert_called()
    character.fetch_online_morgue.assert_called()
    assert morgue_file == expected_morgue_file
Beispiel #17
0
def test_spells_above():
    character = Character(name="GucciMane", local_mode=True)
    spells = character.spells_above(4)
    expected_spells = [
        "Poison Arrow Conj/Pois #######... 1% 6.0 None",
        "Throw Icicle Conj/Ice ######.. 1% 4.0 None",
        "Yara's Violent Unravell Hex/Tmut ######.... 4% 5.0 None",
        "Invisibility Hex ######.. 14% 6.0 None",
        "Metabolic Englaciation Hex/Ice ######.... 17% 5.0 None",
        "Alistair's Intoxication Tmut/Pois #####... 24% 5.0 None",
        "Petrify Tmut/Erth ####.... 38% 4.0 None",
    ]
    assert spells == expected_spells
Beispiel #18
0
def test_max_spell_calculator():
    # character = Character(morgue_filepath="support/sunspire.txt", local_mode=True)
    character = Character(morgue_filepath="support/GucciMane.txt",
                          local_mode=True)
    max_spell_calculator = MaxSpellCalculator(character=character)
    result = max_spell_calculator.calculate()

    expected = [
        {
            "name": "Searing Ray",
            "spell_type": "Conj",
            "power": "###...",
            "failure": "3%",
            "level": 2.0,
            "hunger": "##.....",
        },
        {
            "name": "Dazzling Spray",
            "spell_type": "Conj/Hex",
            "power": "##....",
            "failure": "17%",
            "level": 3.0,
            "hunger": "###....",
        },
        {
            "name": "Iskenderun's Mystic Bla",
            "spell_type": "Conj",
            "power": "###.....",
            "failure": "22%",
            "level": 4.0,
            "hunger": "####...",
        },
        {
            "name": "Force Lance",
            "spell_type": "Conj/Tloc",
            "power": "##......",
            "failure": "50%",
            "level": 4.0,
            "hunger": "####...",
        },
        {
            "name": "Fulminant Prism",
            "spell_type": "Conj/Hex",
            "power": "##........",
            "failure": "50%",
            "level": 4.0,
            "hunger": "####...",
        },
    ]

    assert result == expected
Beispiel #19
0
def test_weapon():
    full_name = "the +9 sword of Zonguldrok (weapon) {reap}"
    name = "long sword"

    enchantment = 9
    character = Character(morgue_filepath="support/GucciMane.txt",
                          local_mode=True)

    subject = Weapon(full_name=full_name,
                     name=name,
                     enchantment=enchantment,
                     character=character)

    assert subject.max_damage() == 13.85
Beispiel #20
0
    def print_max_damage(self):
        if True:
            weapons = fetch_weapons(self.character.morgue_file())
            return WeaponsFormatter(character=self.character,
                                    weapons=weapons).format_max_damages()
        else:
            max_damages = {}
            from morgue_stalker import fetch_characters

            characters = morgue_stalker.fetch_characters()

            for character in characters:
                max_damages[character] = max_damage(
                    Character(name=character).morgue_file())
            return max_damages
Beispiel #21
0
    def __init__(self):
        # Pygame launch
        pygame.display.set_caption("SANTARENA")

        # Screen (camera)
        self.camera = Camera()

        # Tilemap
        self.tilemap = Tilemap(MAP_H, MAP_W)

        # Characters
        self.character = Character()
        self.enemies = []

        # Clock
        self.clock = Clock()
        self.dt = 0
Beispiel #22
0
def clean_the_morgue():
    characters = fetch_characters()
    for character_name in characters:
        character = Character(name=character_name)
        morgue_url = character.morgue_url
        online_morgue = character._fetch_online_morgue()

        if "Escaped with the Orb" in online_morgue:
            import pdb

            pdb.set_trace()

        if online_morgue:
            print(f"You get to live: {character.name} {morgue_url}")
        else:
            print(
                f"\033[31;1mNO ONLINE MORGUE FOUND FOR: {character.name}\033[0m"
            )
Beispiel #23
0
def celebrate_awards(max_by_type):
    send_chat_to_stream(["PorscheWIN Fourth Annual Weapon Awards!!! PorscheWIN"])
    for weapon_info in max_by_type:
        character = Character(name=weapon_info["character"])
        emoji = find_emoji(weapon_info["type"])

        pawn_star = PawnStar(weapon_info["weapon"])
        if pawn_star.is_unrand():
            unrand_emoji = "PraiseIt"
        else:
            unrand_emoji = ""

        send_chat_to_stream(
            [
                f"{emoji} {unrand_emoji} Winner {weapon_info['character']} {unrand_emoji} {emoji} - Category: {weapon_info['type']}",
                WeaponsFormatter(character, []).format_weapon(weapon_info),
            ]
        )
Beispiel #24
0
def find_the_max_damage_for_all_characters():
    characters = set(fetch_characters())

    all_max_damages = []
    for character_name in characters:
        print(f"\033[33mEntering {character_name} into the Weapon Awards...\033[0m")
        character = Character(name=character_name)
        weapons = fetch_weapons(character.morgue_file())

        weapons_appraiser = WeaponsAppraiser(character=character, weapons=weapons)
        max_damages = weapons_appraiser.calc_max_damages()

        if max_damages == ["No Weapons Found!"]:
            print(
                f"\033[37mIt's ok get some weapons and come back: {character_name}\033[0m"
            )
        else:
            all_max_damages.extend(max_damages)

    max_by_type = find_max_by_type(all_max_damages)
    celebrate_awards(max_by_type)
Beispiel #25
0
def _look_for_unrands(msg):
    try:
        new_unrands = []
        # Why are we decoded as the first thing we do in a function???
        decoded_msg = json.loads(msg)
        message = decoded_msg["Message"]

        print(f"\033[33mmessage: {message}\033[0m")

        character_weapon_info = json.loads(message)
        character = Character(name=character_weapon_info["character"])

        new_weapons = character_weapon_info["weapons"]

        new_unrands = [
            weapon for weapon in new_weapons if PawnStar(weapon).is_unrand()
        ]

        if new_unrands:
            send_chat_to_stream(
                f"OSFrog {character.name} got a New Unrand! OSFrog {' || '.join(new_unrands)}"
            )
    except Exception as e:
        print(f"Error: {e} | msg: {msg}")
Beispiel #26
0
def test_spells():
    character = Character(name="GucciMane", local_mode=True)
    spells = list(character.spells())
    assert type(spells[0]) == Spell
Beispiel #27
0
def test_morgue_filepath():
    local_mode = True
    character = Character(name="GucciMane", local_mode=local_mode)
    expected_filepath = f"/Users/begin/Library/Application Support/Dungeon Crawl Stone Soup/morgue/GucciMane.txt"
    assert character.morgue_filepath == expected_filepath
Beispiel #28
0
def test_spellcasting():
    character = Character(morgue_filepath="support/GucciMane.txt",
                          local_mode=True)
    assert character.spellcasting() == 3.5
Beispiel #29
0
def test_lookup_skill():
    character = Character(morgue_filepath="support/GucciMane.txt",
                          local_mode=True)
    assert character.lookup_skill("Conjurations").level == 4.6
Beispiel #30
0
def process_event(event):
    morgue_event = MorgueEvent.from_event(event)

    if morgue_event.command == "!h?":
        return print_the_help()

    # Elif Island
    msg = None
    if morgue_event.is_character_command():
        print("A single Character Command!")
        character = Character(name=morgue_event.character)
        formatter = Formatter(character)

        if morgue_event.command == "!armour":
            msg = formatter.print_armour()
        elif morgue_event.command == "!weapons":
            msg = formatter.print_weapons()
        elif morgue_event.command == "!runes":
            msg = formatter.print_runes()
        elif morgue_event.command == "!spells":

            if morgue_event.level_barrier:
                msg = character.spells_above(morgue_event.level_barrier)
            else:
                msg = formatter.print_spells()

        elif morgue_event.command == "!skills":
            msg = formatter.print_skills()
        elif morgue_event.command == "!version":
            msg = formatter.print_version()
        elif morgue_event.command == "!jewellery":
            msg = formatter.print_jewellery()
            print(
                f"WE are looking for jewellery and this is what we found {msg}"
            )
        elif morgue_event.command == "!max_damage":
            msg = formatter.print_max_damage()
        elif morgue_event.command == "!mutations":
            msg = formatter.print_mutations()
        elif morgue_event.command == "!scrolls":
            msg = formatter.print_scrolls()
        elif morgue_event.command == "!potions":
            msg = formatter.print_potions()
        elif morgue_event.command == "!gods":
            msg = formatter.print_gods()
        elif morgue_event.command == "!overview":
            morgue_parser = MorgueParser(character.non_saved_morgue_file())
            msg = morgue_parser.overview()
        elif morgue_event.command == "!fetch":
            morgue_saver(character, character.non_saved_morgue_file(), True)
        elif morgue_event.command == "!fetch_s3_morgue":
            print(f"We are fetching the S3 Morgue for {character.name}")
            with open(f"tmp/s3_{character.name}.txt", "w") as f:
                f.write(character.s3_morgue_file())
        elif morgue_event.command == "!save_morgue":
            save_morgue(character)
        elif morgue_event.command == "!search":
            pass
            # for c in ["!armour", "!weapons", "!jewellery"]:
            #     call_command_with_arg(formatter, c, morgue_event.args[0])

    elif morgue_event.is_multi_character_command():
        print("A multiple Character Command!")
        if morgue_event.command == "!stalk_all":
            characters = fetch_characters()
            for character in characters:
                character = Character(name=character)
                morgue_saver(character, character.non_saved_morgue_file(),
                             True)
        elif morgue_event.command == "!rune_awards":
            rune_awards()
        elif morgue_event.command == "!characters":
            characters = fetch_characters()
            msg = ["All The Characters"] + [", ".join(characters)]
        elif morgue_event.command == "!clean_morgue":
            print("COMING SOON")
            # clean_the_morgue()
        elif morgue_event.command == "!weapon_awards":
            find_the_max_damage_for_all_characters()
    else:
        print("WE DON'T KNOW THAT COMMAND!!!!!!!")

    if morgue_event.search:
        print(f"We are searching: {morgue_event.search}")

        if type(msg) is list:
            print("Search a List")
            msg = [item for item in msg if morgue_event.search in item]
        else:
            print("Search a strang")
            if morgue_event.search not in msg:
                msg = None

    if msg:
        send_chat_to_stream(msg)
    else:
        print(
            f"No Message return for command: {morgue_event.command} character: {morgue_event.character}"
        )