Esempio n. 1
0
def bat(point=None, dungeon_level=1):
    health_component = Health(4)

    creature = Character(point,
                         'B',
                         'bat',
                         COLORS.get('bat'),
                         ai=PredatorNPC(species=Species.INSECT),
                         species=Species.BAT,
                         health=health_component,
                         act_energy=3)

    creature.add_component(Offence(base_power=1), 'offence')
    creature.add_component(Defence(defence=1), 'defence')
    creature.add_component(Level(xp_value=10), 'level')

    teeth = equipment.teeth()
    teeth.lootable = False

    creature.inventory.add_item(teeth)
    creature.equipment.toggle_equip(teeth)

    if randint(1, 100) >= 70:
        equipment.add_lifedrain(teeth)
        creature.add_component(Naming(creature.base_name, prefix='Vampiric'),
                               'naming')

    return creature
Esempio n. 2
0
    def load_hero(self):
        # Load Character
        hero_scale = SCALE_REFERENCE["character.png"]
        idle_imgs = load_image_folder(os.path.join(CHARACTER_PATH, 'idle'),
                                      scale=hero_scale)
        base_imgs = load_image(os.path.join(CHARACTER_PATH, 'idle', '0.png'),
                               scale=hero_scale)
        attack_imgs = [
            load_image_folder(os.path.join(CHARACTER_PATH, 'attack', '1'),
                              scale=hero_scale),
            load_image_folder(os.path.join(CHARACTER_PATH, 'attack', '2'),
                              scale=hero_scale),
            load_image_folder(os.path.join(CHARACTER_PATH, 'attack', '3'),
                              scale=hero_scale)
        ]
        run_imgs = load_image_folder(os.path.join(CHARACTER_PATH, 'run'),
                                     scale=hero_scale)
        jump_imgs = load_image_folder(os.path.join(CHARACTER_PATH, 'jump'),
                                      scale=hero_scale)
        fall_imgs = load_image_folder(os.path.join(CHARACTER_PATH, 'fall'),
                                      scale=hero_scale)

        hero_images = {
            'idle': idle_imgs,
            'base': base_imgs,
            'attack': attack_imgs,
            'run': run_imgs,
            'jump': jump_imgs,
            'fall': fall_imgs
        }

        self.hero = Character(self.initial_position, hero_images)
Esempio n. 3
0
    def __init__(self, char_id):
        '''Constructor for the PartyMember class. Initialises a Character object.

        args:
            char_id: str; a unique identifier for the character
        '''
        Character.__init__(self, char_id)

        info = load_party_info(self._id)
        self._name = info[0]
        self._lvl = info[1]
Esempio n. 4
0
    def __init__(self, char_id):
        '''Constructor for the monster class. Initialises a Character object.

        args:
            char_id: str; a unique identifier for the monster
        '''
        Character.__init__(self, char_id)

        self._info = load_monster_info(self._id)
        self._inventory = load_inventory(self._id)

        self._default_action = self._set_default_action()
Esempio n. 5
0
def hornets_nest(point=None, dungeon_level=1):
    health_component = Health(20)

    creature = Character(point,
                         chr(234),
                         SPECIES_STRINGS[Species.HORNETNEST],
                         COLORS.get('hornets_nest'),
                         ai=SpawningNPC(hornets),
                         species=Species.HORNETNEST,
                         health=health_component,
                         act_energy=2)

    creature.add_component(Defence(defence=5), 'defence')
    creature.add_component(Level(xp_value=50), 'level')
    creature.add_component(Children(5), 'children')

    creature.movement.routing_avoid.extend(creature_avoid)

    armour = equipment.random_armour(dungeon_level=dungeon_level)
    armour.lootable = False
    equipment.add_spawning(item=armour, entity=hornets)
    creature.inventory.add_item(armour)
    creature.equipment.toggle_equip(armour)

    equipment.add_random_loot(creature, dungeon_level)

    return creature
Esempio n. 6
0
def rat(point=None, dungeon_level=1):
    health_component = Health(4)

    creature = Character(point,
                         'R',
                         'rat',
                         COLORS.get('rat'),
                         ai=PredatorNPC(species=Species.EGG),
                         species=Species.RAT,
                         health=health_component,
                         act_energy=3)

    creature.add_component(Offence(base_power=1), 'offence')
    creature.add_component(Defence(defence=1), 'defence')
    creature.add_component(Level(xp_value=10), 'level')

    creature.movement.routing_avoid.extend(creature_avoid)

    teeth = equipment.teeth()
    teeth.lootable = False

    creature.inventory.add_item(teeth)
    creature.equipment.toggle_equip(teeth)

    pubsub.pubsub.subscribe(
        pubsub.Subscription(creature, pubsub.PubSubTypes.ATTACKED, rat_swarm))

    return creature
