class WinState

Game state of summary of won game

Attributes

faction[R]

Public Instance Methods

draw() click to toggle source
# 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) click to toggle source
# 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!() click to toggle source
# File lib/lib/game_states/win_state.rb, line 55
 def unset_victory!()
  @faction = nil
  @type = nil
  @turn = nil
  @score = nil
end
update(button) click to toggle source

Process given button

# 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