all repos — Legends-RPG @ 3033ec723dbf8059aad0a4e2b087d5ed2fca6c5f

A fantasy mini-RPG built with Python and Pygame.

data/states/town/town.py (view raw)

 1"""This is town state.  Most of its functionality is inherited from
 2the level_state.py module.  Most of the level data is contained in
 3the tilemap .txt files in this state's directory.  Essentially the
 4only purpose of town.py is to assign dialogue to each sprite
 5"""
 6
 7from .. import level_state
 8from ... import constants as c
 9
10class Town(level_state.LevelState):
11    def __init__(self):
12        super(Town, self).__init__()
13        self.name = c.TOWN
14        self.map_width = 25
15        self.map_height = 50
16
17    def set_sprite_dialogue(self):
18        """Sets unique dialogue for each sprite"""
19        for sprite in self.sprites:
20            if sprite.location == [9, 46]:
21                sprite.dialogue = ['Welcome to our town, traveller!',
22                                   'Our King protects us against the evil forces of the outside world.',
23                                   'As long as we never leave, we have nothing to fear!']
24            elif sprite.location == [15, 41]:
25                sprite.dialogue = ['You seem tired from your travels.',
26                                   'Why not rest at our Inn and stay awhile?']
27                sprite.begin_auto_resting()
28            elif sprite.location == [13, 13]:
29                sprite.dialogue = ['Be careful. There are monsters surrounding our town.',
30                                   'Make sure to equip sufficient armour and weapons.',
31                                   'Spells and potions are useful too.']
32            elif sprite.location == [10, 13]:
33                sprite.dialogue = ['I have heard rumours that the King has lost something...',
34                                   'Perhaps you should pay him a visit.']
35            elif sprite.location == [10, 7]:
36                sprite.dialogue = ['Welcome to the castle, citizen.']
37            elif sprite.location == [13, 7]:
38                sprite.dialogue = ['Only those given special permission by the King can leave this town.',
39                                   'It is for our own good, as few could survive in the outside world.']
40            elif sprite.location == [18, 27]:
41                sprite.dialogue = ["Don't be frightened. I'm a friendly Demon.",
42                                   "My brothers and sisters, however, are not so nice.",
43                                   "Be careful not to run into them."]
44