def _place_player(
         self,
         player: Actor,
         rooms: List[RectangularRoom],
         dungeon: GameMap
 ) -> None:
     room = self._get_random_room(rooms)
     player.place(*room.random_field, gamemap=dungeon)
Beispiel #2
0
def getUniquePerson():
    return Actor(
        char="T", 
        color=(63, 127, 0), 
        name=getName(),
        fighter=Fighter(energy=1), 
        ai_cls=OtherPerson
)
Beispiel #3
0
def kill_entity(engine: Engine, entity: Actor) -> None:
    entity.char = '%'
    entity.color = (191, 0, 0)

    if engine.player == entity:
        death_message = 'You died!'
        death_message_color = (191, 0, 0)
        engine.event_handler = GameOverEventHandler(engine)
    else:
        death_message = f'{entity.name} is dead!'
        death_message_color = (255, 127, 0)
        entity.blocks_movement = False
        entity.ai = DeadAI()
        entity.name = f'remains of {entity.name}'
        entity.render_order = RenderOrder.CORPSE

    engine.message_log.add_message(death_message, death_message_color)
Beispiel #4
0
'''

#_______________________________________________________________________// MODULES

from entity import Actor
from components.ai import HostileEnemy
from components.fighter import Fighter

from colors import *

#_______________________________________________________________________// DATA (TUPLES) - ENTITIES

# Player
player = Actor(char="@",
               color=yellow,
               name="Player",
               ai_cls=HostileEnemy,
               fighter=Fighter(hp=30, defense=2, power=5))

#Enemies
# TODO: Set enemy's 'Fighter' stats to derive from player's stats (so difficulty will scale up)

orc = Actor(char="O",
            color=red,
            name="Orc",
            ai_cls=HostileEnemy,
            fighter=Fighter(hp=10, defense=0, power=3))

troll = Actor(char="T",
              color=red,
              name="Troll",
Beispiel #5
0
import random

f = open('NAME.txt')
name = f.read()
f.close()

if name == "":
    name = "The Unknown"

player = Actor(
    char="@",
    color=(82, 216, 7),
    name=name,
    equipment=Equipment(),
    ai_cls=HostileEnemy,
    fighter=Fighter(hp=30,
                    base_defense=2,
                    base_power=5,
                    max_hunger=100,
                    hunger=100),
    inventory=Inventory(capacity=26),
    level=Level(level_up_base=300),
)

rusty = Actor(
    char="R",
    color=(255, 8, 10),
    name="Rusty One",
    equipment=Equipment(),
    ai_cls=PermConfusedEnemy,
    fighter=Fighter(hp=22,
                    base_defense=1,
from components.ai import HostileEnemy
from components import consumable, equippable
from components.fighter import Fighter
from components.equipment import Equipment
from components.inventory import Inventory
from components.level import Level
from entity import Actor, Item
"""Player"""

player = Actor(char="@",
               color=(255, 255, 255),
               name="Player",
               ai_cls=HostileEnemy,
               equipment=Equipment(),
               fighter=Fighter(hp=30,
                               base_constitution=2,
                               base_strength=5,
                               base_agility=5,
                               base_intelligence=4),
               inventory=Inventory(capacity=26),
               level=Level(level_up_base=200),
               primary_mod=None)
"""Enemies"""

slime = Actor(char="J",
              color=(63, 127, 63),
              name="Slime",
              ai_cls=HostileEnemy,
              equipment=Equipment(),
              fighter=Fighter(hp=10,
                              base_constitution=0,
from __future__ import annotations

from json import load as json_load

from entity import Actor
from components.ai import HostileEnemy
from components.level import Level
from components.inventory import Inventory
from components.stats import Stats

RACES: None

try:
    with open('res/races.json') as f:
        RACES = json_load(f)
except FileNotFoundError:
    raise FileNotFoundError()

HUMAN = RACES['human']

human = Actor(
    char=RACES['human']['char'],
    color=RACES['human']['color'],
    name=str(RACES['human']['name']['singular'].capitalize()),
    ai_cls=HostileEnemy,
    stats=Stats(stats=RACES['human']['stats']),
    level=Level(),  # TODO
    inventory=Inventory())
Beispiel #8
0
from components.ai import HostileEnemy
from components.stats import EntityStats
from entity import Actor

player = Actor(char="@",
               color=(255, 255, 255),
               name="Player",
               ai_class=HostileEnemy,
               stats=EntityStats(10, 2, 5))

rat = Actor(char="R",
            color=(0, 127, 0),
            name="Rat",
            ai_class=HostileEnemy,
            stats=EntityStats(20, 0, 3))

spider = Actor(char="M",
               color=(63, 127, 63),
               name="Spider",
               ai_class=HostileEnemy,
               stats=EntityStats(30, 1, 3))
Beispiel #9
0
    def get_ranged_direction(self,
                             attacker: Actor,
                             target: Actor,
                             valid_range: int = 4):
        """
        If target is
        1. in possible attacking direction (8-ways linear direction)
        2. in valid range
        3. not blocked from any obstacle
        return the direction as tuple.
        If any of them is unsatisfied, return None. 

        e.g. @-actor T-target
        . . T
        . . .
        @ . .
        return (1,-1)
        """
        # get coordinate axis distances
        x_diff = target.x - attacker.x
        y_diff = target.y - attacker.y

        # Check if in range
        distance = int(attacker.distance(target.x, target.y))
        if distance > valid_range:
            return None

        # (0,0) is not considered as a valid direction
        if x_diff == 0 and y_diff == 0:
            return None

        # Check if the target is in possible attack direction (linear direction)
        direction = None

        if abs(x_diff) == abs(y_diff):  #(1,1), (-1,-1), (1,-1), (-1,1)
            if x_diff > 0:
                if y_diff > 0:
                    direction = (1, 1)
                else:
                    direction = (1, -1)
            else:
                if y_diff > 0:
                    direction = (-1, 1)
                else:
                    direction = (-1, -1)
        elif x_diff == 0:  # (0,1), (0,-1)
            if y_diff > 0:
                direction = (0, 1)
            else:
                direction = (0, -1)
        elif y_diff == 0:  # (1,0), (-1,0)
            if x_diff > 0:
                direction = (1, 0)
            else:
                direction = (-1, 0)
        else:
            return None

        # Check for obstacles
        for i in range(1, distance):
            blocking_actor = attacker.gamemap.get_actor_at_location(
                attacker.x + i * direction[0], attacker.y + i * direction[1])

            # Non-walkable tile is blocking
            if not attacker.gamemap.tiles["walkable"][attacker.x +
                                                      i * direction[0],
                                                      attacker.y +
                                                      i * direction[1]]:
                return None
            # if actor is blocking, check if that actor is also considered as enemy.
            # (preventing friendly fire)
            # NOTE: The actor will not attack if there is any non-hostile actor between the actor and the target.
            elif blocking_actor:
                if self.check_if_enemy(blocking_actor):
                    continue
                else:
                    return None
            else:
                continue

        # return
        return direction
from components.ai import HostileEnemy
from components.fighter import Fighter
from entity import Actor

player = Actor(
    char="@",
    color=(255, 255, 255),
    name="Player",
    ai_cls=HostileEnemy,
    fighter=Fighter(hp=30, defense=2, power=5),
)

cultist = Actor(
    char="c",
    color=(31, 43, 31),
    name="Cultist",
    ai_cls=HostileEnemy,
    fighter=Fighter(hp=10, defense=0, power=3),
)

chosen = Actor(
    char="C",
    color=(43, 59, 47),
    name="Chosen",
    ai_cls=HostileEnemy,
    fighter=Fighter(hp=16, defense=1, power=4),
)
from components.ai import HostileEnemy
from components.fighter import Fighter
from entity import Actor

player = Actor(
	char="@", 
	color=(255, 255, 255), 
	name="Player", 
	ai_cls=HostileEnemy,
	fighter=Fighter(hp=30, defense=2, power=5),
)

limb = Actor(
	char="~", 
	color=(255, 0, 0), 
	name="Crawling Limb",
	ai_cls=HostileEnemy,
	fighter=Fighter(hp=5, defense=0, power=2),
)

ghoul = Actor(
	char="g", 
	color=(196, 233, 223), 
	name="Ghoul", 
	ai_cls=HostileEnemy,
	fighter=Fighter(hp=10, defense=0, power=3),
)

wraith = Actor(
	char="W", 
	color=(43, 148, 118), 
from components.ai import HostileEnemy, RangedEnemy, HealingEnemy
from components.baseclass import Templar, Cleric, Archer, Shaman, Shadow, Assassin, NoClass
from components import consumable, equippable
from components.equipment import Equipment
from components.fighter import Fighter
from components.inventory import Inventory
from components.level import Level
from entity import Actor, Item

player = Actor(
    char="@",
    color=(255, 255, 255),
    name="Player",
    ai_cls=HostileEnemy,
    faction="Holy",
    Class=Templar(),
    Subclass=NoClass(),
    equipment=Equipment(),
    fighter=Fighter(hp=500, base_defense=30, base_power=50,mana=150,mana_regen=20),
    inventory=Inventory(capacity=26),
    level=Level(),
)

soldier = Actor(
    char="T",
    color=(255, 255, 255),
    name="Templar",
    ai_cls=HostileEnemy,
    faction="Holy",
    Class=Templar(),
    Subclass=Shadow(),
from components.ai import HostileEnemy
from components.fighter import Fighter
from entity import Actor

player = Actor(
    char="@",
    color=(255, 255, 255),
    name="Player",
    ai_cls=HostileEnemy,
    fighter=Fighter(hp=30, defense=2, power=5),
)

goblin = Actor(
    char="g",
    color=(63, 127, 63),
    name="Goblin",
    ai_cls=HostileEnemy,
    fighter=Fighter(hp=10, defense=0, power=3),
)
troll = Actor(
    char="T",
    color=(0, 127, 0),
    name="Troll",
    ai_cls=HostileEnemy,
    fighter=Fighter(hp=16, defense=1, power=4),
)
Beispiel #14
0
from components.ai import HostileEnemy
from components import consumable

from components.fighter import Fighter
from components.inventory import Inventory
from components.level import Level
from entity import Actor, Item

player = Actor(
    char='@',
    color=(255, 255, 255),
    name='Player',
    ai_cls=HostileEnemy,
    fighter=Fighter(hp=30, defense=2, power=5),
    inventory=Inventory(capacity=26),
    level=Level(level_up_base=200),
)

orc = Actor(
    char='o',
    color=(88, 220, 86),
    name='Orc',
    ai_cls=HostileEnemy,
    fighter=Fighter(hp=10, defense=0, power=3),
    inventory=Inventory(capacity=0),
    level=Level(xp_given=35),
)

troll = Actor(
    char='T',
    color=(0, 255, 255),
from components.consumable import Consumable, HealingConsumable
from components.ai import BaseAI, Hostile
from components.fighter import Fighter
from components.inventory import Inventory
from entity import Actor, Item
from config import Config as CONFIG

player = Actor(name="Player",
               ai_cls=BaseAI,
               fighter=Fighter(hp=30, defense=2, power=5),
               inventory=Inventory(capacity=CONFIG.Game.get("inventory_size")))
# TODO Magic numbers!

blue = Actor(name="Blue",
             ai_cls=Hostile,
             fighter=Fighter(hp=10, defense=0, power=3),
             inventory=Inventory(0))
yellow = Actor(name="Yellow",
               ai_cls=Hostile,
               fighter=Fighter(hp=16, defense=1, power=4),
               inventory=Inventory(0))
health_potion = Item(
    name="Health Potion",
    consumable=HealingConsumable(amount=4),
)
Beispiel #16
0
player = Actor(
    char="@",
    fg=(255, 255, 255),
    name="Player",
    entity_id="player",
    entity_desc="Player desc",
    rarity=0,
    spawnable=False,
    growthable=True,
    edible=RawMeatEdible(nutrition=300),
    render_order=RenderOrder.PLAYER,
    ai_cls=None,
    status=Status(
        hp=80000,#80
        mp=1000,
        strength=15,
        dexterity=15,
        agility=15,
        intelligence=15,
        constitution=15,
        charm=15,
        difficulty=0,
        base_melee=8,
        additional_melee=5,
        protection=10,
        eyesight=20,
        ),
    actor_state=ActorState(
        hunger=-1,##DEBUG 1200 TODO
        heal_wounds=True,
        size=4,
        weight=70,
    ),
    inventory=Inventory(capacity=52, is_fireproof=False),
    ability_inventory=AbilityInventory(capacity=10),
    equipments=Equipments(),
    initial_items=[(item_factories.scroll_of_enchantment, 1, (1,5)), (item_factories.scroll_of_identify, 1, (1,4)), (item_factories.scroll_of_remove_curse, 1, (1,4))],##DEBUG,
    initial_equipments=[(item_factories.leather_armor, 1)],
    initial_abilities=[(ability_factories.lightning_bolt, 1), (ability_factories.steal, 1)],
)
Beispiel #17
0
def getName():
    return names.get_last_name()

def getUniquePerson():
    return Actor(
        char="T", 
        color=(63, 127, 0), 
        name=getName(),
        fighter=Fighter(energy=1), 
        ai_cls=OtherPerson
)

player = Actor(
    char="@", 
    color=colors.v_dark_purp, 
    name="Player", 
    fighter=Fighter(energy=100),
    ai_cls=OtherPerson,
    
)

food = Item(
    char="%",
    color=(127, 0, 255),
    name="Food",
    consumable=HealingConsumable(amount=7),
)

# me = Entity(char="o", color=(63, 127, 63), name="You", blocks_movement=True)

Beispiel #18
0
from components.ai import HostileEnemy
from components import consumable, equippable
from components.equipment import Equipment
from components.fighter import Fighter
from components.inventory import Inventory
from components.level import Level
from entity import Actor, Item

player = Actor(
    char="#",
    color=(255, 255, 255),
    name="player",
    ai_cls=HostileEnemy,
    equipment=Equipment(),
    fighter=Fighter(hp=30, base_defense=1, base_power=2),
    inventory=Inventory(capacity=26),
    level=Level(level_up_base=200),
)

orc = Actor(
    char="o",
    color=(63, 127, 63),
    name="Orc",
    ai_cls=HostileEnemy,
    equipment=Equipment(),
    fighter=Fighter(hp=10, base_defense=0, base_power=3),
    inventory=Inventory(capacity=0),
    level=Level(xp_given=25),
)
troll = Actor(
    char="T",
from components.ai import HostileEnemy, BaseAI
from components import consumable
from components.fighter import Fighter
from components.inventory import Inventory
from entity import Actor, Item

player = Actor(
    char="@",
    color=(255, 255, 255),
    name="Player",
    ai_cls=BaseAI,
    fighter=Fighter(hp=30, defense=2, power=5),
    inventory=Inventory(capacity=26),
)

orc = Actor(
    char="o",
    color=(63, 127, 63),
    name="Orc",
    ai_cls=HostileEnemy,
    fighter=Fighter(hp=10, defense=0, power=3),
    inventory=Inventory(capacity=0),
)

troll = Actor(
    char="T",
    color=(0, 127, 0),
    name="Troll",
    ai_cls=HostileEnemy,
    fighter=Fighter(hp=16, defense=1, power=4),
    inventory=Inventory(capacity=0),
Beispiel #20
0
from components.ai import HostileEnemy
from components import consumable
from components.fighter import Fighter
from components.inventory import Inventory
from components.level import Level
from entity import Actor, Item

player = Actor(
    char="@",
    color=(255, 255, 255),
    name="Strong Terry",
    ai_cls=HostileEnemy,
    fighter=Fighter(hp=30, defense=2, power=5),
    inventory=Inventory(capacity=26),
    level=Level(level_up_base=200),
)

terry = Actor(
    char="T",
    color=(63, 127, 63),
    name="Terry",
    ai_cls=HostileEnemy,
    fighter=Fighter(hp=10, defense=0, power=3),
    inventory=Inventory(capacity=0),
    level=Level(xp_given=35),
)

ricky = Actor(
    char="R",
    color=(0, 127, 0),
    name="Ricky",
Beispiel #21
0
from components.ai import BaseAI, HostileEnemy
from components.consumable import HealthPotion
from components.fighter import Fighter
from components.inventory import Inventory
from entity import Actor, Item
import enum

player = Actor(char="@",
               color=(255, 255, 0),
               name="EGG",
               ai=BaseAI(),
               fighter=Fighter(hp=30, defense=2, power=5),
               inventory=Inventory(capacity=15))

orc = Actor(char="S",
            color=(63, 127, 63),
            name="Spoon",
            ai=HostileEnemy(),
            fighter=Fighter(hp=10, defense=0, power=3),
            inventory=Inventory(capacity=0))

troll = Actor(char="T",
              color=(0, 127, 0),
              name="Troll",
              ai=HostileEnemy(),
              fighter=Fighter(hp=16, defense=1, power=4),
              inventory=Inventory(capacity=0))

health_potion = Item(char="!",
                     color=(255, 255, 255),
                     name="HP Potion +4",
from components.ai import HostileEnemy
from components import consumable
from components.fighter import Fighter
from components.inventory import Inventory
from entity import Actor, Item

player = Actor(
    char="@",
    color=(255, 255, 255),
    name="Player",
    ai_cls=HostileEnemy,
    fighter=Fighter(hp=30, defense=2, power=5),
    inventory=Inventory(capacity=26),
    # 26 по числу букв англ алфавита (каждая буква может представлять собой инвентарь)
)

monst1 = Actor(
    char="u",
    color=(142, 7, 54),
    name="Untung",
    ai_cls=HostileEnemy,
    fighter=Fighter(hp=10, defense=0, power=3),
    inventory=Inventory(capacity=0),
)
monst2 = Actor(
    char="T",
    color=(142, 7, 54),
    name="Tiada",
    ai_cls=HostileEnemy,
    fighter=Fighter(hp=16, defense=1, power=4),
    inventory=Inventory(capacity=0),
from components.ai import HostileEnemy
from components import consumable, equippable
from components.equipment import Equipment
from components.fighter import Fighter
from components.inventory import Inventory
from components.level import Level
from entity import Actor, Item

player = Actor(
    char="@",
    color=(255, 255, 255),
    name="Player",
    ai_cls=HostileEnemy,
    equipment=Equipment(),
    fighter=Fighter(hp=30, base_defense=1, base_power=2),
    inventory=Inventory(capacity=26),
    level=Level(level_up_base=200),
)
goblin = Actor(
    char="g",
    color=(63, 127, 63),
    name="Goblin",
    ai_cls=HostileEnemy,
    equipment=Equipment(),
    fighter=Fighter(hp=10, base_defense=0, base_power=3),
    inventory=Inventory(capacity=0),
    level=Level(xp_given=35),
)
troll = Actor(
    char="T",
    color=(0, 127, 0),
from components.ai import HostileEnemy
from components.fighter import Fighter
from entity import Actor

player = Actor(
    char='@',
    color=(255, 255, 255),
    name='Roscoe',
    ai_cls=HostileEnemy,
    fighter=Fighter(hp=30, defense=2, power=5),
)

orc = Actor(
    char='o',
    color=(63, 127, 63),
    name='Orc',
    ai_cls=HostileEnemy,
    fighter=Fighter(hp=10, defense=0, power=3),
)

troll = Actor(
    char='T',
    color=(0, 127, 0),
    name='Troll',
    ai_cls=HostileEnemy,
    fighter=Fighter(hp=16, defense=1, power=4),
)
Beispiel #25
0
from components.ai import HostileEnemy
from components.fighter import Fighter
from components import consumable
from components.inventory import Inventory
from components.level import Level
from entity import Actor, Item

player = Actor(
    char="@",
    color=(255, 255, 255),
    name="Player",
    ai_cls=HostileEnemy,
    fighter=Fighter(hp=30, defense=2, power=5),
    inventory=Inventory(capacity=26),
    level=Level(level_up_base=200),
)
grunt = Actor(char="o",
              color=(63, 127, 63),
              name="grunt",
              ai_cls=HostileEnemy,
              fighter=Fighter(hp=10, defense=0, power=3),
              inventory=Inventory(capacity=0),
              level=Level(xp_given=50))
juggernaut = Actor(
    char="T",
    color=(0, 127, 0),
    name="juggernaut",
    ai_cls=HostileEnemy,
    fighter=Fighter(hp=16, defense=1, power=4),
    inventory=Inventory(capacity=0),
    level=Level(xp_given=100),
from components.ai import HostileEnemy
from components.fighter import Fighter
from entity import Actor

player = Actor(
    char="@",
    color=(255, 255, 255),
    name="Player",
    ai_cls=HostileEnemy,
    fighter=Fighter(hp=30, defense=2, power=5),
)

pixie = Actor(
    char="p",
    color=(217, 65, 194),
    name="Pixie",
    ai_cls=HostileEnemy,
    fighter=Fighter(hp=10, defense=0, power=3),
)

goblin = Actor(
    char="g",
    color=(0, 127, 0),
    name="Goblin",
    ai_cls=HostileEnemy,
    fighter=Fighter(hp=16, defense=1, power=4),
)
Beispiel #27
0
from components.ai import HostileEnemy
from components import consumable, equippable
from components.equipment import Equipment
from components.fighter import Fighter
from components.inventory import Inventory
from components.level import Level
from entity import Actor, Item

import copy

player = Actor(char="@",
               color=(255, 255, 255),
               name="Player",
               ai_cls=HostileEnemy,
               equipment=Equipment(),
               fighter=Fighter(hp=30),
               inventory=Inventory(capacity=26),
               level=Level(level_up_base=200),
               strength=12)

goblin = Actor(char="g",
               color=(63, 127, 63),
               name="Goblin",
               ai_cls=HostileEnemy,
               equipment=Equipment(),
               fighter=Fighter(hp=7),
               inventory=Inventory(capacity=0),
               level=Level(xp_given=50),
               strength=8,
               dexterity=14)
from components.ai import HostileEnemy
from components import consumable, equippable
from components.equipment import Equipment
from components.fighter import Fighter
from components.inventory import Inventory
from components.level import Level
from entity import Actor, Item

player = Actor(
    char="@",
    color=(255, 255, 255),
    name="Player",
    ai_cls=HostileEnemy,
    equipment=Equipment(),
    fighter=Fighter(hp=30, base_defense=1, base_power=2),
    inventory=Inventory(capacity=26),
    level=Level(level_up_base=200),
)
orc = Actor(
    char="o",
    color=(63, 127, 63),
    name="Orc",
    ai_cls=HostileEnemy,
    equipment=Equipment(),
    fighter=Fighter(hp=10, base_defense=0, base_power=3),
    inventory=Inventory(capacity=0),
    level=Level(xp_given=35),
)
troll = Actor(
    char="T",
    color=(0, 127, 0),
Beispiel #29
0
from components.ai import HostileEnemy
from components.consumable import HealingConsumable
from components.fighter import Fighter
from components.inventory import Inventory
from components.level import Level
from entity import Actor, Item

player = Actor(
    char="@",
    color=(255, 255, 255),
    name="Player",
    ai_cls=HostileEnemy,
    fighter=Fighter(hp=30, defense=1, power=7),
    inventory=Inventory(capacity=26),
    level=Level(level_up_base=200),
)

# small healing potions

open_front_unrounded_vowel = Item(
    char="Ω",
    color=(158, 48, 87),
    name="Open Front Unrounded Vowel",
    consumable=HealingConsumable(amount=4),
)

open_back_unrounded_vowel = Item(
    char="δ",
    color=(158, 48, 87),
    name="Open Back Unrounded Vowel",
    consumable=HealingConsumable(amount=5),