From dfb591d410eff4c0e126aef58c700440c6619109 Mon Sep 17 00:00:00 2001 From: eichhornchen Date: Sun, 10 Jan 2021 16:31:46 +0100 Subject: [PATCH] The player's stats now get better when levelling up. The strength level and frequency of appearance of entities have been changed to offer bettter game experience. --- squirrelbattle/entities/monsters.py | 6 +++--- squirrelbattle/entities/player.py | 13 ++++++++++++- squirrelbattle/interfaces.py | 9 +++++---- 3 files changed, 20 insertions(+), 8 deletions(-) diff --git a/squirrelbattle/entities/monsters.py b/squirrelbattle/entities/monsters.py index c654428..8f3c2b5 100644 --- a/squirrelbattle/entities/monsters.py +++ b/squirrelbattle/entities/monsters.py @@ -76,8 +76,8 @@ class Tiger(Monster): """ A tiger monster. """ - def __init__(self, name: str = "tiger", strength: int = 2, - maxhealth: int = 20, *args, **kwargs) -> None: + def __init__(self, name: str = "tiger", strength: int = 5, + maxhealth: int = 30, *args, **kwargs) -> None: super().__init__(name=name, strength=strength, maxhealth=maxhealth, *args, **kwargs) @@ -97,7 +97,7 @@ class Rabbit(Monster): A rabbit monster. """ def __init__(self, name: str = "rabbit", strength: int = 1, - maxhealth: int = 15, critical: int = 30, + maxhealth: int = 20, critical: int = 30, *args, **kwargs) -> None: super().__init__(name=name, strength=strength, maxhealth=maxhealth, critical=critical, diff --git a/squirrelbattle/entities/player.py b/squirrelbattle/entities/player.py index 8257f85..5b788b2 100644 --- a/squirrelbattle/entities/player.py +++ b/squirrelbattle/entities/player.py @@ -3,6 +3,7 @@ from random import randint from typing import Dict, Optional, Tuple +from math import log from .items import Item from ..interfaces import FightingEntity, InventoryHolder @@ -69,9 +70,19 @@ class Player(InventoryHolder, FightingEntity): self.level += 1 self.current_xp -= self.max_xp self.max_xp = self.level * 10 + self.maxhealth += int(2*log(self.level)/log(2)) self.health = self.maxhealth self.strength = self.strength + 1 - # TODO Remove it, that's only fun + if self.level % 3 == 0 : + self.dexterity += 1 + self.constitution += 1 + if self.level % 4 == 0 : + self.intelligence += 1 + if self.level % 6 == 0 : + self.charisma += 1 + if self.level % 10 == 0 and self.critical < 95: + self.critical += (100-self.charisma)//30 + # TODO Remove it, that's only for fun self.map.spawn_random_entities(randint(3 * self.level, 10 * self.level)) diff --git a/squirrelbattle/interfaces.py b/squirrelbattle/interfaces.py index 2280909..60a7c82 100644 --- a/squirrelbattle/interfaces.py +++ b/squirrelbattle/interfaces.py @@ -628,8 +628,9 @@ class Entity: Rabbit, TeddyBear, GiantSeaEagle from squirrelbattle.entities.friendly import Merchant, Sunflower, \ Trumpet, Chest - return [BodySnatchPotion, Bomb, Heart, Hedgehog, Rabbit, TeddyBear, - Sunflower, Tiger, Merchant, GiantSeaEagle, Trumpet, Chest] + return [BodySnatchPotion, Bomb, Chest, GiantSeaEagle, Heart, + Hedgehog, Merchant, Rabbit, Sunflower, TeddyBear, Tiger, + Trumpet] @staticmethod def get_weights() -> list: @@ -637,7 +638,7 @@ class Entity: 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, 3, 1, 2, 4] + return [30, 80, 50, 1, 100, 100, 60, 70, 70, 20, 40, 40] @staticmethod def get_all_entity_classes_in_a_dict() -> dict: @@ -765,7 +766,7 @@ class FightingEntity(Entity): The entity takes damage from the attacker based on their respective stats. """ - damage = max(0, amount - self.constitution) + damage = max(1, amount - self.constitution) self.health -= damage if self.health <= 0: self.die()