all repos — Legends-RPG @ d888c95f9758b73561d9d31039006d9332f0329b

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
 8
 9class Town(level_state.LevelState):
10    def __init__(self, name, width, height):
11        super(Town, self).__init__(name, width, height)
12
13    def set_sprite_dialogue(self):
14        """Sets unique dialogue for each sprite"""
15        for sprite in self.level_sprites:
16            if sprite.location == [9, 46]:
17                sprite.dialogue = ['Welcome to our town, Mr. Traveller!',
18                                   'The King is loved by all!',
19                                   'You should go visit him in his castle.']
20            elif sprite.location == [15, 41]:
21                sprite.dialogue = ['You seem tired, why not rest at our Inn?']
22                sprite.begin_auto_resting()
23            elif sprite.location == [13, 13]:
24                sprite.dialogue = ['Be careful. There are monsters surrounding our town.',
25                                   'Make sure to equip sufficient armour and weapons.',
26                                   'Spells and potions are useful too.']
27            elif sprite.location == [10, 13]:
28                sprite.dialogue = ['I have heard rumours that the King has lost something...',
29                                   'Perhaps you should pay him a visit.']
30            elif sprite.location == [10, 7]:
31                sprite.dialogue = ['Welcome to the castle, citizen.']
32            elif sprite.location == [13, 7]:
33                sprite.dialogue = ['Move along.']
34