Beispiel #1
0
 def load_def(self, defkey):
     for k, v in DEFS[defkey].items():
         setattr(self, k, v)
     creature_passive_def = [k[1] for k in self.passives]
     self.passives = [PASSIVES[k[0]] for k in self.passives]
     for c_def, passive_template in zip(creature_passive_def,
                                        self.passives):
         c_def.update(passive_template[1])
     self.passives = [
         template[0](**c_def)
         for template, c_def in zip(self.passives, creature_passive_def)
     ]
     for passive in self.passives:
         passive.apply_to(self)
     creature_ability_def = [k[1] for k in self.abilities]
     self.abilities = [ABILITIES[k[0]] for k in self.abilities]
     for c_def, ability_template in zip(creature_ability_def,
                                        self.abilities):
         c_def.update(ability_template[1])
     self.abilities = [
         template[0](**c_def)
         for template, c_def in zip(self.abilities, creature_ability_def)
     ]
     self.maxhealth = self.health
     SimpleSprite.__init__(self, DEFS[defkey]['image_name'])
     self.subsprites = [self.health_gauge, self.shield_gauge]
Beispiel #2
0
 def __init__(self, father):
     CascadeElement.__init__(self)
     self.inventory_display = StatusDisplay(self)
     self.mob_list = []
     self.current_question_key = ''
     self.previous_question = ''
     self.current_question = None
     self.bg = SimpleSprite('menu.png')
     self.inventory = []
     self.cursor = SimpleSprite('icons/magnifyingglass.png')
     self.pc_position = GameTile(0, 0)
     self.pc_sprite = SimpleSprite('tiles/Fighter.png')
     self.map = WorldMap(0)
     self.subsprites = [
         self.bg, self.inventory_display, self.map, self.pc_sprite,
         self.cursor
     ]
     self.formation = [
         (-2, 4),
         (-1, 4.5),
         (0, 4),
         (1, 4.5),
         (2, 4),
     ]
     Interface.__init__(self,
                        father,
                        keys=[
                            ('(up|down)(left|right)?', self.move),
                            (K_ESCAPE, self.quit),
                        ])
Beispiel #3
0
    def __init__(self, father):
        CascadeElement.__init__(self)
        self.bg = SimpleSprite('helpmodal.png')
        self.bg.rect.x, self.bg.rect.y = 302, 200
        self.text = TextSprite('Items to buy. [Esc] to leave.', '#ffffff', 330,
                               250)
        self.items = []
        self.item_texts = []
        father.desactivate()
        for i in range(3):
            choice = random.choice(list(items.ITEMS.keys()))
            item_class = items.ITEMS[choice][0]
            item_args = items.ITEMS[choice][1]
            item = item_class(*item_args)
            self.items.append(item)
            self.item_texts.append(
                TextSprite(
                    "[%d]: %s - %d gold" % (i + 1, item.name, item.shop_price),
                    "#ffffff", 368, 304 + 40 * i))

        Interface.__init__(self,
                           father,
                           keys=[
                               (K_ESCAPE, self.leave),
                               ('[1-3]', self.buy),
                           ])