Esempio n. 7
0
def goblin(point=None, dungeon_level=1):
    #create a goblin
    health_component = Health(20)
    ai_component = BasicNPC()

    npc = Character(point,
                    'G',
                    'goblin',
                    COLORS.get('goblin'),
                    ai=ai_component,
                    species=Species.GOBLIN,
                    health=health_component,
                    act_energy=5)

    npc.add_component(Offence(base_power=5), 'offence')
    npc.add_component(Defence(defence=5), 'defence')
    npc.add_component(Level(xp_value=10), 'level')

    npc.movement.routing_avoid.extend(npc_avoid)

    dagger = equipment.create_weapon('dagger')
    dagger.lootable = False

    npc.inventory.add_item(dagger)
    npc.equipment.toggle_equip(dagger)

    pubsub.pubsub.subscribe(
        pubsub.Subscription(npc, pubsub.PubSubTypes.DEATH,
                            goblin_observed_death))

    return npc
Esempio n. 8
0
def gelatinous_cube(point=None, dungeon_level=1):
    npc = Character(point,
                    'C',
                    'gelatinous cube',
                    COLORS.get('gelatinous_cube'),
                    ai=CleanerNPC(),
                    species=Species.OOZE,
                    render_order=RenderOrder.OVERLAY,
                    health=Health(20))

    npc.add_component(Offence(base_power=1), 'offence')
    npc.add_component(Defence(defence=1), 'defence')
    npc.add_component(Level(xp_value=10), 'level')

    cube_avoid = [
        Tiles.INTERNAL_DOOR, Tiles.EXIT_DOOR, Tiles.DOOR, Tiles.CAVERN_FLOOR,
        Tiles.FUNGAL_CAVERN_FLOOR, Tiles.ROOM_FLOOR, Tiles.SHALLOW_WATER,
        Tiles.DEEP_WATER, Tiles.STAIRS_FLOOR, Tiles.SPAWN_POINT
    ]

    npc.movement.routing_avoid.extend(cube_avoid)

    pseudopod = equipment.pseudopod()
    pseudopod.lootable = False
    equipment.add_paralysis(pseudopod)

    npc.inventory.add_item(pseudopod)
    npc.equipment.toggle_equip(pseudopod)

    return npc
Esempio n. 9
0
def orc(point=None, dungeon_level=1):
    #create an orc
    health_component = Health(20)
    ai_component = BasicNPC()

    npc = Character(point,
                    'O',
                    'orc',
                    COLORS.get('orc'),
                    ai=ai_component,
                    species=Species.ORC,
                    health=health_component,
                    act_energy=5)

    npc.add_component(Offence(base_power=10), 'offence')
    npc.add_component(Defence(defence=4), 'defence')
    npc.add_component(Level(xp_value=10), 'level')

    npc.movement.routing_avoid.extend(npc_avoid)

    item = equipment.create_weapon('shortsword')
    item.lootable = False

    npc.inventory.add_item(item)
    npc.equipment.toggle_equip(item)

    return npc
Esempio n. 10
0
def create_chest(point=None, dungeon_level=1):
    npc = Character(point,
                    'C',
                    'Chest',
                    COLORS.get('chest'),
                    species=Species.NONDESCRIPT)

    if randint(1, 100) >= 95:
        return mimic(point, dungeon_level=1)

    npc.add_component(Health(10), 'health')
    npc.add_component(Defence(defence=2), 'defence')
    npc.add_component(Offence(base_power=0), 'offence')
    #TODO: Generate random level appropriate loot in chest
    potion = equipment.random_potion(dungeon_level=dungeon_level)
    potion.lootable = True

    scroll = equipment.random_scroll(dungeon_level=dungeon_level)
    scroll.lootable = True

    weapon = equipment.random_magic_weapon(dungeon_level=dungeon_level)
    weapon.lootable = True

    armour = equipment.random_armour(dungeon_level=dungeon_level)
    armour.lootable = True

    npc.inventory.add_item(potion)
    npc.inventory.add_item(scroll)
    npc.inventory.add_item(weapon)
    npc.inventory.add_item(armour)

    return npc
