Class: WinState

Inherits:
GameState show all
Includes:
Singleton
Defined in:
lib/lib/game_states/win_state.rb

Overview

Game state of summary of won game

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from GameState

#after_start, #before_end, switch!

Instance Attribute Details

#factionObject (readonly)

Returns the value of attribute faction.



11
12
13
# File 'lib/lib/game_states/win_state.rb', line 11

def faction
  @faction
end

Instance Method Details

#drawObject



31
32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/lib/game_states/win_state.rb', line 31

def draw
  winner_text = "VICTORY FOR FACTION #{@faction}"
  summary_text = "Summary:
      victory type: #{@type}
      won on turn: #{@turn}
      ending score: #{@score}"
  options_text = 'Do you want to continue playing?
      Enter – resume
      Esc – return to menu'

  win_summary = Gosu::Image.from_text(
    winner_text + "\n\n\n" + summary_text + "\n\n" + options_text, 20)
  win_summary.draw((2*TILESIZE) + XTEXT, (2*TILESIZE) + YTEXT, ZTEXT)
end

#set_victory!(faction, type, turn, score) ⇒ Object



46
47
48
49
50
51
52
53
# File 'lib/lib/game_states/win_state.rb', line 46

def set_victory!(faction, type, turn, score)
  @faction = faction
  @type = type
  @turn = turn
  @score = score.clone # separate object is neeeded

  GameState.switch!(WinState.instance)
end

#unset_victory!Object



55
56
57
58
59
60
# File 'lib/lib/game_states/win_state.rb', line 55

def unset_victory!()
  @faction = nil
  @type = nil
  @turn = nil
  @score = nil
end

#update(button) ⇒ Object

Process given button



22
23
24
25
26
27
28
29
# File 'lib/lib/game_states/win_state.rb', line 22

def update(button)
  case(button)
  when Gosu::KbEscape then
    GameState.switch!(WelcomeState.instance)
  when Gosu::KbReturn then
    GameState.switch!(PlayState.instance)
  end
end