Added an overpowered eagle boss. To avoid seing it too often, entities now have a certain chance of being spawned. Closes #19.
This commit is contained in:
		@@ -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='🦅',
 | 
			
		||||
)
 | 
			
		||||
 
 | 
			
		||||
@@ -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)
 | 
			
		||||
 
 | 
			
		||||
@@ -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:
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user