Esempio n. 11
0
def necromancer(point=None, dungeon_level=1):
    #create a necromancer
    health_component = Health(30)
    ai_component = NecromancerNPC()

    npc = Character(point,
                    'N',
                    'necromancer',
                    COLORS.get('necromancer'),
                    ai=ai_component,
                    species=Species.NONDESCRIPT,
                    health=health_component)

    npc.add_component(Offence(base_power=12), 'offence')
    npc.add_component(Defence(defence=8), 'defence')
    npc.add_component(Level(xp_value=10), 'level')
    npc.add_component(Children(6), 'children')

    npc.movement.routing_avoid.extend(npc_avoid)

    npc_level = (dungeon_level - 1) + randint(-1, 1)

    if npc_level > 1:
        npc.level.random_level_up(npc_level - 1)

    weapon = equipment.random_magic_weapon(dungeon_level=dungeon_level)
    weapon.lootable = True

    npc.inventory.add_item(weapon)
    npc.equipment.toggle_equip(weapon)

    num_of_potions = randint(0, 3)

    for _ in range(num_of_potions):
        potion = equipment.random_potion(dungeon_level=dungeon_level)
        potion.lootable = True
        npc.inventory.add_item(potion)

    num_of_scrolls = randint(0, 3)

    for _ in range(num_of_scrolls):
        scroll = equipment.random_scroll(dungeon_level=dungeon_level)
        scroll.lootable = True
        npc.inventory.add_item(scroll)

    return npc
Esempio n. 12
0
def warlord(point=None, dungeon_level=1):
    #create a warlord
    ai_component = WarlordNPC()
    health_component = Health(50)

    npc = Character(point,
                    'W',
                    'Warlord',
                    COLORS.get('warlord'),
                    ai=ai_component,
                    species=Species.ORC,
                    death=WarlordDeath(),
                    health=health_component)

    npc.add_component(Offence(base_power=10), 'offence')
    npc.add_component(Defence(defence=4), 'defence')
    npc.add_component(Level(xp_value=10), 'level')

    npc.movement.routing_avoid.extend(npc_avoid)

    npc_level = (dungeon_level - 1) + randint(-1, 1)

    if npc_level > 1:
        npc.level.random_level_up(npc_level - 1)

    item = equipment.create_weapon('longsword')
    item.base_name = item.base_name + " of I'll F*****G Have You"
    item.color = COLORS.get('equipment_epic')
    item.equippable.power = item.equippable.power * 2
    npc.inventory.add_item(item)
    npc.equipment.toggle_equip(item)

    shield = equipment.create_armour('steel shield')
    shield.base_name = shield.base_name + " of Hide and Seek"
    shield.color = COLORS.get('equipment_epic')
    shield.equippable.power = item.equippable.defence * 2
    npc.inventory.add_item(shield)
    npc.equipment.toggle_equip(shield)

    breastplate = equipment.create_armour('breastplate')
    breastplate.base_name = breastplate.base_name + " of Rebounding"
    breastplate.color = COLORS.get('equipment_epic')
    breastplate.equippable.power = item.equippable.defence * 2
    npc.inventory.add_item(breastplate)
    npc.equipment.toggle_equip(breastplate)

    return npc
Esempio n. 13
0
def bountyhunter(point):
    #create a questgiver

    ai_component = TetheredNPC(4, point)
    npc = Character(point,
                    '?',
                    'Bounty Hunter',
                    COLORS.get('bounty_hunter'),
                    ai=ai_component,
                    interaction=Interactions.QUESTGIVER,
                    species=Species.NONDESCRIPT,
                    act_energy=6)
    npc.add_component(Offence(base_power=0), 'offence')
    npc.add_component(Defence(defence=0), 'defence')
    npc.add_component(Questgiver(), 'questgiver')

    npc.movement.routing_avoid.extend(npc_avoid)

    return npc
Esempio n. 14
0
def rats_nest(point=None, dungeon_level=1):
    health_component = Health(20)

    creature = Character(point,
                         'N',
                         SPECIES_STRINGS[Species.RATNEST],
                         COLORS.get('rats_nest'),
                         ai=SpawningNPC(rat),
                         species=Species.RATNEST,
                         health=health_component,
                         act_energy=2)

    creature.add_component(Defence(defence=5), 'defence')
    creature.add_component(Level(xp_value=50), 'level')
    creature.add_component(Children(5), 'children')

    creature.movement.routing_avoid.extend(creature_avoid)

    equipment.add_random_loot(creature, dungeon_level)

    return creature
