Testing + linting (yes there remains two linting errors, i don't know what to do.

This commit is contained in:
eichhornchen
2021-01-10 18:04:33 +01:00
parent afaa12d86b
commit 93e51d9240
6 changed files with 79 additions and 27 deletions

View File

@ -3,7 +3,7 @@
from random import choice, shuffle
from .items import Item, Bomb
from .items import Bomb, Item
from .monsters import Monster
from .player import Player
from ..interfaces import Entity, FightingEntity, FriendlyEntity, \
@ -48,11 +48,14 @@ class Chest(InventoryHolder, FriendlyEntity):
"""
A class of chest inanimate entities which contain objects.
"""
annihilated: bool
def __init__(self, name: str = "chest", inventory: list = None,
hazel: int = 0, *args, **kwargs):
super().__init__(name=name, *args, **kwargs)
self.hazel = hazel
self.inventory = self.translate_inventory(inventory or [])
self.annihilated = False
if not self.inventory:
for i in range(3):
self.inventory.append(choice(Item.get_all_items())())
@ -68,8 +71,9 @@ class Chest(InventoryHolder, FriendlyEntity):
"""
A chest is not living, it can not take damage
"""
if isinstance(attacker, Bomb) :
if isinstance(attacker, Bomb):
self.die()
self.annihilated = True
return _("The chest exploded")
return _("It's not really effective")
@ -78,7 +82,7 @@ class Chest(InventoryHolder, FriendlyEntity):
"""
Chest can not die
"""
return False
return self.annihilated
class Sunflower(FriendlyEntity):

View File

@ -1,13 +1,13 @@
# Copyright (C) 2020-2021 by ÿnérant, eichhornchen, nicomarg, charlse
# SPDX-License-Identifier: GPL-3.0-or-later
from math import log
from random import randint
from typing import Dict, Optional, Tuple
from math import log
from .items import Item
from ..interfaces import FightingEntity, InventoryHolder
from ..translations import gettext as _, Translator
from ..translations import gettext as _
class Player(InventoryHolder, FightingEntity):
@ -74,10 +74,10 @@ class Player(InventoryHolder, FightingEntity):
if diceroll <= self.charisma:
for entity in self.map.entities:
if entity.is_fighting_entity() and not entity == self \
and entity.distance(self)<=3:
found = True
entity.confused = 1
entity.effects.append(["confused", 1, 3])
and entity.distance(self) <= 3:
found = True
entity.confused = 1
entity.effects.append(["confused", 1, 3])
if found:
self.map.logs.add_message(_(
"It worked! Nearby ennemies will be confused for 3 turns."))
@ -88,7 +88,6 @@ class Player(InventoryHolder, FightingEntity):
self.map.logs.add_message(
_("The dance was not effective..."))
def level_up(self) -> None:
"""
Add as many levels as possible to the player.
@ -97,18 +96,18 @@ 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.maxhealth += int(2 * log(self.level) / log(2))
self.health = self.maxhealth
self.strength = self.strength + 1
if self.level % 3 == 0 :
if self.level % 3 == 0:
self.dexterity += 1
self.constitution += 1
if self.level % 4 == 0 :
if self.level % 4 == 0:
self.intelligence += 1
if self.level % 6 == 0 :
if self.level % 6 == 0:
self.charisma += 1
if self.level % 10 == 0 and self.critical < 95:
self.critical += (100-self.charisma)//30
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))