empi 0.23 → 0.24
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/empi.rb +1 -1
- data/lib/lib/game_states/build_state.rb +16 -30
- data/lib/lib/units/army.rb +1 -1
- data/lib/lib/units/ship.rb +1 -1
- data/lib/lib/units/town.rb +10 -8
- data/lib/lib/units/unit.rb +6 -6
- data/lib/lib/user_interface/cursor.rb +9 -3
- data/lib/lib/user_interface/tile.rb +16 -0
- metadata +7 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 63caec222a8c3c293532aabadbebc30a9acb2f8a664b4327ba95dae6e5222955
|
4
|
+
data.tar.gz: '09b1c7b2f163e042ee4e9ecb17547b585c5d8b80480c099f8a253a2c917449e2'
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1662dd058a2e1d8d5e4a8f4cdf48cb7f3b8a45bcc2500c11dd458af7c0d0aff5c9718ce79d5378f47ef6d9d0b9650a1a0a8604b791368371515f68390264e02e
|
7
|
+
data.tar.gz: abcac90abcfa4d0c72561ddac4c8a074e558d906f82530a7ac7d554f8784d769998b778ed8e5cb3f71c2217f807d6ddcf505217f589a1bfdf2f887c1b3577a0b
|
data/lib/empi.rb
CHANGED
@@ -18,62 +18,48 @@ class BuildState < GameState
|
|
18
18
|
|
19
19
|
# What to do just before state gets deactivated
|
20
20
|
#def before_end
|
21
|
-
# TODO hide question?
|
22
21
|
#end
|
23
22
|
|
24
23
|
# Process given button to cursor
|
25
24
|
def update(button)
|
26
|
-
|
25
|
+
newly_selected = nil
|
27
26
|
|
28
27
|
case(button)
|
28
|
+
# Cancelled change of project = return
|
29
29
|
when Gosu::KbEscape then
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
else
|
34
|
-
puts PROMPT + @unit.to_s + ": cancelling, nothing changed"
|
35
|
-
GameState.switch!(PlayState.instance)
|
36
|
-
end
|
30
|
+
puts PROMPT + @unit.to_s + ": cancelling, nothing changed"
|
31
|
+
GameState.switch!(PlayState.instance)
|
32
|
+
# Paused production = reset function and return
|
37
33
|
when Gosu::Kb0, Gosu::KbN then
|
38
|
-
|
34
|
+
puts PROMPT + @unit.to_s + ": production paused, resetting function"
|
35
|
+
@unit.set_function!(FUNCNONE, @unit.faction)
|
36
|
+
GameState.switch!(PlayState.instance)
|
37
|
+
# Selected new project = set it and return
|
39
38
|
when Gosu::Kb1, Gosu::KbA then
|
40
|
-
|
39
|
+
newly_selected = Army
|
41
40
|
when Gosu::Kb2, Gosu::KbS then
|
42
|
-
|
41
|
+
newly_selected = Ship
|
43
42
|
end
|
44
43
|
|
45
44
|
# Did we get any proper answer?
|
46
|
-
if
|
47
|
-
@unit.set_project!(
|
45
|
+
if newly_selected
|
46
|
+
@unit.set_project!(newly_selected)
|
48
47
|
GameState.switch!(PlayState.instance)
|
49
48
|
end
|
50
49
|
end
|
51
50
|
|
52
|
-
# If "none" project was selected reset also the function
|
53
|
-
def reset_function!()
|
54
|
-
puts PROMPT + @unit.to_s + ": no project selected, resetting function"
|
55
|
-
@unit.set_function!(FUNCNONE, @unit.faction)
|
56
|
-
GameState.switch!(PlayState.instance)
|
57
|
-
end
|
58
|
-
|
59
51
|
def draw
|
60
52
|
# Combine parts according to if there already is some project set
|
61
53
|
unit_text = "Built so far in " + @unit.to_s + ":"
|
62
|
-
|
63
|
-
project_text = "
|
54
|
+
project_text = "
|
64
55
|
#{@unit.parts_built} " +
|
65
56
|
"part#{ 's' unless @unit.parts_built == 1 } of " +
|
66
57
|
@unit.project.name + " (" + @unit.build_info + ")"
|
67
|
-
else
|
68
|
-
project_text = "
|
69
|
-
no project selected"
|
70
|
-
end
|
71
|
-
|
72
58
|
options_text = "Select the project:\n
|
73
59
|
1, A – Army (#{ @unit.price_list[Army] } turns)
|
74
60
|
2, S – Ship (#{ @unit.price_list[Ship] } turns)\n
|
75
|
-
0, N –
|
76
|
-
Esc – cancel
|
61
|
+
0, N – pause production
|
62
|
+
Esc – cancel change of project"
|
77
63
|
|
78
64
|
build_project = Gosu::Image.from_text(
|
79
65
|
unit_text + "\n" + project_text + "\n\n" + options_text, 20)
|
data/lib/lib/units/army.rb
CHANGED
data/lib/lib/units/ship.rb
CHANGED
data/lib/lib/units/town.rb
CHANGED
@@ -17,11 +17,12 @@ class Town < Unit
|
|
17
17
|
dir_path = File.dirname(__FILE__)
|
18
18
|
@image = Gosu::Image.new(dir_path + '/../../media/town.png')
|
19
19
|
|
20
|
-
@
|
20
|
+
@armour_left = @armour_max = 1
|
21
21
|
@moves_max = 0
|
22
22
|
@cargo_max = 10
|
23
23
|
|
24
|
-
@starting_project = Army unless @faction == 0
|
24
|
+
@starting_project = Army unless @faction == 0 # used once at the game start
|
25
|
+
@default_project = Army # used after capture
|
25
26
|
@project = nil
|
26
27
|
@parts_built = 0
|
27
28
|
@parts_needed = 0
|
@@ -47,10 +48,12 @@ class Town < Unit
|
|
47
48
|
super
|
48
49
|
|
49
50
|
# Reset build process
|
51
|
+
# 1) remove old project so that it is not disclosed
|
52
|
+
# 2) set default project so that there is always some set (remove old parts)
|
53
|
+
# 3) offer change of the project to the new owner
|
50
54
|
@function.func = FUNCNONE
|
51
55
|
@project = nil
|
52
|
-
@
|
53
|
-
|
56
|
+
set_project!(@default_project)
|
54
57
|
set_function!(FUNCBUILD, @faction)
|
55
58
|
end
|
56
59
|
|
@@ -87,12 +90,11 @@ class Town < Unit
|
|
87
90
|
@parts_built = 0
|
88
91
|
|
89
92
|
new_project_set_text = PROMPT + to_s + ": project set to #{@project.name} (#{build_info} done)"
|
90
|
-
|
91
|
-
puts new_project_set_text
|
92
|
-
else
|
93
|
+
if previous_project and lost_parts > 0 # parts were lost but not due to capture
|
93
94
|
puts new_project_set_text + ", losing #{lost_parts} " +
|
94
95
|
"part#{ 's' unless lost_parts == 1 } of #{previous_project.name}"
|
95
|
-
|
96
|
+
else
|
97
|
+
puts new_project_set_text
|
96
98
|
end
|
97
99
|
end
|
98
100
|
end
|
data/lib/lib/units/unit.rb
CHANGED
@@ -6,7 +6,7 @@ class Unit
|
|
6
6
|
attr_reader :name, :map_symbol, :price, :value
|
7
7
|
end
|
8
8
|
|
9
|
-
attr_reader :
|
9
|
+
attr_reader :armour_left
|
10
10
|
attr_accessor :x, :y, :faction, :function, :cargo, :cargo_max
|
11
11
|
|
12
12
|
def initialize(x, y, faction, map, infopane)
|
@@ -16,8 +16,8 @@ class Unit
|
|
16
16
|
@map = map
|
17
17
|
@infopane = infopane
|
18
18
|
|
19
|
-
@
|
20
|
-
@
|
19
|
+
@armour_max = 1
|
20
|
+
@armour_left = @armour_max
|
21
21
|
@moves_max = 1
|
22
22
|
@moves_left = @moves_max
|
23
23
|
@cargo = [] # transported units
|
@@ -79,7 +79,7 @@ class Unit
|
|
79
79
|
|
80
80
|
# Add <value> to the other faction and remove links to given unit
|
81
81
|
def destroy!
|
82
|
-
@
|
82
|
+
@armour_left = 0 # for non-attack damage
|
83
83
|
|
84
84
|
# If you are transporting somebody, destroy them first
|
85
85
|
@cargo.each { |uu| uu.destroy! }
|
@@ -278,9 +278,9 @@ class Unit
|
|
278
278
|
"#{self.class.name} (FAC#{@faction} #{@x}-#{@y})"
|
279
279
|
end
|
280
280
|
|
281
|
-
# Set long info string: short info string,
|
281
|
+
# Set long info string: short info string, armour, moves, function, cargo
|
282
282
|
def info
|
283
|
-
ret = to_s + ":
|
283
|
+
ret = to_s + ": armour #{@armour_left}/#{@armour_max}"
|
284
284
|
|
285
285
|
if @moves_max > 0
|
286
286
|
ret = ret + ", moves #{@moves_left}/#{@moves_max}"
|
@@ -78,6 +78,7 @@ class Cursor
|
|
78
78
|
@x += xx
|
79
79
|
@y += yy
|
80
80
|
@local_unit = @map.get_unit(@x, @y)
|
81
|
+
# TODO show some basic tile info in infopane
|
81
82
|
else
|
82
83
|
check_unit
|
83
84
|
|
@@ -87,7 +88,7 @@ class Cursor
|
|
87
88
|
@locked_to.check_movement(@x, @y) # cursor coordinates work like old_x, old_y
|
88
89
|
|
89
90
|
# Is the unit still alive?
|
90
|
-
if @locked_to.
|
91
|
+
if @locked_to.armour_left > 0
|
91
92
|
warp_to_locked! # whether it moved or not
|
92
93
|
else
|
93
94
|
# It got destroyed so clear last links then so that (object of)
|
@@ -104,6 +105,11 @@ class Cursor
|
|
104
105
|
|
105
106
|
if @local_unit
|
106
107
|
@local_unit.set_function!(func, @infopane.faction)
|
108
|
+
|
109
|
+
# Update infopane with the new (possibly changed) state
|
110
|
+
# (visible only in freeroam mode as in locked one the infopane is
|
111
|
+
# overwritten as cursor either jumps away or switches to freeroam mode)
|
112
|
+
@infopane.text = @local_unit.info
|
107
113
|
else
|
108
114
|
puts "no unit to set that function to (at #{@x}-#{@y})"
|
109
115
|
end
|
@@ -169,7 +175,7 @@ class Cursor
|
|
169
175
|
def info
|
170
176
|
check_unit
|
171
177
|
|
172
|
-
|
178
|
+
if @local_unit
|
173
179
|
@infopane.text = @local_unit.info
|
174
180
|
puts @local_unit.info
|
175
181
|
|
@@ -178,7 +184,7 @@ class Cursor
|
|
178
184
|
end
|
179
185
|
else
|
180
186
|
@infopane.text = ''
|
181
|
-
puts
|
187
|
+
puts "no unit to show info of (at #{@x}-#{@y})"
|
182
188
|
end
|
183
189
|
end
|
184
190
|
end
|
@@ -27,10 +27,26 @@ class Tile
|
|
27
27
|
end
|
28
28
|
|
29
29
|
def draw
|
30
|
+
# 1) terrain
|
30
31
|
@image.draw(@x * TILESIZE, (@y + 1) * TILESIZE, ZTILE)
|
31
32
|
|
33
|
+
# 2) unit
|
32
34
|
if @unit
|
33
35
|
@unit.draw
|
34
36
|
end
|
37
|
+
|
38
|
+
# 3) axes
|
39
|
+
draw_axis_tick(@x, @y, 0) # TODO 0 -> viewport.y
|
40
|
+
draw_axis_tick(@y, @x, 0) # TODO 0 -> viewport.x
|
41
|
+
end
|
42
|
+
|
43
|
+
# Draw one tick of axis for appropriate tiles
|
44
|
+
def draw_axis_tick(draw_coord, test_coord, test_against)
|
45
|
+
# TODO appropriatness can be changed (show axes: no/top/left/bottom/right)
|
46
|
+
if test_coord == test_against
|
47
|
+
tick = Gosu::Image.from_text(draw_coord, 20)
|
48
|
+
tick.draw(@x * TILESIZE, (@y + 1) * TILESIZE, ZTEXT)
|
49
|
+
# ^^ TODO substract test_against of viewport from @x and @y here?
|
50
|
+
end
|
35
51
|
end
|
36
52
|
end
|
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.24'
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Detros
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-10-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: gosu
|
@@ -38,9 +38,10 @@ dependencies:
|
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '10.0'
|
41
|
-
description:
|
42
|
-
|
43
|
-
|
41
|
+
description: |-
|
42
|
+
Empi: Ruby Edition is a turn-based wargame with hotseat
|
43
|
+
multiplayer, currently in alpha development state. The game is inspired by
|
44
|
+
Classic Empire, originally from 1977.
|
44
45
|
email: rasunadon@seznam.cz
|
45
46
|
executables: []
|
46
47
|
extensions: []
|
@@ -100,5 +101,5 @@ rubyforge_project:
|
|
100
101
|
rubygems_version: 2.7.6
|
101
102
|
signing_key:
|
102
103
|
specification_version: 4
|
103
|
-
summary:
|
104
|
+
summary: A turn-based wargame
|
104
105
|
test_files: []
|