Esempio n. 15
0
def egg(point=None, dungeon_level=1):
    health_component = Health(4)

    creature = Character(point,
                         'E',
                         'Snake Egg',
                         COLORS.get('snake_egg'),
                         ai=HatchingNPC(snake),
                         species=Species.EGG,
                         health=health_component)

    creature.movement.routing_avoid.extend(creature_avoid)

    creature.add_component(Offence(base_power=1), 'offence')
    creature.add_component(Defence(defence=1), 'defence')

    return creature
Esempio n. 16
0
class Game:
    def __init__(self):
        self.canvas = pygame.display.set_mode((960, 580))
        self.initial_position = pygame.Vector2(0, 0)
        self.hero = None
        self.current_level = 0
        self.clock = None
        self.blocks = None
        self.enemies = None
        self.running = False

        self.tiles_groups = {}
        self.tiles_images = {}

    def load_hero(self):
        # Load Character
        hero_scale = SCALE_REFERENCE["character.png"]
        idle_imgs = load_image_folder(os.path.join(CHARACTER_PATH, 'idle'),
                                      scale=hero_scale)
        base_imgs = load_image(os.path.join(CHARACTER_PATH, 'idle', '0.png'),
                               scale=hero_scale)
        attack_imgs = [
            load_image_folder(os.path.join(CHARACTER_PATH, 'attack', '1'),
                              scale=hero_scale),
            load_image_folder(os.path.join(CHARACTER_PATH, 'attack', '2'),
                              scale=hero_scale),
            load_image_folder(os.path.join(CHARACTER_PATH, 'attack', '3'),
                              scale=hero_scale)
        ]
        run_imgs = load_image_folder(os.path.join(CHARACTER_PATH, 'run'),
                                     scale=hero_scale)
        jump_imgs = load_image_folder(os.path.join(CHARACTER_PATH, 'jump'),
                                      scale=hero_scale)
        fall_imgs = load_image_folder(os.path.join(CHARACTER_PATH, 'fall'),
                                      scale=hero_scale)

        hero_images = {
            'idle': idle_imgs,
            'base': base_imgs,
            'attack': attack_imgs,
            'run': run_imgs,
            'jump': jump_imgs,
            'fall': fall_imgs
        }

        self.hero = Character(self.initial_position, hero_images)

    def load_level(self):
        # Load Map TODO will change when the levels are ready
        tiles_list = [
            p for p in os.listdir(TILES_PATH) if p != "character.png"
        ]
        self.tiles_images = {
            tile: load_image(os.path.join(TILES_PATH, tile),
                             scale=SCALE_REFERENCE[tile])
            for tile in tiles_list
        }
        self.tiles_groups = {
            tile: pygame.sprite.Group()
            for tile in tiles_list
        }
        with open(os.path.join(LEVELS_PATH, f"{self.current_level}.json"),
                  "r") as json_file:
            level_data = json.load(json_file)

        for pos in level_data:
            for tile in level_data[pos]["tiles"]:
                if tile["tile"] == "character.png":
                    self.initial_position = pygame.Vector2(
                        level_data[pos]["x"] * 64, level_data[pos]["y"] * 64)
                    continue
                pos_vec = pygame.Vector2(level_data[pos]["x"] * 64,
                                         level_data[pos]["y"] * 64)
                self.tiles_groups[tile["tile"]].add(
                    OBJECT_REFERENCE[tile["tile"]](
                        pos_vec, self.tiles_images[tile["tile"]]))

    def start(self):
        pygame.init()
        # clock - FPS
        self.clock = pygame.time.Clock()
        # mainloop
        self.running = True
        # load main menu
        self.load_level()
        self.load_hero()

    def update(self):
        while self.running:
            for event in pygame.event.get():
                if event.type == QUIT:
                    self.running = False
                elif event.type == KEYDOWN:
                    if event.key == K_ESCAPE:
                        self.running = False
                    elif event.key == K_x:
                        self.hero.attack()
                    elif event.key == K_UP:
                        self.hero.jump()

            pressed = pygame.key.get_pressed()
            if pressed[K_LEFT]:
                self.hero.move(left=True)
            elif pressed[K_RIGHT]:
                self.hero.move()
            else:
                self.hero.stop_moving()

            self.canvas.fill((0, 0, 0))

            for name, group in self.tiles_groups.items():
                group.draw(self.canvas)
                for b_sprite in group.sprites():
                    b_sprite.draw_line_limit(self.canvas, color=(255, 0, 0))
                self.hero.update(self.canvas, group)
            pygame.display.flip()

            self.clock.tick(15)

        pygame.quit()

    def main(self):
        self.start()
        self.update()