Beispiel #4
0
class BansheeTile(MapTile):
    def __init__(self, tile):
        super().__init__(tile, 'tiles/GreyTile.png')
        self.fight_sprite = SimpleSprite('tiles/Banshee.png')
        self.fight_sprite.rect = self.rect

    def on_step(self, world_interface):
        num_banshees = 2 + min(6, world_interface.level // 3)
        mobs = ['Banshee'] * num_banshees
        world_interface.start_combat(mobs=mobs)
        world_interface.party_gold += random.randint(
            5 + world_interface.level, 10 + world_interface.level * 4)
        world_interface.map.board[world_interface.pc_position] = MapTile(
            world_interface.pc_position)

    def display(self):
        MapTile.display(self)
        self.fight_sprite.display()
Beispiel #5
0
 def __init__(self, creature, basex, basey):
     super().__init__()
     self.basex, self.basey = basex, basey
     self.pc = creature
     self.pc.rect.x, self.pc.rect.y = basex, basey
     self.health_stat = TextSprite('', '#ffffff', basex + 38, basey + 4)
     self.inventory = [
         SimpleSprite('icons/icon-blank.png'),
         SimpleSprite('icons/icon-blank.png'),
         SimpleSprite('icons/icon-blank.png'),
     ]
     for i, sprite in enumerate(self.inventory):
         sprite.rect.x, sprite.rect.y = basex + 120 + 32 * i, basey
     for i, item in enumerate(self.pc.items):
         item.rect.x, item.rect.y = self.inventory[
             i].rect.x, self.inventory[i].rect.y
     self.subsprites = [self.pc, self.health_stat
                        ] + self.inventory + self.pc.items
Beispiel #6
0
class DemonTile(MapTile):
    def __init__(self, tile):
        super().__init__(tile, 'tiles/GreyTile.png')
        self.fight_sprite = SimpleSprite('tiles/Demon.png')
        self.fight_sprite.rect = self.rect

    def on_step(self, world_interface):
        num_demons = min(2, world_interface.level // 10)
        num_imp = min(12, random.randint(0, world_interface.level // 2))
        mobs = ['Demon'] * num_demons + ['Imp'] * num_imp
        world_interface.start_combat(mobs=mobs)
        world_interface.party_gold += random.randint(
            5 + world_interface.level, 10 + world_interface.level * 4)
        world_interface.map.board[world_interface.pc_position] = MapTile(
            world_interface.pc_position)

    def display(self):
        MapTile.display(self)
        self.fight_sprite.display()
Beispiel #7
0
class GobelinTile(MapTile):
    def __init__(self, tile):
        super().__init__(tile, 'tiles/GreyTile.png')
        self.fight_sprite = SimpleSprite('tiles/Gobelin.png')
        self.fight_sprite.rect = self.rect

    def on_step(self, world_interface):
        num_gobelins = 1 + min(6, world_interface.level // 2)
        num_trolls = min(5, world_interface.level // 3)
        mobs = ['Gobelin'] * num_gobelins + ['Troll'] * num_trolls
        world_interface.start_combat(mobs=mobs)
        world_interface.party_gold += random.randint(
            4 + world_interface.level // 2, 8 + world_interface.level * 2)
        world_interface.party_food += random.randint(40, 100)
        world_interface.map.board[world_interface.pc_position] = MapTile(
            world_interface.pc_position)

    def display(self):
        MapTile.display(self)
        self.fight_sprite.display()
Beispiel #8
0
 def __init__(self, worldinterface):
     super().__init__()
     self.worldinterface = worldinterface
     self.gold_icon = SimpleSprite('icons/gold.png')
     self.gold_icon.rect.x, self.gold_icon.rect.y = 20, 50
     self.gold_stat = TextSprite('', '#ffffff', 58, 54)
     self.food_icon = SimpleSprite('icons/apple.png')
     self.food_icon.rect.x, self.food_icon.rect.y = 92, 50
     self.food_stat = TextSprite('', '#ffffff', 130, 54)
     self.day_text = TextSprite('', '#ffffff', 20, 90)
     self.inventory = []
     self.items = []
     for i in range(10):
         self.inventory.append(SimpleSprite('icons/icon-blank.png'))
         self.inventory[i].rect.x, self.inventory[i].rect.y = 50 + (
             i % 5) * 32, 380 + (i // 5) * 32
     self.subsprites = [
         self.gold_icon, self.gold_stat, self.food_icon, self.food_stat,
         self.day_text
     ] + self.inventory
     self.teammates = []
Beispiel #9
0
class SkeletonTile(MapTile):
    def __init__(self, tile):
        super().__init__(tile, 'tiles/GreyTile.png')
        self.fight_sprite = SimpleSprite('tiles/Skeleton.png')
        self.fight_sprite.rect = self.rect

    def on_step(self, world_interface):
        num_skeletons = 2 + min(6, world_interface.level // 2)
        num_archers = min(5, world_interface.level // 3)
        num_necro = min(2, world_interface.level // 11)

        mobs = ['Skeleton'] * num_skeletons + [
            'SkeletonArcher'
        ] * num_archers + ['Necromancer'] * num_necro
        world_interface.start_combat(mobs=mobs)
        world_interface.party_gold += random.randint(
            5 + world_interface.level // 2, 10 + world_interface.level * 2)
        world_interface.map.board[world_interface.pc_position] = MapTile(
            world_interface.pc_position)

    def display(self):
        MapTile.display(self)
        self.fight_sprite.display()
Beispiel #10
0
 def __init__(self, father):
     CascadeElement.__init__(self)
     Interface.__init__(self,
                        father,
                        keys=[(K_ESCAPE, self.cancel),
                              (K_RETURN, self.cancel)])
     self.basex, self.basey = 302, 200
     self.bg = SimpleSprite('helpmodal.png')
     self.bg.rect.move_ip(self.basex, self.basey)
     self.text = TextSprite('Your party is dead. Game Over.',
                            '#ffffff',
                            330,
                            250,
                            maxlen=350)
     self.subsprites = [self.bg, self.text]
     self.display()
Beispiel #11
0
 def __init__(self, father, tavern):
     CascadeElement.__init__(self)
     self.bg = SimpleSprite('helpmodal.png')
     self.bg.rect.x, self.bg.rect.y = 262, 200
     self.text = TextSprite('Enter a word or two about your inquiry',
                            '#ffffff', 274, 250)
     self.question = TextSprite('', '#ffffff', 274, 300)
     self.word = ''
     self.tavern = tavern
     self.subsprites = [self.bg, self.text, self.question]
     Interface.__init__(self,
                        father,
                        keys=[
                            (K_ESCAPE, lambda x: self.done()),
                            ('[a-z ]', self.typing),
                            (K_BACKSPACE, self.erase),
                            (K_RETURN, self.validate),
                        ])
Beispiel #12
0
 def __init__(self, father, item):
     CascadeElement.__init__(self)
     self.item = item
     self.bg = SimpleSprite('helpmodal.png')
     self.bg.rect.x, self.bg.rect.y = 302, 200
     self.text = TextSprite(
         'Apply to adventurer with [1-5]. [Esc] to cancel.',
         '#ffffff',
         330,
         250,
         maxlen=350)
     self.stats = TextSprite(str(item), '#ffffff', 330, 220, maxlen=350)
     self.subsprites = [self.bg, self.stats, self.text]
     Interface.__init__(self,
                        father,
                        keys=[
                            (K_ESCAPE, lambda x: self.done()),
                            ('[1-5]', self.equip),
                        ])
Beispiel #13
0
 def __init__(self):
     CascadeElement.__init__(self)
     self.bg = SimpleSprite('menu.png')
     self.hello = TextSprite('Choose a save slot with keys 1-3', '#ffffff',
                             320, 280)
     self.slots = []
     for i in range(3):
         try:
             slotname = 'Day %d' % json.load(open('save%d.json' %
                                                  (i + 1)))['level']
         except FileNotFoundError:
             slotname = 'Empty'
         self.slots.append(
             TextSprite('[%d] Slot - %s' % (i + 1, slotname), '#ffffff',
                        320, 300 + 20 * i))
     self.subsprites = [self.bg, self.hello] + self.slots
     Interface.__init__(self,
                        None,
                        keys=[
                            (K_ESCAPE, lambda x: self.done()),
                            ('[1-3]', self.start),
                        ])
Beispiel #14
0
 def display(self):
     if self.combat:
         CascadeElement.display(self)
     SimpleSprite.display(self)
Beispiel #15
0
 def __init__(self, tile):
     super().__init__(tile, 'tiles/GreyTile.png')
     self.fight_sprite = SimpleSprite('tiles/Demon.png')
     self.fight_sprite.rect = self.rect