1 # This file is part of Realism, which is Copyright FunnyMan3595 (Charlie Nolan)
2 # and licensed under the GNU GPL v3. For more details, see LICENSE in the main
5 # WARNING: All mod formats are under heavy development. They may change at any
6 # time, breaking old mods. For this reason, we DO NOT RECOMMEND making mods
9 # This file defines the basic map tiles used in the game. These tiles cannot
10 # be used directly in a map, but they are used by the standard map tiles. For
11 # instance, a standard "safe" tile is the combination of the "no_encounters"
12 # and "regen" basic tiles.
14 # This file has the same format as <module>/basic_tiles.py.
15 # For a complete guide to modding, see MODDING, in the Realism main directory.
17 # Like all the .py files, this is Python code. Most mod makers should be able
18 # to understand and adapt it, but knowledge of Python will help, and may allow
19 # you to do neat tricks.
21 '''Basic tiles are the fundamental pieces that you put together to create normal tiles. Each one handles one specific function, like random encounters or the regen when you take a step.'''
23 from engine
.tile
import *
24 from engine
.shop
import make_shop
26 class TileException(Exception):
30 '''The base tile for all ordinary empty squares.'''
34 '''Dummy basic tile for anything that has no effect.'''
35 no_regen
= no_encounters
= no_op
38 '''Every time the player steps on this tile, each party member gets healed slightly.'''
39 def go_to(self
, teleported
= False):
40 went
= super(regen
, self
).go_to(teleported
)
45 class random_encounters(empty
):
46 '''Every time the player steps on this tile, there is a chance he may be sent into a random encounter.'''
47 def go_to(self
, teleported
= False):
48 went
= super(random_encounters
, self
).go_to(teleported
)
54 '''A door. Walking into a door that's closed but unlocked will open it, but it takes a second attempt to move to this tile.'''
55 save
= ("open","locked")
59 def __init__(self
, map_pos
, *args
):
60 super(door
, self
).__init
__(map_pos
)
61 def go_to(self
, teleported
= False):
65 self
.type = "door_open"
67 return super(door
, self
).go_to(teleported
)
69 class locked_door(door
):
70 '''A door that starts locked.'''
73 class warp_tile(empty
):
74 '''A tile that attempts to warp the player to a new location on the map.'''
75 def __init__(self
, map_pos
, target_row
, target_col
, *args
):
77 super(warp_tile
, self
).__init
__(map_pos
)
79 # If we got ('s', 's'), the start square of the map, we preserve it.
80 # Otherwise, we process row and col into integers.
81 if target_row
== target_col
== 's':
84 row
= self
.argument("target row", target_row
, int)
85 col
= self
.argument("target col", target_col
, int)
87 # Save the target position.
88 self
.target_pos
= (row
, col
)
90 class map_tile(warp_tile
):
91 '''A tile that attempts to warp the player to a new map. If no location is specified, the player is warped to the map's start location. Usually, only teleporters will want to omit the location.'''
92 def __init__(self
, map_pos
, target_map
, target_row
= None, target_col
= None, *args
):
93 # If we got both row and col, we just pass those into warp_tile.
94 # If we got neither, we use ('s', 's'), the start square of the map.
95 if target_row
!= None and target_col
== None:
96 raise MapException("target row without target col in tile map_tile on map", map_pos
[0].name
)
97 elif target_row
== None:
98 (target_row
, target_col
) = ('s', 's')
101 warp_tile
.__init
__(self
, map_pos
, target_row
, target_col
)
103 # Find and store the target map.
104 self
.target_map
= self
.argument("target map", target_map
, a_map
)
106 class tutorial(empty
):
107 '''The first time the player steps on a tutorial tile, they are given a tutorial, which must be defined as tutorial(self) on the final tile.'''
110 def __init__(self
, map_pos
, main_game
= False, *args
):
111 super(tutorial
, self
).__init
__(map_pos
)
112 self
.main_game
= self
.argument("main game", main_game
, bool)
115 # TODO: Consider changing to raise.
116 print TileException("No tutorial defined for %s." % self
.__class
__.__name
__)
118 def go_to(self
, teleported
= False):
119 went
= super(tutorial
, self
).go_to(teleported
)
120 if went
and not self
.seen
:
126 '''Walking into a shop tile causes the player to enter a shop, regardless of whether he moves onto the tile.'''
132 def __init__(self
, map_pos
, level
=None, *args
):
133 super(shop
, self
).__init
__(map_pos
, *args
)
136 self
.level
= self
.argument("shop level", level
, int)
138 self
.shop
= make_shop(self
.level
, **self
.shop_args
)
140 def go_to(self
, teleported
= False):
141 game
.ui
.shop_mode(self
.shop
)
142 return super(shop
, self
).go_to(teleported
)
144 class climb_tile(tile
):
145 '''A climb tile is simply a tile with some element of height to it. A level 1 climb tile could be as little as a twig or bit of trash in the way. If the party's climb level is equal to or greater than the climb tile's level, they can pass.'''
148 def __init__(self
, map_pos
, level
= None, *args
):
149 super(climb_tile
, self
).__init
__(map_pos
, *args
)
152 self
.level
= self
.argument("climb level", level
, int)
154 def go_to(self
, teleported
= False):
155 if game
.party
.climb_level
>= self
.level
:
156 return super(climb_tile
, self
).go_to(teleported
)