Esempio n. 17
0
class TestCharacter(unittest.TestCase):
    def setUp(self):
        initialise_db()
        pg.init()
        pg.display.set_mode(NATIVE_RESOLUTION, pg.HIDDEN)
        self.char = Character('bob')
        self.char.inventory = load_inventory('bob')

    def tearDown(self):
        pg.quit()

    def test_check_hp_within_limits(self):
        self.char.curr_hp = 50
        self.char.check_hp()
        self.assertEqual(self.char.curr_hp, 50)

    def test_check_hp_too_high(self):
        self.char.curr_hp = 200
        self.char.check_hp()
        self.assertEqual(self.char.curr_hp, self.char._stats.hp)

    def test_check_hp_negative(self):
        self.char.curr_hp = -1
        self.char.check_hp()
        self.assertEqual(self.char.curr_hp, 0)

    def test_char_dies_when_hp_is_zero(self):
        self.char.curr_hp = 0
        self.char.check_hp()
        self.assertFalse(self.char.alive)

    def test_check_mp_within_limits(self):
        self.char.curr_mp = 5
        self.char.check_mp()
        self.assertEqual(self.char.curr_mp, 5)

    def test_check_mp_too_high(self):
        self.char.curr_mp = 20
        self.char.check_mp()
        self.assertEqual(self.char.curr_mp, self.char._stats.mp)

    def test_use_item_in_inv(self):
        test_info = self.char.use_item('test_item1', self.char)
        expected = [('hp', 20), ('mp', 5)]
        self.assertEqual(test_info, expected)

    def test_use_item_not_enough_in_inv(self):
        self.char.use_item('test_item1', self.char)
        test_info = self.char.use_item('test_item1', self.char)
        expected = 'Not enough TEST ITEM 1s in inventory!'
        self.assertEqual(test_info, expected)

    def test_use_item_not_in_inv(self):
        test_info = self.char.use_item('slp_tblt', self.char)
        self.assertIsInstance(test_info, ValueError)

    def test_use_skill_info_is_ok(self):
        target = Character('bob')
        test_info = self.char.use_skill('test_skill', target)
        self.assertEqual(len(test_info), 2)

    def test_use_skill_battlesprites_ok(self):
        target = Character('bob')
        self.char.use_skill('test_skill', target)
        actual = (self.char.battlesprite._action, target.battlesprite._action)
        self.assertEqual(actual, (1, 2))

    def test_use_skill_uses_mp(self):
        target = Character('bob')
        self.char.use_skill('test_magic', target)
        self.assertLess(self.char.curr_mp, self.char._stats.mp)

    def test_use_skill_not_enough_mp(self):
        self.char.curr_mp = 0
        target = Character('bob')
        test_info = self.char.use_skill('test_magic', target)
        self.assertEqual(test_info, 'Not enough MP!')

    def test_use_skill_not_in_char_skills(self):
        target = Character('bob')
        test_info = self.char.use_skill('energy_blst', target)
        self.assertEqual(test_info, 'bob does not know skill energy_blst!')

    def test_get_item_qty_in_inv(self):
        test_qty = self.char.get_item_qty('test_item1')
        self.assertEqual(test_qty, 1)

    def test_get_item_qty_not_in_inv(self):
        test_qty = self.char.get_item_qty('slp_tblt')
        self.assertEqual(test_qty, 'no item slp_tblt in inventory!')

    def test_get_skill_cost_not_in_char_skills(self):
        test_cost = self.char.get_skill_cost('energy_blst')
        self.assertEqual(test_cost, 'bob does not know skill energy_blst!')

    def test_get_skill_cost(self):
        test_cost = self.char.get_skill_cost('test_skill')
        self.assertEqual(test_cost, 0)

    def test_propeties(self):
        test_properties = [
            self.char.id, self.char.max_hp, self.char.max_mp, self.char.atk,
            self.char.defs, self.char.mag, self.char.mdef
        ]
        expected = ['bob', 100, 10, 10, 10, 5, 5]
        self.assertEqual(test_properties, expected)

    def test_res(self):
        expected = {
            'physical': 1.0,
            'fire': 0.0,
            'ice': 1.5,
            'lightning': 1.0,
            'wind': 1.0,
            'light': 0.5,
            'dark': -1.0
        }
        self.assertEqual(self.char.res, expected)

    def test_skills(self):
        self.assertIsInstance(self.char.skills, dict)

    def test_inventory(self):
        self.assertIsInstance(self.char.inventory, dict)

    def test_inventory_setter(self):
        self.char.inventory = {}
        self.assertFalse(self.char.inventory)
Esempio n. 18
0
 def test_use_skill_not_in_char_skills(self):
     target = Character('bob')
     test_info = self.char.use_skill('energy_blst', target)
     self.assertEqual(test_info, 'bob does not know skill energy_blst!')
Esempio n. 19
0
 def test_use_skill_not_enough_mp(self):
     self.char.curr_mp = 0
     target = Character('bob')
     test_info = self.char.use_skill('test_magic', target)
     self.assertEqual(test_info, 'Not enough MP!')
Esempio n. 20
0
 def test_use_skill_uses_mp(self):
     target = Character('bob')
     self.char.use_skill('test_magic', target)
     self.assertLess(self.char.curr_mp, self.char._stats.mp)
Esempio n. 21
0
 def test_use_skill_battlesprites_ok(self):
     target = Character('bob')
     self.char.use_skill('test_skill', target)
     actual = (self.char.battlesprite._action, target.battlesprite._action)
     self.assertEqual(actual, (1, 2))
Esempio n. 22
0
 def test_use_skill_info_is_ok(self):
     target = Character('bob')
     test_info = self.char.use_skill('test_skill', target)
     self.assertEqual(len(test_info), 2)
Esempio n. 23
0
 def setUp(self):
     initialise_db()
     pg.init()
     pg.display.set_mode(NATIVE_RESOLUTION, pg.HIDDEN)
     self.char = Character('bob')
     self.char.inventory = load_inventory('bob')
Esempio n. 24
0
         #Prep
         count_letters = 0
         character_name = ""
         #Checking for name to add to list variable key
         while count_letters < len(
                 character_data) and character_data[count_letters] != ":":
             character_name += character_data[count_letters]
             count_letters += 1
         character_info.append(character_name)
         count_letters += 1
         #Checking for stats to add to corresponding variable key
         while count_letters < len(character_data):
             #Checking for
             if character_data[count_letters] != "," and character_data[
                     count_letters] != "\n" and character_data[
                         count_letters] != " ":
                 character_info.append(character_data[count_letters])
             count_letters += 1
         #Character list updated
         character = Character(
             character_info[0], character_info[1], character_info[2],
             character_info[3], character_info[4], character_info[5],
             character_info[6], character_info[7], character_info[8],
             character_info[9], character_info[10], character_info[11],
             character_info[12], character_info[13], character_info[14],
             character_info[15], character_info[16], character_info[17],
             character_info[18], character_info[19], character_info[20],
             character_info[21], character_info[22])
         characters.update({characters_num: character})
 #Move to next line
 count_story += 1
Esempio n. 25
0
taunt = Move("Taunt", "MagicalAffinity", 0, "MagicalControl", 0, "MagicalControl", 0, "PhysicalGrace", 0, "SocialPresence", 4, [taunt_efc], "SocialHeart", 1, "SocialHeart", 1)
attack = Move("Physical Attack", "PhysicalSkill", 1, "PhysicalSkill", 1, "MagicalControl", 0, "PhysicalGrace", 2, "PhysicalGrace", 2, effects.values(), "SocialHeart", 0, "PhysicalGrace", 0)
cressida_timestop = Move("Cressida\'s Timestop", "MagicalAffinity", 0, "MagicalControl", 0, "MagicalControl", 1, "PhysicalGrace", 0, "MagicalConcentration", 1, [timestop_efc], "MagicalAffinity", 3, "MagicalAffinity", 0)
skip = Move("Skip turn", "MagicalAffinity", 0, "MagicalAffinity", 0, "MagicalAffinity", 0, "MagicalAffinity", 0, "MagicalAffinity", 0, [], "MagicalAffinity", 0, "MagicalAffinity", 0)
spells = {
  "Damage": damage,
  "Element": element,
  "Area": area,
  "Heal": heal,
  "Rally": rally,
  "Attack": attack,
}

