empi 0.18 → 0.19
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/cursor.rb +5 -22
- data/lib/docu/info.txt +97 -7
- data/lib/empi.rb +2 -2
- data/lib/infopane.rb +2 -2
- data/lib/map.rb +1 -1
- data/lib/save/m02-err.esf +26 -0
- data/lib/tile.rb +8 -8
- data/lib/town.rb +52 -3
- data/lib/unit.rb +78 -40
- data/lib/unitFunction.rb +27 -20
- metadata +3 -4
- data/lib/docu/Empi v14.png +0 -0
- data/lib/docu/Empi v18 - printouts.png +0 -0
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 2d95cf3fd4165a2f088ce364e4a5e1a1511ee395a2f0f9a697528a8860d1b69d
|
|
4
|
+
data.tar.gz: b1e56a884ed3f3db2909379e73ddd9d5079ecab4c7e80e92524d543e0ef0800b
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: bfb3d1398928e814bba042ac3017fb051df0073cead2fa24119f7c53406d3767a20c39e44de8631b3c17ebd53e0a9b7ea5ec7c9382a974b30fa2e27b16720755
|
|
7
|
+
data.tar.gz: e4a85873b8bd9127b051ea262aadca0c251e3cfabbbea3a09bc211f067b8590fefb241b1236e6ab59855223fef4f44a8c7dfc094cb105b70c845ccc8d23de42f
|
data/lib/cursor.rb
CHANGED
|
@@ -8,7 +8,7 @@ class Cursor
|
|
|
8
8
|
@y = y
|
|
9
9
|
@map = map
|
|
10
10
|
@infopane = infopane
|
|
11
|
-
|
|
11
|
+
|
|
12
12
|
@image = Gosu::Image.new(dir_path + '/media/cursor.png')
|
|
13
13
|
@freeroam = false
|
|
14
14
|
|
|
@@ -95,35 +95,19 @@ class Cursor
|
|
|
95
95
|
def set_function_to_unit(func)
|
|
96
96
|
if freeroam
|
|
97
97
|
uu = @map.get_unit(@x, @y)
|
|
98
|
-
else
|
|
99
|
-
# If in locked mode
|
|
98
|
+
else # in locked mode
|
|
100
99
|
if !@unit
|
|
101
100
|
abort("cursor.set_function_to_unit(): Cursor is in locked mode but there is no unit it is locked to (at #{@x} - #{@y})")
|
|
102
101
|
end
|
|
103
102
|
uu = @unit
|
|
104
103
|
end
|
|
105
|
-
|
|
106
|
-
uu.set_function(func) unless !uu
|
|
104
|
+
|
|
105
|
+
uu.set_function!(func) unless !uu
|
|
107
106
|
end
|
|
108
107
|
|
|
109
108
|
# Find next unit to target with cursor
|
|
110
109
|
def to_next_unit!
|
|
111
|
-
if @unit
|
|
112
|
-
puts 'current unit is there'
|
|
113
|
-
else
|
|
114
|
-
puts 'nothing hereeee'
|
|
115
|
-
end
|
|
116
|
-
|
|
117
|
-
if @unit && @unit.can_move?
|
|
118
|
-
puts 'current unit can move'
|
|
119
|
-
end
|
|
120
|
-
|
|
121
|
-
if @unit && @unit.function == FUNCNONE
|
|
122
|
-
puts 'current unit has no function set'
|
|
123
|
-
end
|
|
124
|
-
|
|
125
110
|
unless @unit && @unit.can_move? && @unit.function == FUNCNONE # unless the current one is still movable
|
|
126
|
-
puts 'searching'
|
|
127
111
|
movable_units = @map.all_units.select { |uu| uu.can_move? && uu.function == FUNCNONE}
|
|
128
112
|
|
|
129
113
|
# If there are no more movable units without function, switch to freeroam mode
|
|
@@ -136,8 +120,7 @@ puts 'searching'
|
|
|
136
120
|
|
|
137
121
|
@unit = movable_units[0] # newly selected one
|
|
138
122
|
end
|
|
139
|
-
|
|
140
|
-
|
|
123
|
+
|
|
141
124
|
warp_to!(@unit) # stay at old or go to new
|
|
142
125
|
info
|
|
143
126
|
end
|
data/lib/docu/info.txt
CHANGED
|
@@ -6,9 +6,87 @@ Empi: Ruby Edition
|
|
|
6
6
|
====================
|
|
7
7
|
CC-BY-SA 3.0, Detros
|
|
8
8
|
http://www.bay12forums.com/smf/index.php?topic=157538
|
|
9
|
+
https://rubygems.org/gems/empi
|
|
9
10
|
rasunadon@seznam.cz
|
|
10
11
|
|
|
11
12
|
|
|
13
|
+
v19 dev
|
|
14
|
+
=========
|
|
15
|
+
- units which can't build will not only protest against such function but also not set it
|
|
16
|
+
fixed: units which can't build can still have function set to build
|
|
17
|
+
- added link to the gem page to the header of this Info file
|
|
18
|
+
- defenders of capturable units need to be dealt with before it can be captured
|
|
19
|
+
fixed: capturing town with units leaves those enemy units inside
|
|
20
|
+
- destroyed transporters first destroy their cargo
|
|
21
|
+
fixed: destroyed transport ships don't give points for their lost cargo
|
|
22
|
+
- apparently fixed in v0.18 with storing of last unit in cursor
|
|
23
|
+
fixed: transported units show in infopane info of their transport instead when selected
|
|
24
|
+
- cargo part of info shown even for empty transporters
|
|
25
|
+
- UnitFunction stores its unit
|
|
26
|
+
fixed: transported units don't function properly, their transports secretly function instead of them
|
|
27
|
+
- preliminary work done on setting build projects
|
|
28
|
+
- towns say what their project and its progress are
|
|
29
|
+
- parts are first build and then checked so building process takes one less turn now
|
|
30
|
+
- captured towns have their build process reset
|
|
31
|
+
- reworded function parts of unit info
|
|
32
|
+
|
|
33
|
+
newly found issues
|
|
34
|
+
--------------------
|
|
35
|
+
! passing a Window to Image.from_text has been deprecated since Gosu 0.9
|
|
36
|
+
! Fontconfig error: failed reading config file
|
|
37
|
+
! no way to list cargo in loaded maps
|
|
38
|
+
! units loaded from tile can spawn on unsuitable terrain
|
|
39
|
+
|
|
40
|
+
file changes
|
|
41
|
+
--------------
|
|
42
|
+
army.rb
|
|
43
|
+
PARTS_TO_BE_BUILT
|
|
44
|
+
|
|
45
|
+
cursor.rb
|
|
46
|
+
removed debug printouts from to_next_unit!()
|
|
47
|
+
|
|
48
|
+
empi.rb
|
|
49
|
+
added Build function to help
|
|
50
|
+
|
|
51
|
+
ship
|
|
52
|
+
PARTS_TO_BE_BUILT
|
|
53
|
+
|
|
54
|
+
unit.rb
|
|
55
|
+
set_function(func) properly returns if it tries to set build function for unit which can't build
|
|
56
|
+
capture(by_whom) renamed to capture!(by_whom)
|
|
57
|
+
destroy(by_whom) renamed to destroy!(by_whom)
|
|
58
|
+
tile_check() renamed to is_terrain_suitable?()
|
|
59
|
+
+engage!(by_whom) - Process engagement targeted at this unit
|
|
60
|
+
+attack!(by_whom) - Process attack targeted at this unit
|
|
61
|
+
capture!(by_whom) checks if unit can be captured and if capturing faction is different from current one
|
|
62
|
+
destroy!(by_whom) removes from cargo of its transporter when transported
|
|
63
|
+
cargo part shortened in info()
|
|
64
|
+
positive cargo_max used instead of cargo size to show cargo part of info
|
|
65
|
+
simplified calling of UnitFunction in function!
|
|
66
|
+
set_function(func) renamed to set_function!(func)
|
|
67
|
+
PARTS_TO_BE_BUILT
|
|
68
|
+
moved build part of capture! to Town
|
|
69
|
+
moved build part of set_function! to Town
|
|
70
|
+
+can_be_built?
|
|
71
|
+
|
|
72
|
+
unitFunction.rb
|
|
73
|
+
removed PARTS_NEEDED
|
|
74
|
+
@unit
|
|
75
|
+
states project and its state when building in func!()
|
|
76
|
+
loading needed unit parameters from its stored unit in func!()
|
|
77
|
+
+info() - Set function part of long info string of unit
|
|
78
|
+
|
|
79
|
+
town.rb
|
|
80
|
+
@parts_needed
|
|
81
|
+
@project
|
|
82
|
+
+build_info - Tell the state of current build project
|
|
83
|
+
+capture!(by_whom) - Process capture targeted at this town and reset build process
|
|
84
|
+
+set_function(func) - Set desired function and possibly also project
|
|
85
|
+
+set_project! - Set desired project
|
|
86
|
+
|
|
87
|
+
save/m02-err.esf
|
|
88
|
+
copy of m02 with two extra units on unsuitable terrain
|
|
89
|
+
|
|
12
90
|
v18 dev
|
|
13
91
|
=========
|
|
14
92
|
- help is now listing all keys
|
|
@@ -26,14 +104,19 @@ v18 dev
|
|
|
26
104
|
- function setting of units separated to its own method
|
|
27
105
|
- autodisabling of freeroam mode on each end of turn moved to the start of next turn
|
|
28
106
|
|
|
107
|
+
newly found issues
|
|
108
|
+
--------------------
|
|
29
109
|
! help should be shown after each load of new map
|
|
30
110
|
! transported units can't get commands from freeroaming cursor
|
|
31
111
|
! transported units don't function properly, their transports secretly function instead of them
|
|
32
112
|
! unit info shown twice at the start of the first turn
|
|
33
113
|
! units which can't build can still have function set to build (though they do protest)
|
|
34
114
|
|
|
115
|
+
file changes
|
|
116
|
+
--------------
|
|
35
117
|
empi.rb
|
|
36
118
|
help shown at the start of game
|
|
119
|
+
added End turn and End game keys to help()
|
|
37
120
|
"End of turn" marker
|
|
38
121
|
removed calling of @map.draw_units
|
|
39
122
|
removed search for next movable unit
|
|
@@ -61,6 +144,8 @@ tile.rb
|
|
|
61
144
|
infopane.rb
|
|
62
145
|
removed one space from score output
|
|
63
146
|
|
|
147
|
+
docu/Empi v18.png
|
|
148
|
+
docu/Empi v18 - printouts.png
|
|
64
149
|
|
|
65
150
|
v17 dev
|
|
66
151
|
=========
|
|
@@ -105,7 +190,7 @@ unit.rb
|
|
|
105
190
|
check_movement() checks if moved unit has enough move points
|
|
106
191
|
check_movement() print outs are more detailed
|
|
107
192
|
tile_check() doesn't check terrain type for transported units
|
|
108
|
-
info()
|
|
193
|
+
info() prints out also max cargo capacity
|
|
109
194
|
fixed comparing of functions in set_function()
|
|
110
195
|
+can_capture?
|
|
111
196
|
+can_be_captured?
|
|
@@ -266,17 +351,22 @@ new problems
|
|
|
266
351
|
! hardcoded unit type to be built
|
|
267
352
|
! transported units are never drawn
|
|
268
353
|
!x transported units show only info of their transport instead when selected
|
|
269
|
-
!x all units can capture
|
|
354
|
+
!x all units can capture towns
|
|
355
|
+
!x all units can visit towns
|
|
270
356
|
!x units are still stored via Map class instead of Tile one
|
|
271
357
|
!x units are still accessed via Window class instead of Cursor one
|
|
358
|
+
!x capturing town with units leaves those enemy units inside
|
|
272
359
|
! damaged units are destroyed
|
|
273
|
-
! transported units show in infopane info of their transport instead when selected
|
|
274
|
-
!
|
|
360
|
+
!x transported units show in infopane info of their transport instead when selected
|
|
361
|
+
!x destroyed transport ships don't give points for their lost cargo
|
|
275
362
|
! help should be shown after each load of new map
|
|
276
363
|
! transported units can't get commands from freeroaming cursor
|
|
277
|
-
! transported units don't function properly, their transports secretly function instead of them
|
|
364
|
+
!x transported units don't function properly, their transports secretly function instead of them
|
|
278
365
|
! unit info shown twice at the start of the first turn
|
|
279
|
-
! units which can't build can still have function set to build
|
|
366
|
+
!x units which can't build can still have function set to build
|
|
367
|
+
! passing a Window to Image.from_text has been deprecated since Gosu 0.9
|
|
368
|
+
! Fontconfig error: failed reading config file
|
|
369
|
+
! no way to list cargo in loaded maps
|
|
370
|
+
! units loaded from tile can spawn on unsuitable terrain
|
|
280
371
|
|
|
281
372
|
(! thing to fix, !x fixed thing)
|
|
282
|
-
|
data/lib/empi.rb
CHANGED
|
@@ -36,7 +36,7 @@ class GameWindow < Gosu::Window
|
|
|
36
36
|
height = (MAPY + 2) * TILESIZE, \
|
|
37
37
|
fullscreen = false)
|
|
38
38
|
super
|
|
39
|
-
self.caption = 'Empi: Ruby Edition 0.
|
|
39
|
+
self.caption = 'Empi: Ruby Edition 0.19 dev'
|
|
40
40
|
|
|
41
41
|
@infopane = Infopane.new
|
|
42
42
|
@map = Map.new(@infopane)
|
|
@@ -102,7 +102,7 @@ class GameWindow < Gosu::Window
|
|
|
102
102
|
puts "-----------\n" \
|
|
103
103
|
"h: help, Esc: end game, Enter: info, j: switch freeroam\n" \
|
|
104
104
|
"QWEADZXC or arrow keys: movement, .: end turn\n" \
|
|
105
|
-
"functions: s sentry, n none\n" \
|
|
105
|
+
"functions: s sentry, b build, n none\n" \
|
|
106
106
|
"-----------\n"
|
|
107
107
|
end
|
|
108
108
|
end
|
data/lib/infopane.rb
CHANGED
data/lib/map.rb
CHANGED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
mission02 11x11 14
|
|
2
|
+
###########
|
|
3
|
+
#..###..###
|
|
4
|
+
#....#...##
|
|
5
|
+
##...#....#
|
|
6
|
+
##....#...#
|
|
7
|
+
####...####
|
|
8
|
+
#...#....##
|
|
9
|
+
#....#....#
|
|
10
|
+
##...#....#
|
|
11
|
+
###..##..##
|
|
12
|
+
###########
|
|
13
|
+
T 0 1-3
|
|
14
|
+
T 0 3-1
|
|
15
|
+
T 0 6-9
|
|
16
|
+
T 0 9-6
|
|
17
|
+
T 1 8-1
|
|
18
|
+
T 1 9-2
|
|
19
|
+
A 1 10-0
|
|
20
|
+
S 1 8-2
|
|
21
|
+
T 2 1-8
|
|
22
|
+
T 2 2-9
|
|
23
|
+
A 2 0-10
|
|
24
|
+
S 2 2-8
|
|
25
|
+
S 2 0-0
|
|
26
|
+
A 2 1-1
|
data/lib/tile.rb
CHANGED
|
@@ -15,14 +15,14 @@ class Tile
|
|
|
15
15
|
@infopane = infopane
|
|
16
16
|
|
|
17
17
|
case(loaded_symbol)
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
18
|
+
when SYMBOL_SEA then
|
|
19
|
+
@terrain = TILE_SEA
|
|
20
|
+
@image = Gosu::Image.new(dir_path + '/media/sea.png')
|
|
21
|
+
when SYMBOL_GROUND then
|
|
22
|
+
@terrain = TILE_GROUND
|
|
23
|
+
@image = Gosu::Image.new(dir_path + '/media/ground.png')
|
|
24
|
+
else
|
|
25
|
+
abort("tile.initialize(): Unknown terrain symbol (#{loaded_symbol})")
|
|
26
26
|
end
|
|
27
27
|
end
|
|
28
28
|
|
data/lib/town.rb
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
require_relative './unit'
|
|
2
2
|
|
|
3
3
|
class Town < Unit
|
|
4
|
-
attr_accessor :parts_built
|
|
4
|
+
attr_accessor :project, :parts_built, :parts_needed
|
|
5
5
|
|
|
6
6
|
def initialize(x, y, faction, map, infopane)
|
|
7
7
|
super
|
|
@@ -12,10 +12,13 @@ class Town < Unit
|
|
|
12
12
|
@value = 20
|
|
13
13
|
@armor_left = @armor_max = 1
|
|
14
14
|
@moves_max = 0
|
|
15
|
+
@cargo_max = 10
|
|
15
16
|
|
|
16
17
|
@parts_built = 0
|
|
17
|
-
@
|
|
18
|
-
|
|
18
|
+
@parts_needed = 0
|
|
19
|
+
@project = nil
|
|
20
|
+
|
|
21
|
+
set_function!(FUNCBUILD)
|
|
19
22
|
end
|
|
20
23
|
|
|
21
24
|
def can_build?
|
|
@@ -25,4 +28,50 @@ class Town < Unit
|
|
|
25
28
|
def can_be_captured?
|
|
26
29
|
true
|
|
27
30
|
end
|
|
31
|
+
|
|
32
|
+
# Tell the state of current build project
|
|
33
|
+
def build_info
|
|
34
|
+
"#{@parts_built}/#{@parts_needed}"
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
# Process capture targeted at this town and reset build process
|
|
38
|
+
def capture!(by_whom)
|
|
39
|
+
super
|
|
40
|
+
|
|
41
|
+
# Reset build process
|
|
42
|
+
@project = nil
|
|
43
|
+
@parts_built = 0
|
|
44
|
+
set_function!(FUNCBUILD)
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
# Set desired function and possibly also project
|
|
48
|
+
def set_function!(func)
|
|
49
|
+
super
|
|
50
|
+
|
|
51
|
+
if @faction != 0 and func == FUNCBUILD # neutral towns dom't need projects either
|
|
52
|
+
set_project!
|
|
53
|
+
end
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
# Set desired project
|
|
57
|
+
def set_project!
|
|
58
|
+
@desired_project = "army" # TODO ask for input on what to build
|
|
59
|
+
@parts_needed = 3 # TODO load from given project class
|
|
60
|
+
|
|
61
|
+
if @desired_project == @project
|
|
62
|
+
puts PROMPT + to_s + ": project has already been set to #{@project} (#{build_info} done)"
|
|
63
|
+
else
|
|
64
|
+
previous_project = @project
|
|
65
|
+
@project = @desired_project
|
|
66
|
+
lost_parts = @parts_built
|
|
67
|
+
@parts_built = 0
|
|
68
|
+
|
|
69
|
+
new_project_set_text = PROMPT + to_s + ": project set to #{@project} (#{build_info} done)"
|
|
70
|
+
unless lost_parts > 0
|
|
71
|
+
puts new_project_set_text
|
|
72
|
+
else
|
|
73
|
+
puts new_project_set_text + ", losing #{lost_parts} parts of #{previous_project} "
|
|
74
|
+
end
|
|
75
|
+
end
|
|
76
|
+
end
|
|
28
77
|
end
|
data/lib/unit.rb
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
require_relative './unitFunction'
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
PARTS_TO_BE_BUILT = 0
|
|
4
|
+
|
|
5
|
+
# Both capturable and movable game pieces
|
|
4
6
|
class Unit
|
|
5
7
|
attr_accessor :x, :y, :faction, :function, :cargo
|
|
6
8
|
|
|
7
|
-
|
|
8
9
|
def initialize(x, y, faction, map, infopane)
|
|
9
10
|
@x = x
|
|
10
11
|
@y = y
|
|
@@ -20,7 +21,7 @@ class Unit
|
|
|
20
21
|
@moves_left = @moves_max
|
|
21
22
|
@cargo = [] # transported units
|
|
22
23
|
@cargo_max = 0
|
|
23
|
-
@function = UnitFunction.new(FUNCNONE)
|
|
24
|
+
@function = UnitFunction.new(FUNCNONE, self)
|
|
24
25
|
|
|
25
26
|
# Store yourself
|
|
26
27
|
coords_unit = @map.get_unit(@x, @y)
|
|
@@ -31,25 +32,66 @@ class Unit
|
|
|
31
32
|
end
|
|
32
33
|
end
|
|
33
34
|
|
|
34
|
-
#
|
|
35
|
-
def
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
35
|
+
# Process engagement targeted at this unit
|
|
36
|
+
def engage!(by_whom)
|
|
37
|
+
if by_whom == @faction
|
|
38
|
+
abort("unit.engage!(): Engaging unit is of the same faction as this one (#{@faction})")
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
# Can it be captured and is it without defenders?
|
|
42
|
+
if can_be_captured?
|
|
43
|
+
if is_transporting?
|
|
44
|
+
cargo[0].attack!(by_whom)
|
|
45
|
+
else # then capture it if you can
|
|
46
|
+
if by_whom.can_capture?
|
|
47
|
+
puts PROMPT + by_whom.to_s + ' is capturing ' + to_s
|
|
48
|
+
capture!(by_whom.faction)
|
|
49
|
+
else
|
|
50
|
+
puts PROMPT + by_whom.to_s + ' can\'t capture other units'
|
|
51
|
+
end
|
|
52
|
+
end
|
|
53
|
+
else
|
|
54
|
+
attack!(by_whom) # uncapturable transporters can't get help from their cargo
|
|
55
|
+
end
|
|
39
56
|
end
|
|
40
57
|
|
|
41
|
-
|
|
42
|
-
|
|
58
|
+
# Process attack targeted at this unit
|
|
59
|
+
def attack!(by_whom)
|
|
60
|
+
puts PROMPT + by_whom.to_s + ' is attacking ' + to_s
|
|
61
|
+
destroy! # TODO proper combat
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
# Process capture targeted at this unit
|
|
65
|
+
def capture!(by_whom)
|
|
66
|
+
unless can_be_captured?
|
|
67
|
+
abort("unit.capture!(): This unit can\'t be captured")
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
if by_whom == @faction
|
|
71
|
+
abort("unit.capture!(): This unit already belongs to faction #{@faction}")
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
# Add <value> to the capturing faction
|
|
43
75
|
@infopane.add_score(by_whom - 1, @value)
|
|
44
76
|
@faction = by_whom
|
|
77
|
+
end
|
|
78
|
+
|
|
79
|
+
# Add <value> to the other faction and remove links to given unit
|
|
80
|
+
def destroy!
|
|
81
|
+
# If you are transporting somebody, destroy them first
|
|
82
|
+
@cargo.each { |uu| uu.destroy! }
|
|
45
83
|
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
84
|
+
@infopane.add_score(3 - @faction - 1, @value) # TODO more factions?
|
|
85
|
+
|
|
86
|
+
if is_transported?
|
|
87
|
+
coords_unit = @map.get_unit(@x, @y)
|
|
88
|
+
coords_unit.cargo -= [self]
|
|
89
|
+
else
|
|
90
|
+
@map.set_unit(@x, @y, nil)
|
|
49
91
|
end
|
|
50
92
|
end
|
|
51
93
|
|
|
52
|
-
#
|
|
94
|
+
# Process move of unit and take care of its (un)loading or start of engagement
|
|
53
95
|
def check_movement(old_x, old_y)
|
|
54
96
|
if @x != old_x || @y != old_y # only if it moved
|
|
55
97
|
if @moves_left <= 0
|
|
@@ -66,7 +108,7 @@ class Unit
|
|
|
66
108
|
!newcoords_unit.is_full?)
|
|
67
109
|
|
|
68
110
|
# Leave old coordinates
|
|
69
|
-
if oldcoords_unit == self
|
|
111
|
+
if oldcoords_unit == self
|
|
70
112
|
@map.set_unit(old_x, old_y, nil)
|
|
71
113
|
else # if you have been transported
|
|
72
114
|
oldcoords_unit.cargo.delete(self)
|
|
@@ -99,26 +141,16 @@ class Unit
|
|
|
99
141
|
puts PROMPT + newcoords_unit.to_s + ' is already full'
|
|
100
142
|
end
|
|
101
143
|
else
|
|
102
|
-
#
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
puts PROMPT + to_s + ' is capturing ' + newcoords_unit.to_s
|
|
106
|
-
newcoords_unit.capture(@faction)
|
|
107
|
-
else
|
|
108
|
-
puts PROMPT + to_s + ' can\'t capture other units'
|
|
109
|
-
end
|
|
110
|
-
else # then battle it
|
|
111
|
-
puts PROMPT + to_s + ' is battling ' + newcoords_unit.to_s
|
|
112
|
-
newcoords_unit.destroy # TODO randomized combat
|
|
113
|
-
end
|
|
114
|
-
end
|
|
144
|
+
# Enemy!
|
|
145
|
+
newcoords_unit.engage!(self)
|
|
146
|
+
end
|
|
115
147
|
end
|
|
116
148
|
@moves_left -= 1
|
|
117
149
|
|
|
118
150
|
# Check if you are on an invalid type of terrain (unless transported)
|
|
119
|
-
unless
|
|
151
|
+
unless is_terrain_suitable?
|
|
120
152
|
puts PROMPT + to_s + " found itself in a bad place"
|
|
121
|
-
destroy
|
|
153
|
+
destroy!
|
|
122
154
|
end
|
|
123
155
|
end
|
|
124
156
|
end
|
|
@@ -149,6 +181,10 @@ class Unit
|
|
|
149
181
|
false
|
|
150
182
|
end
|
|
151
183
|
|
|
184
|
+
def can_be_built?
|
|
185
|
+
PARTS_TO_BE_BUILT > 0
|
|
186
|
+
end
|
|
187
|
+
|
|
152
188
|
def can_transport?
|
|
153
189
|
@cargo_max > 0
|
|
154
190
|
end
|
|
@@ -174,7 +210,7 @@ class Unit
|
|
|
174
210
|
end
|
|
175
211
|
|
|
176
212
|
# Checks if unit is on the right type of terrain (not for transported units)
|
|
177
|
-
def
|
|
213
|
+
def is_terrain_suitable?
|
|
178
214
|
unless is_transported?
|
|
179
215
|
case @map.tile(@x, @y).terrain
|
|
180
216
|
when TILE_SEA
|
|
@@ -190,14 +226,16 @@ class Unit
|
|
|
190
226
|
@function.func
|
|
191
227
|
end
|
|
192
228
|
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
229
|
+
# Set desired function
|
|
230
|
+
def set_function!(func)
|
|
231
|
+
unless @faction == 0 # neutral towns dom't need functions
|
|
232
|
+
if func == FUNCBUILD and !can_build?
|
|
196
233
|
puts PROMPT + to_s + ": this unit can't build other units"
|
|
234
|
+
return
|
|
197
235
|
end
|
|
198
236
|
|
|
199
237
|
if @function.func == func
|
|
200
|
-
puts PROMPT + to_s + ": function
|
|
238
|
+
puts PROMPT + to_s + ": function is already set to #{@function.func}"
|
|
201
239
|
else
|
|
202
240
|
@function.func = func
|
|
203
241
|
puts PROMPT + to_s + ": function set to #{@function.func}"
|
|
@@ -206,7 +244,7 @@ class Unit
|
|
|
206
244
|
end
|
|
207
245
|
|
|
208
246
|
def function!
|
|
209
|
-
ret = @function.func!(@
|
|
247
|
+
ret = @function.func!(@map, @infopane)
|
|
210
248
|
puts to_s + ret
|
|
211
249
|
end
|
|
212
250
|
|
|
@@ -218,15 +256,15 @@ class Unit
|
|
|
218
256
|
# Set long info string: short info string, armor, moves, function, cargo
|
|
219
257
|
def info
|
|
220
258
|
ret = to_s + ": armor #{@armor_left}/#{@armor_max}"
|
|
221
|
-
|
|
259
|
+
|
|
222
260
|
if @moves_max > 0
|
|
223
261
|
ret = ret + ", moves #{@moves_left}/#{@moves_max}"
|
|
224
262
|
end
|
|
225
263
|
|
|
226
|
-
ret = ret + ",
|
|
264
|
+
ret = ret + ", #{@function.info}"
|
|
227
265
|
|
|
228
|
-
if @
|
|
229
|
-
ret = ret + ",
|
|
266
|
+
if @cargo_max > 0
|
|
267
|
+
ret = ret + ", cargo #{@cargo.size}/#{@cargo_max}"
|
|
230
268
|
end
|
|
231
269
|
|
|
232
270
|
ret
|
data/lib/unitFunction.rb
CHANGED
|
@@ -1,38 +1,45 @@
|
|
|
1
|
-
PARTS = 3
|
|
2
|
-
|
|
3
1
|
class UnitFunction
|
|
4
2
|
attr_accessor :func
|
|
5
3
|
|
|
6
|
-
def initialize(function = FUNCNONE)
|
|
4
|
+
def initialize(function = FUNCNONE, unit)
|
|
7
5
|
@func = function
|
|
6
|
+
@unit = unit
|
|
8
7
|
end
|
|
9
8
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
9
|
+
# Set function part of long info string of unit
|
|
10
|
+
def info
|
|
11
|
+
case @func
|
|
12
|
+
when FUNCNONE
|
|
13
|
+
"no function"
|
|
14
|
+
when FUNCBUILD
|
|
15
|
+
"building #{@unit.project} (#{@unit.build_info})"
|
|
16
|
+
when FUNCSENTRY
|
|
17
|
+
"sentrying"
|
|
16
18
|
end
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
def func!(map, infopane)
|
|
22
|
+
ret = " didn't actually do anything (ERROR)"
|
|
17
23
|
|
|
18
24
|
case @func
|
|
19
25
|
# Build given unit
|
|
20
26
|
when FUNCBUILD
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
27
|
+
@unit.parts_built += 1
|
|
28
|
+
|
|
29
|
+
unless @unit.parts_built >= @unit.parts_needed # just == should be enough
|
|
30
|
+
ret = " built next part of #{@unit.project} (#{@unit.build_info} done)"
|
|
25
31
|
else
|
|
26
|
-
ret = "
|
|
27
|
-
unit.parts_built =
|
|
32
|
+
ret = " completed building of #{@unit.project}"
|
|
33
|
+
@unit.parts_built = 0
|
|
34
|
+
Army.new(@unit.x, @unit.y, @unit.faction, map, infopane)
|
|
28
35
|
end
|
|
29
|
-
|
|
30
|
-
# Wake
|
|
36
|
+
|
|
37
|
+
# Wake when enemies are nearby
|
|
31
38
|
when FUNCSENTRY
|
|
32
39
|
units_around = map.all_units.select { |uu|
|
|
33
|
-
(uu.x -
|
|
34
|
-
(uu.y -
|
|
35
|
-
uu.faction != unit.faction
|
|
40
|
+
(uu.x - @unit.x).abs <= 1 &&
|
|
41
|
+
(uu.y - @unit.y).abs <= 1 &&
|
|
42
|
+
uu.faction != @unit.faction
|
|
36
43
|
}
|
|
37
44
|
if units_around.size > 0
|
|
38
45
|
ret = " woke up"
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: empi
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: '0.
|
|
4
|
+
version: '0.19'
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Detros
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2019-
|
|
11
|
+
date: 2019-12-04 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: gosu
|
|
@@ -48,8 +48,6 @@ extra_rdoc_files: []
|
|
|
48
48
|
files:
|
|
49
49
|
- lib/army.rb
|
|
50
50
|
- lib/cursor.rb
|
|
51
|
-
- lib/docu/Empi v14.png
|
|
52
|
-
- lib/docu/Empi v18 - printouts.png
|
|
53
51
|
- lib/docu/Empi v18.png
|
|
54
52
|
- lib/docu/info.txt
|
|
55
53
|
- lib/empi.rb
|
|
@@ -62,6 +60,7 @@ files:
|
|
|
62
60
|
- lib/media/ship.png
|
|
63
61
|
- lib/media/town.png
|
|
64
62
|
- lib/save/m01.esf
|
|
63
|
+
- lib/save/m02-err.esf
|
|
65
64
|
- lib/save/m02.esf
|
|
66
65
|
- lib/save/m03.esf
|
|
67
66
|
- lib/ship.rb
|
data/lib/docu/Empi v14.png
DELETED
|
Binary file
|
|
Binary file
|