diff --git a/squirrelbattle/display/texturepack.py b/squirrelbattle/display/texturepack.py index 2295667..ed89be6 100644 --- a/squirrelbattle/display/texturepack.py +++ b/squirrelbattle/display/texturepack.py @@ -30,6 +30,7 @@ class TexturePack: TEDDY_BEAR: str TIGER: str WALL: str + EAGLE: str ASCII_PACK: "TexturePack" SQUIRREL_PACK: "TexturePack" @@ -76,6 +77,7 @@ TexturePack.ASCII_PACK = TexturePack( TEDDY_BEAR='8', TIGER='n', WALL='#', + EAGLE='µ', ) TexturePack.SQUIRREL_PACK = TexturePack( @@ -103,4 +105,5 @@ TexturePack.SQUIRREL_PACK = TexturePack( TEDDY_BEAR='🧸', TIGER='🐅', WALL='🧱', + EAGLE='🦅', ) diff --git a/squirrelbattle/entities/monsters.py b/squirrelbattle/entities/monsters.py index e50fad0..bcdff11 100644 --- a/squirrelbattle/entities/monsters.py +++ b/squirrelbattle/entities/monsters.py @@ -100,3 +100,12 @@ class TeddyBear(Monster): maxhealth: int = 50, *args, **kwargs) -> None: super().__init__(name=name, strength=strength, maxhealth=maxhealth, *args, **kwargs) + +class GiantSeaEagle(Monster): + """ + An eagle boss + """ + def __init__(self, name: str = "eagle", strength: int = 1000, + maxhealth: int = 5000, *args, **kwargs) -> None: + super().__init__(name=name, strength=strength, + maxhealth=maxhealth, *args, **kwargs) diff --git a/squirrelbattle/interfaces.py b/squirrelbattle/interfaces.py index dceea6a..25a8baa 100644 --- a/squirrelbattle/interfaces.py +++ b/squirrelbattle/interfaces.py @@ -3,7 +3,7 @@ from enum import Enum, auto from math import sqrt -from random import choice, randint +from random import choice, randint, choices from typing import List, Optional, Any from .display.texturepack import TexturePack @@ -146,7 +146,8 @@ class Map: tile = self.tiles[y][x] if tile.can_walk(): break - entity = choice(Entity.get_all_entity_classes())() + entity = choices(Entity.get_all_entity_classes(),\ + weights = Entity.get_weights(), k=1)[0]() entity.move(y, x) self.add_entity(entity) @@ -349,10 +350,19 @@ class Entity: """ from squirrelbattle.entities.items import BodySnatchPotion, Bomb, Heart from squirrelbattle.entities.monsters import Tiger, Hedgehog, \ - Rabbit, TeddyBear + Rabbit, TeddyBear, GiantSeaEagle from squirrelbattle.entities.friendly import Merchant, Sunflower return [BodySnatchPotion, Bomb, Heart, Hedgehog, Rabbit, TeddyBear, - Sunflower, Tiger, Merchant] + Sunflower, Tiger, Merchant, GiantSeaEagle] + + @staticmethod + def get_weights() -> list: + """ + Returns a weigth list associated to the above function, to + be used to spawn random entities with a certain probability. + """ + return [3, 5, 6, 5, 5, 5, + 5, 4, 4, 1] @staticmethod def get_all_entity_classes_in_a_dict() -> dict: @@ -361,7 +371,7 @@ class Entity: """ from squirrelbattle.entities.player import Player from squirrelbattle.entities.monsters import Tiger, Hedgehog, Rabbit, \ - TeddyBear + TeddyBear, GiantSeaEagle from squirrelbattle.entities.friendly import Merchant, Sunflower from squirrelbattle.entities.items import BodySnatchPotion, Bomb, \ Heart, Sword @@ -377,6 +387,7 @@ class Entity: "Merchant": Merchant, "Sunflower": Sunflower, "Sword": Sword, + "Eagle": GiantSeaEagle, } def save_state(self) -> dict: