empi 0.21 → 0.25

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.
data/lib/play_state.rb DELETED
@@ -1,98 +0,0 @@
1
- require 'singleton'
2
-
3
- require_relative './game_state'
4
- require_relative './escape_state'
5
-
6
- require_relative './cursor'
7
- require_relative './infopane'
8
- require_relative './map'
9
-
10
-
11
- XTEXT = 5
12
- YTEXT = 5
13
- ZTILE = 0
14
- ZUNIT = 1
15
- ZTEXT = 2
16
- ZCURSOR = 3
17
-
18
- FACTIONS = 2
19
- COLOUR = [0xff_ffffff, 0xff_ff3300, 0xff_ffcc00]
20
-
21
- FUNCNONE = 'none'
22
- FUNCSENTRY = 'sentry'
23
- FUNCBUILD = 'build'
24
-
25
- # Game state of main gameplay
26
- class PlayState < GameState
27
- include Singleton
28
-
29
- # Load new scenario or resume game
30
- def after_start
31
- unless @infopane and @map and @cursor # is everything set up yet?
32
- @infopane = Infopane.new
33
- @map = Map.new(@infopane)
34
- @cursor = Cursor.new(0, 0, @map, @infopane)
35
- help # show help after loading of map
36
- new_turn
37
- else
38
- # Remind player the current status
39
- if @cursor.freeroam
40
- @infopane.text = 'freeroam is enabled'
41
- puts 'freeroam is enabled'
42
- else
43
- @cursor.info
44
- end
45
- end
46
- end
47
-
48
- # What to do just before state gets deactivated
49
- #def before_end
50
- # TODO undraw all parts?
51
- #end
52
-
53
- # Process given button or send it to cursor
54
- def update(button)
55
- case(button)
56
- when Gosu::KbEscape then
57
- GameState.switch!(EscapeState.instance)
58
- when Gosu::KbPeriod then
59
- new_turn
60
- when Gosu::KbH then
61
- help
62
- else
63
- @cursor.update(button)
64
- end
65
- end
66
-
67
- # Draw all parts of main window
68
- def draw
69
- @map.draw_tiles
70
- @cursor.draw
71
- @infopane.draw
72
- end
73
-
74
- # End current turn and start the next one
75
- def new_turn
76
- puts "=============\n" \
77
- "End of turn\n" \
78
- "=============\n"
79
-
80
- functionable_units = @map.all_units.select { |uu| uu.function != FUNCNONE}
81
- functionable_units.each { |uu| uu.function! }
82
-
83
- @map.all_units.each { |uu| uu.reset_moves!}
84
- @infopane.next_turn
85
-
86
- @cursor.freeroam = true
87
- @cursor.switch_freeroam! # so freeroam = false, with messages
88
- end
89
-
90
- # Printout the controls
91
- def help
92
- puts "-----------\n" \
93
- "h: help, Esc: end game, Enter: info, j: switch freeroam\n" \
94
- "QWEADZXC or arrow keys: movement, .: end turn\n" \
95
- "functions: s sentry, b build, n none\n" \
96
- "-----------\n"
97
- end
98
- end
data/lib/tile.rb DELETED
@@ -1,36 +0,0 @@
1
- TILE_SEA = 0
2
- TILE_GROUND = 1
3
-
4
- SYMBOL_SEA = '.'
5
- SYMBOL_GROUND = '#'
6
-
7
- class Tile
8
- attr_accessor :terrain, :infopane, :unit
9
-
10
- def initialize(x, y, loaded_symbol, infopane)
11
- dir_path = File.dirname(__FILE__)
12
-
13
- @x = x
14
- @y = y
15
- @infopane = infopane
16
-
17
- case(loaded_symbol)
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
- end
27
- end
28
-
29
- def draw
30
- @image.draw(@x * TILESIZE, (@y + 1) * TILESIZE, ZTILE)
31
-
32
- if @unit
33
- @unit.draw
34
- end
35
- end
36
- end