#Each point in a physical skill increases HP by 2, party members start with 5HP
#Example = Character(name, HP, MaxHP, SP, MaxSP, MP, MaxMP, SPresence, SHeart, SStability, PGrace, PSkill, PPoise, MAffinity, MControl, MConcentration, InventoryList, TraumaList, EffectsList, TagsList, Move, Move2, Move3, op_maxDeaths, op_deaths)
Esteri = Character("Esteri", 29, 29, 19, 19, 7, 7, 3, 3, 1, 5, 4, 3, 0, 0, 1, [], [], [], [], attack, rally, area) #Esteri max: 29+19+7 = 55
Cressida = Character("Cressida", 13, 13, 25, 25, 21, 21, 4, 3, 3, 0, 1, 3, 2, 3, 3, [], [], [], [], heal, damage, rally) #Cressida max: 13+25+21 = 59
Kosu = Character("Kosu", 21, 21, 29, 29, 5, 5, 4, 5, 3, 3, 4, 1, 0, 0, 0, [], [], [], [], attack, rally, element) #Kosu max: 21+29+5 = 55
Ai = Character("Ai", 7, 7, 15, 15, 33, 33, 1, 4, 0, 0, 1, 0, 4, 5, 5, [], ["grief"], [], [], damage, element, area) #Ai max: 7+15+33= 55
#Ai starts with grief
Amaliyah = Character("Amaliyah", 29, 29, 19, 19, 10, 10, 3, 3, 1, 5, 4, 3, 4, 0, 1, [], [], [], [], attack, element, heal)
PartyDronae = Character("Dronae", 20, 20, 10, 10, 0, 0, 2, 4, 1, 3, 1, 1, 1, 1, 1, [], [], [], [], heal, heal, attack)

