empi 0.23 → 0.24

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d7a7e44ce8aebd925aac9b87c2344c2ddfb75dc7e12b2d2d61d584c6c4ca2477
4
- data.tar.gz: edc23d080b7c85249fd869b4571c6c42eff315a2a5ddee93720b5f7c9aa09004
3
+ metadata.gz: 63caec222a8c3c293532aabadbebc30a9acb2f8a664b4327ba95dae6e5222955
4
+ data.tar.gz: '09b1c7b2f163e042ee4e9ecb17547b585c5d8b80480c099f8a253a2c917449e2'
5
5
  SHA512:
6
- metadata.gz: 22293eedf9f530feafdc018936a37399c2c4ac975c65e00f4b32ffa4c27a79e912d1e2c5e3d0189d464b348b8f0aebc9b5c2955f7b616daadd813afc9f6e5a11
7
- data.tar.gz: 4701285d5bb8aa354afd9d766e4b2012489822aaa0e3c59cc3c6b9ae6f9cb3a7c61ab521d142e425bfb582c6fa2c6ef86dc10a5fdb1a785a03ecf2de4a97c4f9
6
+ metadata.gz: 1662dd058a2e1d8d5e4a8f4cdf48cb7f3b8a45bcc2500c11dd458af7c0d0aff5c9718ce79d5378f47ef6d9d0b9650a1a0a8604b791368371515f68390264e02e
7
+ data.tar.gz: abcac90abcfa4d0c72561ddac4c8a074e558d906f82530a7ac7d554f8784d769998b778ed8e5cb3f71c2217f807d6ddcf505217f589a1bfdf2f887c1b3577a0b
@@ -19,7 +19,7 @@ class GameWindow < Gosu::Window
19
19
  height = (MAPY + 2) * TILESIZE, \
20
20
  fullscreen = false)
21
21
  super
22
- self.caption = 'Empi: Ruby Edition 0.23'
22
+ self.caption = 'Empi: Ruby Edition 0.24'
23
23
 
24
24
  # Activate first state
25
25
  $window = self
@@ -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
- project = nil
25
+ newly_selected = nil
27
26
 
28
27
  case(button)
28
+ # Cancelled change of project = return
29
29
  when Gosu::KbEscape then
30
- # If there was no project selected before then behave same as "none" option
31
- unless @unit.project
32
- reset_function!()
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
- reset_function!()
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
- project = Army
39
+ newly_selected = Army
41
40
  when Gosu::Kb2, Gosu::KbS then
42
- project = Ship
41
+ newly_selected = Ship
43
42
  end
44
43
 
45
44
  # Did we get any proper answer?
46
- if project
47
- @unit.set_project!(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
- if @unit.project
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 – none
76
- Esc – cancel project #{ @unit.project ? 'change' : 'setup'}"
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)
@@ -11,7 +11,7 @@ class Army < Unit
11
11
  dir_path = File.dirname(__FILE__)
12
12
  @image = Gosu::Image.new(dir_path + '/../../media/army.png')
13
13
 
14
- @armor_left = @armor_max = 3
14
+ @armour_left = @armour_max = 3
15
15
  @moves_max = 5
16
16
  end
17
17
 
@@ -11,7 +11,7 @@ class Ship < Unit
11
11
  dir_path = File.dirname(__FILE__)
12
12
  @image = Gosu::Image.new(dir_path + '/../../media/ship.png')
13
13
 
14
- @armor_left = @armor_max = 1
14
+ @armour_left = @armour_max = 1
15
15
  @moves_max = 2
16
16
  @cargo_max = 3
17
17
  end
@@ -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
- @armor_left = @armor_max = 1
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
- @parts_built = 0
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
- unless lost_parts > 0
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
@@ -6,7 +6,7 @@ class Unit
6
6
  attr_reader :name, :map_symbol, :price, :value
7
7
  end
8
8
 
9
- attr_reader :armor_left
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
- @armor_max = 1
20
- @armor_left = @armor_max
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
- @armor_left = 0 # for non-attack damage
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, armor, moves, function, cargo
281
+ # Set long info string: short info string, armour, moves, function, cargo
282
282
  def info
283
- ret = to_s + ": armor #{@armor_left}/#{@armor_max}"
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.armor_left > 0
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
- unless !@local_unit
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 'nothing here'
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.23'
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-08-25 00:00:00.000000000 Z
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: 'Empi: Ruby Edition is a turn based wargame, currently deep in development.
42
- While learning Ruby I have found there are hardly any strategic games avaiable.
43
- So this should be Ruby version of Classic Empire, wargame from old times.'
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: Turn-based wargame
104
+ summary: A turn-based wargame
104
105
  test_files: []