all repos — Legends-RPG @ cc5415b4ae455bd90a3ba7e4e0e42dc9b3e9811d

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, Mr. Traveller!',
22                                   'The King is loved by all!',
23                                   'You should go visit him in his castle.']
24            elif sprite.location == [15, 41]:
25                sprite.dialogue = ['You seem tired, why not rest at our Inn?']
26                sprite.begin_auto_resting()
27            elif sprite.location == [13, 13]:
28                sprite.dialogue = ['Be careful. There are monsters surrounding our town.',
29                                   'Make sure to equip sufficient armour and weapons.',
30                                   'Spells and potions are useful too.']
31            elif sprite.location == [10, 13]:
32                sprite.dialogue = ['I have heard rumours that the King has lost something...',
33                                   'Perhaps you should pay him a visit.']
34            elif sprite.location == [10, 7]:
35                sprite.dialogue = ['Welcome to the castle, citizen.']
36            elif sprite.location == [13, 7]:
37                sprite.dialogue = ['Move along.']
38            elif sprite.location == [18, 27]:
39                sprite.dialogue = ["Don't be frightened. I'm a friendly Demon.",
40                                   "My brothers and sisters, however, are not so nice.",
41                                   "Be careful not to run into them."]
42