Merge branch 'EvenmoreDoc' into 'moredocs'
# Conflicts: # docs/entities/items.rst
This commit is contained in:
@ -3,7 +3,7 @@
|
||||
|
||||
from random import choice, shuffle
|
||||
|
||||
from .items import Item
|
||||
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,6 +71,10 @@ class Chest(InventoryHolder, FriendlyEntity):
|
||||
"""
|
||||
A chest is not living, it can not take damage
|
||||
"""
|
||||
if isinstance(attacker, Bomb):
|
||||
self.die()
|
||||
self.annihilated = True
|
||||
return _("The chest exploded")
|
||||
return _("It's not really effective")
|
||||
|
||||
@property
|
||||
@ -75,14 +82,14 @@ class Chest(InventoryHolder, FriendlyEntity):
|
||||
"""
|
||||
Chest can not die
|
||||
"""
|
||||
return False
|
||||
return self.annihilated
|
||||
|
||||
|
||||
class Sunflower(FriendlyEntity):
|
||||
"""
|
||||
A friendly sunflower.
|
||||
"""
|
||||
def __init__(self, maxhealth: int = 15,
|
||||
def __init__(self, maxhealth: int = 20,
|
||||
*args, **kwargs) -> None:
|
||||
super().__init__(name="sunflower", maxhealth=maxhealth, *args, **kwargs)
|
||||
|
||||
@ -162,6 +169,6 @@ class Trumpet(Familiar):
|
||||
A class of familiars.
|
||||
"""
|
||||
def __init__(self, name: str = "trumpet", strength: int = 3,
|
||||
maxhealth: int = 20, *args, **kwargs) -> None:
|
||||
maxhealth: int = 30, *args, **kwargs) -> None:
|
||||
super().__init__(name=name, strength=strength,
|
||||
maxhealth=maxhealth, *args, **kwargs)
|
||||
|
@ -498,7 +498,7 @@ class ScrollofDamage(Item):
|
||||
|
||||
class ScrollofWeakening(Item):
|
||||
"""
|
||||
A scroll that, when used, reduces the damage of the ennemies for 3 turn.
|
||||
A scroll that, when used, reduces the damage of the ennemies for 3 turns.
|
||||
"""
|
||||
def __init__(self, name: str = "scroll_of_weakening", price: int = 13,
|
||||
*args, **kwargs):
|
||||
@ -613,7 +613,7 @@ class FireBallStaff(LongRangeWeapon):
|
||||
@property
|
||||
def stat(self) -> str:
|
||||
"""
|
||||
Here it is dexterity
|
||||
Here it is intelligence
|
||||
"""
|
||||
return "intelligence"
|
||||
|
||||
|
@ -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,
|
||||
|
@ -1,11 +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 .items import Item
|
||||
from ..interfaces import FightingEntity, InventoryHolder
|
||||
from ..translations import gettext as _
|
||||
|
||||
|
||||
class Player(InventoryHolder, FightingEntity):
|
||||
@ -61,6 +63,31 @@ class Player(InventoryHolder, FightingEntity):
|
||||
self.recalculate_paths()
|
||||
self.map.compute_visibility(self.y, self.x, self.vision)
|
||||
|
||||
def dance(self) -> None:
|
||||
"""
|
||||
Dancing has a certain probability or making ennemies unable
|
||||
to fight for 3 turns. That probability depends on the player's
|
||||
charisma.
|
||||
"""
|
||||
diceroll = randint(1, 10)
|
||||
found = False
|
||||
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])
|
||||
if found:
|
||||
self.map.logs.add_message(_(
|
||||
"It worked! Nearby ennemies will be confused for 3 turns."))
|
||||
else:
|
||||
self.map.logs.add_message(_(
|
||||
"It worked, but there is no one nearby..."))
|
||||
else:
|
||||
self.map.logs.add_message(
|
||||
_("The dance was not effective..."))
|
||||
|
||||
def level_up(self) -> None:
|
||||
"""
|
||||
Add as many levels as possible to the player.
|
||||
@ -69,9 +96,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))
|
||||
|
||||
|
Reference in New Issue
Block a user