characters = {
  "Esteri": Esteri,
  "Cressida": Cressida,
  "Kosu": Kosu,
  "Kosugade": Kosu,
  "Ai": Ai,
  "Amaliyah": Amaliyah,
  "Friendly Dronae": PartyDronae,
Esempio n. 26
0
def mimic(point=None, dungeon_level=1):
    npc = Character(point,
                    'C',
                    'Chest',
                    COLORS.get('mimic'),
                    species=Species.CREATURE)

    npc.add_component(Health(30), 'health')
    npc.add_component(Offence(base_power=3), 'offence')
    npc.add_component(Defence(defence=3), 'defence')
    npc.add_component(Level(xp_value=50), 'level')
    display_char = ['C'] * 10
    display_char.append('M')
    display_char.append('M')
    display_char.append('M')
    display_char.append('M')
    display_char.append('M')
    npc.add_component(Display(display_char), 'display')

    teeth = equipment.teeth()
    teeth.lootable = False

    npc.inventory.add_item(teeth)
    npc.equipment.toggle_equip(teeth)

    pubsub.pubsub.subscribe(
        pubsub.Subscription(npc, pubsub.PubSubTypes.ATTACKED, mimic_activate))

    return npc
Esempio n. 27
0
def snake(point=None, dungeon_level=1):
    health_component = Health(8)

    creature = Character(point,
                         'S',
                         'snake',
                         COLORS.get('snake'),
                         ai=PredatorNPC(species=Species.RAT),
                         species=Species.SNAKE,
                         health=health_component,
                         act_energy=3)

    creature.add_component(Offence(base_power=1), 'offence')
    creature.add_component(Defence(defence=1), 'defence')
    creature.add_component(Level(xp_value=10), 'level')
    creature.add_component(Spawn(2, egg), 'spawn')

    creature.movement.routing_avoid.extend(creature_avoid)

    teeth = equipment.teeth()

    if randint(1, 100) >= 50:
        equipment.add_poison(teeth, 1, 5)
        creature.add_component(Naming(creature.base_name, prefix='Poisonous'),
                               'naming')
        creature.color = COLORS.get('poisonous_snake')

    teeth.lootable = False

    creature.inventory.add_item(teeth)
    creature.equipment.toggle_equip(teeth)

    pubsub.pubsub.subscribe(
        pubsub.Subscription(creature, pubsub.PubSubTypes.DEATH, eat_rat))

    return creature
Esempio n. 28
0
def hornets(point=None, dungeon_level=1):
    health_component = Health(2)

    creature = Character(point,
                         chr(178),
                         'hornet',
                         COLORS.get('hornet'),
                         ai=BasicNPC(),
                         species=Species.INSECT,
                         health=health_component,
                         act_energy=3)

    creature.add_component(Offence(base_power=1), 'offence')
    creature.add_component(Defence(defence=1), 'defence')
    creature.add_component(Level(xp_value=10), 'level')
    creature.add_component(
        Display([
            chr(176),
            chr(176),
            chr(176),
            chr(177),
            chr(177),
            chr(177),
            chr(178),
            chr(178),
            chr(178)
        ]), 'display')
    creature.add_component(
        DamageModifier(blunt=0.8,
                       slashing=0.8,
                       fire=1.2,
                       ice=1.2,
                       electric=1.2), 'damagemodifier')

    teeth = equipment.teeth()
    teeth.lootable = False

    creature.inventory.add_item(teeth)
    creature.equipment.toggle_equip(teeth)

    return creature
Esempio n. 29
0
def troll(point=None, dungeon_level=1):
    #create a troll
    health_component = Health(30)
    ai_component = BasicNPC()

    npc = Character(point,
                    'T',
                    'troll',
                    COLORS.get('troll'),
                    ai=ai_component,
                    species=Species.TROLL,
                    health=health_component,
                    act_energy=6)

    npc.add_component(Offence(base_power=12), 'offence')
    npc.add_component(Defence(defence=8), 'defence')
    npc.add_component(Level(xp_value=10), 'level')
    regen = Regeneration()
    npc.add_component(regen, 'regeneration')
    npc.add_component(DamageModifier(fire=1.5), 'damagemodifier')
    regen.start()

    npc.movement.routing_avoid.extend(npc_avoid)

    item = None
    dice = randint(1, 100)
    if dice > 75:
        item = equipment.create_weapon('heavy mace')
        equipment.add_smashing(item)
    else:
        item = equipment.create_weapon('longsword')

    item.lootable = False

    npc.inventory.add_item(item)
    npc.equipment.toggle_equip(item)

    return npc
Esempio n. 30
0
def create_player():
    #create object representing the player
    health_component = Health(30)

    player = Character(None,
                       '@',
                       'player',
                       COLORS.get('player'),
                       death=PlayerDeath(),
                       health=health_component,
                       species=Species.PLAYER,
                       act_energy=4)

    player.add_component(Offence(base_power=6), 'offence')
    player.add_component(Defence(defence=6), 'defence')
    player.add_component(Level(), 'level')
    player.add_component(FOV(), 'fov')

    #initial equipment: a dagger
    dagger = equipment.create_weapon('dagger')

    player.inventory.add_item(dagger)
    player.equipment.toggle_equip(dagger)

    armour = equipment.create_armour('leather shirt')
    player.inventory.add_item(armour)
    player.equipment.toggle_equip(armour)

    if CONFIG.get('debug'):
        player.level.random_level_up(30)
        weapon = equipment.random_magic_weapon()
        player.inventory.add_item(weapon)
        player.equipment.toggle_equip(weapon)

        armour = equipment.random_armour()
        #equipment.add_damage_aura(armour)
        player.inventory.add_item(armour)
        player.equipment.toggle_equip(armour)

        ring = equipment.random_ring()
        player.inventory.add_item(ring)
        player.equipment.toggle_equip(ring)

        potion = equipment.healing_potion()
        player.inventory.add_item(potion)

        potion2 = equipment.power_potion()
        potion2.identifiable.identified = True
        player.inventory.add_item(potion2)

        potion3 = equipment.defence_potion()
        potion3.identifiable.identified = True
        player.inventory.add_item(potion3)

        potion4 = equipment.speed_potion()
        potion4.identifiable.identified = True
        player.inventory.add_item(potion4)

        scroll1 = equipment.lighting_scroll()
        scroll1.identifiable.identified = True
        player.inventory.add_item(scroll1)

        scroll2 = equipment.fireball_scroll()
        scroll2.identifiable.identified = True
        player.inventory.add_item(scroll2)

        scroll3 = equipment.confusion_scroll()
        scroll3.identifiable.identified = True
        player.inventory.add_item(scroll3)

        scroll4 = equipment.identify_scroll()
        scroll4.identifiable.identified = True
        player.inventory.add_item(scroll4)

        scroll5 = equipment.speed_scroll()
        scroll5.identifiable.identified = True
        player.inventory.add_item(scroll5)

        scroll6 = equipment.teleport_scroll()
        scroll6.identifiable.identified = True
        player.inventory.add_item(scroll6)

        scroll7 = equipment.map_scroll()
        scroll7.identifiable.identified = True
        player.inventory.add_item(scroll7)

        scroll8 = equipment.chain_lightning_scroll()
        scroll8.identifiable.identified = True
        player.inventory.add_item(scroll8)

    pubsub.pubsub.subscribe(
        pubsub.Subscription(player, pubsub.PubSubTypes.EARNEDXP,
                            earn_quest_xp))

    return player