empi 0.17 → 0.22.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,103 +0,0 @@
1
- class Cursor
2
- attr_accessor :x, :y, :freeroam
3
-
4
- def initialize(x, y, map, infopane)
5
- dir_path = File.dirname(__FILE__)
6
-
7
- @x = x
8
- @y = y
9
- @map = map
10
- @infopane = infopane
11
-
12
- @image = Gosu::Image.new(dir_path + '/media/cursor.png')
13
- @freeroam = false
14
- end
15
-
16
- def update(key)
17
- case key
18
- # Cardinal directions
19
- when Gosu::KbLeft, Gosu::KbA then
20
- @x -= 1 unless @x <= 0
21
- when Gosu::KbRight, Gosu::KbD then
22
- @x += 1 unless @x >= MAPX
23
- when Gosu::KbUp, Gosu::KbW then
24
- @y -= 1 unless @y <= 0
25
- when Gosu::KbDown, Gosu::KbX then
26
- @y += 1 unless @y >= MAPY
27
-
28
- # Intercardinal directions
29
- when Gosu::KbQ then
30
- unless @x <= 0 || @y <= 0
31
- @x -= 1
32
- @y -= 1
33
- end
34
- when Gosu::KbE then
35
- unless @x >= MAPX || @y <= 0
36
- @x += 1
37
- @y -= 1
38
- end
39
- when Gosu::KbZ then
40
- unless @x <= 0 || @y >= MAPY
41
- @x -= 1
42
- @y += 1
43
- end
44
- when Gosu::KbC then
45
- unless @x >= MAPX || @y >= MAPY
46
- @x += 1
47
- @y += 1
48
- end
49
-
50
- # Functions
51
- when Gosu::KbS then
52
- uu = @map.get_unit(@x, @y)
53
- if uu then uu.set_function(FUNCSENTRY) end
54
- when Gosu::KbB then
55
- uu = @map.get_unit(@x, @y)
56
- if uu then uu.set_function(FUNCBUILD) end
57
- when Gosu::KbN then
58
- uu = @map.get_unit(@x, @y)
59
- if uu then uu.set_function(FUNCNONE) end
60
-
61
- when Gosu::KbReturn then
62
- info
63
- end
64
- end
65
-
66
- def draw
67
- @image.draw(@x * TILESIZE, (@y + 1) * TILESIZE, ZCURSOR)
68
- end
69
-
70
- # Move to given coordinates
71
- def warp(x, y)
72
- @x = x
73
- @y = y
74
- end
75
-
76
- # Switch between being attached to unit and being able to freeroam
77
- def switch_freeroam
78
- if freeroam == true
79
- @infopane.text = 'freeroam disabled'
80
- puts 'freeroam disabled'
81
- else
82
- @infopane.text = 'freeroam enabled'
83
- puts 'freeroam enabled'
84
- end
85
- @freeroam = !@freeroam
86
- end
87
-
88
- # Find some info about units on the current tile
89
- def info
90
- uu = @map.get_unit(@x, @y)
91
- if uu
92
- @infopane.text = uu.info
93
- puts uu.info
94
-
95
- if uu.is_transporting?
96
- uu.cargo.each { |uu| puts '- cargo: ' + uu.info }
97
- end
98
- else
99
- @infopane.text = ''
100
- puts 'nothing here'
101
- end
102
- end
103
- end
Binary file
@@ -1,219 +0,0 @@
1
- /-- /// /-/ -/-
2
- /-- ||| /-/ |
3
- /-- ||| | -/-
4
-
5
- Empi: Ruby Edition
6
- ====================
7
-
8
- v17 dev
9
- =========
10
- - selected map: m02
11
- - terrain stuff separated to Tile class
12
- ! units are still stored via Map class instead of Tile one
13
- ! units are still accessed via Window class instead of Cursor one
14
- - removed debug printout from Unit class
15
- - moving transports don't leave their cargo behind
16
- - capturing done only by armies
17
- fixed: all units can capture towns (armies visiting towns are left allowed for now)
18
- - only towns can be captured, other units do battle
19
- fixed: battling units capture instead of damaging
20
- ! capturing town with units leaves those enemy units inside
21
- ! damaged units are destroyed
22
- - printouts tweaked
23
- fixed: transported units show only info of their transport instead when selected
24
- ! transported units show in infopane info of their transport instead when selected
25
- ! destroyed transport ships don't give points for their lost cargo
26
-
27
- file changes
28
- --------------
29
- empi.rb
30
- cursor prints out info() even for not moved units
31
- (say, when friend unit without avaiable cargo capacity was on the destination tile)
32
- added PROMPT to responding printouts
33
-
34
- cursor.rb
35
- info() shows info of transported units too
36
-
37
- map.rb
38
- TILE constants moved to tile.rb
39
- initialize() sets tile and leaves processing of loaded symbol to it
40
- tile() returns object of tile instead directly its terrain type
41
- +all_tiles - Return all tiles
42
- draw_tiles
43
-
44
- unit.rb
45
- removed debug printout used for checking of units leaving towns
46
- added PROMPT to responding printouts
47
- check_movement() makes sure cargo is moved too
48
- check_movement() checks if moved unit has enough move points
49
- check_movement() print outs are more detailed
50
- tile_check() doesn't check terrain type for transported units
51
- info() print outs also max cargo capacity
52
- fixed comparing of functions in set_function()
53
- +can_capture?
54
- +can_be_captured?
55
- can_move() renamed to can_move?()
56
- reset_moves() renamed to reset_moves!()
57
-
58
- army.rb
59
- can capture
60
-
61
- town.rb
62
- can be captured
63
-
64
- save/m02.esf
65
- +two ships, one for each faction
66
-
67
- tile.rb
68
-
69
-
70
- v16 dev
71
- =========
72
- - units on sentry duty say so when functioning
73
- - neutral units can't have functions
74
- - links to media and save files use full path
75
- - towns build armies
76
- fixed: no building of units
77
- ! hardcoded unit type to be built
78
- - units can transport other units
79
- - newly built units are stored in town instead of map
80
- fixes: new units are saved in map instead of the towns that built them
81
- ! transported units are not drawn
82
- ! transported units show only info of their transport instead when selected
83
- ! all units can capture and visit towns
84
-
85
- file changes
86
- --------------
87
- map.rb
88
- initialize() uses full paths to files
89
- all_units renamed to all_map_units() - Return only units directly on map
90
- +all_transported_units() - Return only units transported by other units
91
- +all_units() - Return both map units and transported units
92
- draw_units() draws only map units
93
-
94
- unit.rb
95
- +@cargo, @cargo_max
96
- +can_transport?() - Unit is able to both transport other units and currently has some space left
97
- set_function() checks for @faction == 0
98
- checking of movement separated from update()
99
- +check_movement() - Processes move of unit and takes care of its (un)loading or attack
100
- capture() makes newly captured towns start building
101
-
102
- town.rb
103
- initialize() uses full path to file
104
- +parts_built
105
- +@cargo_max set to 10
106
-
107
- army.rb
108
- initialize() uses full path to file
109
-
110
- ship.rb
111
- initialize() uses full path to file
112
- +@cargo_max set to 3
113
-
114
- unitFunction.rb
115
- +FUNCBUILD case in func!()
116
- FUNCSENTRY case in func!() sets "ret" even when unit keeps sentrying
117
-
118
-
119
- v15 dev
120
- =========
121
- - selected map: m03
122
- - units referenced only from map
123
- fixed: no destruction of units
124
- - loading of units from file
125
- fixed: no loading
126
- - checks of loaded terrain tiles and units
127
- - map stored as [row, column], not [xx, yy]
128
-
129
- file changes
130
- --------------
131
- empi.rb
132
- -scenario_units() - Return list of units for given scenario
133
-
134
- map.rb
135
- load_map() now loads units too
136
- load_head() now returns number of units to load too
137
- load_map(), tile(), get_unit(), set_unit() use rr and cc instead of xx and yy
138
- +load_unit() - Load one unit from given line
139
- +draw_units() - Draw all units
140
-
141
- save/m01.esf
142
- 8 units from old empi.scenario_units()
143
-
144
- save/m02.esf
145
- 10 units similar to old empi.scenario_units()
146
-
147
- save/m03.esf
148
-
149
-
150
- v14 dev
151
- =========
152
- - loading of terrain tiles from file
153
- fixed: hardcoded starting scenario
154
- ! hardcoded save file name
155
- ! hardcoded map size
156
-
157
- file changes
158
- --------------
159
- empi.rb
160
- TILE constants moved to map.rb
161
-
162
- map.rb
163
- -scenario_tiles() - Return map tile for given scenario
164
- +load_map() - Load map from file (for now only terrain tiles)
165
- +load_head() - Load head row of file
166
-
167
- unit.rb
168
- removed generic unit image
169
-
170
- save/m01.esf
171
- save/m02.esf
172
-
173
-
174
- older versions
175
- ================
176
- - towns and armies
177
- - functions none and sentry
178
- - armor and movement points
179
- - movement of units
180
- - rudimentary terrain checking after move
181
- - capturing of units
182
- - turn and score counting
183
- - commmand line and screen text output
184
- - next avaiable unit / freeroam cursor
185
-
186
- current state
187
- ===============
188
- old wishlist
189
- ! no panning of map
190
- !x no destruction of units
191
- !x no building of units
192
- ! no victory conditions
193
- !x battling units capture instead of damaging
194
- ! attacker always wins
195
- ! player playing both factions at once
196
- !x hardcoded starting scenario
197
- ! no fog of war
198
- ! no saving
199
- !x no loading
200
- ! no title screen
201
- ! no highscore screen
202
- ! no settings
203
- ! no sound, no music
204
-
205
- new problems
206
- ! hardcoded save file name
207
- ! hardcoded map size
208
- ! hardcoded unit type to be built
209
- ! transported units are not drawn
210
- !x transported units show only info of their transport instead when selected
211
- !x all units can capture and visit towns
212
- ! units are still stored via Map class instead of Tile one
213
- ! units are still accessed via Window class instead of Cursor one
214
- ! damaged units are destroyed
215
- ! transported units show in infopane info of their transport instead when selected
216
- ! capturing town with units leaves those enemy units inside
217
-
218
- (! thing to fix, !x fixed thing)
219
-
@@ -1,28 +0,0 @@
1
- require_relative './unit'
2
-
3
- class Town < Unit
4
- attr_accessor :parts_built
5
-
6
- def initialize(x, y, faction, map, infopane)
7
- super
8
- dir_path = File.dirname(__FILE__)
9
- @image = Gosu::Image.new(dir_path + '/media/town.png')
10
-
11
- @name = 'town'
12
- @value = 20
13
- @armor_left = @armor_max = 1
14
- @moves_max = 0
15
-
16
- @parts_built = 0
17
- @cargo_max = 10
18
- set_function(FUNCBUILD)
19
- end
20
-
21
- def can_build?
22
- true
23
- end
24
-
25
- def can_be_captured?
26
- true
27
- end
28
- end
@@ -1,47 +0,0 @@
1
- PARTS = 3
2
-
3
- class UnitFunction
4
- attr_accessor :func
5
-
6
- def initialize(function = FUNCNONE)
7
- @func = function
8
- end
9
-
10
- def func!(xx, yy, map, infopane)
11
- ret = " didn't actually do anything (ERROR)"
12
-
13
- unit = map.get_unit(xx, yy)
14
- if unit == nil
15
- abort("unitFunction.func!(): Functioning unit not found at given coordinates (#{xx}-#{yy})")
16
- end
17
-
18
- case @func
19
- # Build given unit
20
- when FUNCBUILD
21
- if(unit.parts_built >= PARTS) # just == should be enough
22
- ret = " completed building of army"
23
- unit.parts_built = 0
24
- Army.new(unit.x, unit.y, unit.faction, map, infopane) # TODO allow setting what to build
25
- else
26
- ret = " built next part of army"
27
- unit.parts_built = unit.parts_built + 1
28
- end
29
-
30
- # Wake up when enemies are nearby
31
- when FUNCSENTRY
32
- units_around = map.all_units.select { |uu|
33
- (uu.x - xx).abs <= 1 &&
34
- (uu.y - yy).abs <= 1 &&
35
- uu.faction != unit.faction
36
- }
37
- if units_around.size > 0
38
- ret = " woke up"
39
- @func = FUNCNONE
40
- else
41
- ret = " was on sentry duty"
42
- end
43
- end
44
-
45
- ret
46
- end
47
- end