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

@ -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))