Class: GameState

Inherits:
Object
  • Object
show all
Defined in:
lib/game_state.rb

Constant Summary collapse

TARGET_MONEY =

Constant variables to hold target money and max reputation for gameplay

50.0
MAX_REPUTATION =
10
PAYMENT =
10.0

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeGameState

Returns a new instance of GameState.



9
10
11
12
13
14
# File 'lib/game_state.rb', line 9

def initialize()
  @@current_money = 0.0
  @@current_reputation = MAX_REPUTATION
  @@target_money = TARGET_MONEY
  @@max_reputation = MAX_REPUTATION
end

Class Method Details

.current_moneyObject



33
34
35
# File 'lib/game_state.rb', line 33

def self.current_money
  @@current_money
end

.current_reputationObject



37
38
39
# File 'lib/game_state.rb', line 37

def self.current_reputation
  @@current_reputation
end

.max_reputationObject



29
30
31
# File 'lib/game_state.rb', line 29

def self.max_reputation
  @@max_reputation
end

.target_moneyObject



25
26
27
# File 'lib/game_state.rb', line 25

def self.target_money
  @@target_money
end

.update_money(payment) ⇒ Object



41
42
43
# File 'lib/game_state.rb', line 41

def self.update_money(payment)
  @@current_money += payment
end

.update_reputation(reputation) ⇒ Object



45
46
47
# File 'lib/game_state.rb', line 45

def self.update_reputation(reputation)
  @@current_reputation += reputation
end

Instance Method Details

#display_game_stateObject



49
50
51
52
53
54
55
56
57
58
59
60
# File 'lib/game_state.rb', line 49

def display_game_state
  state_frame = ScreenMessage.new
  spacing = ScreenMessage::SPACING

  game_state = "MONEY / ".rjust((spacing / 2) + 1) + "Goal".ljust(spacing / 2)
  game_state += "$#{sprintf('%.2f', @@current_money)} / ".rjust((spacing / 2) + 1) + "$#{sprintf('%.2f', @@target_money)}".ljust(spacing / 2) + "\n\n"
  game_state += "+".colorize(:red) * spacing + "\n\n"
  game_state += "REPUTATION / ".rjust((spacing / 2) + 1) + "Max Reputation".ljust(spacing / 2)
  game_state += "#{@@current_reputation} / ".rjust((spacing / 2) + 1) + "#{@@max_reputation}".ljust(spacing / 2) + "\n\n "
  
  state_frame.recipe_frame(game_state)
end

#set_max_reputation(cl_max_reputation) ⇒ Object



20
21
22
23
# File 'lib/game_state.rb', line 20

def set_max_reputation(cl_max_reputation)
  @@max_reputation = cl_max_reputation
  @@current_reputation = @@max_reputation
end

#set_target_money(cl_target_money) ⇒ Object



16
17
18
# File 'lib/game_state.rb', line 16

def set_target_money(cl_target_money)
  @@target_money = cl_target_money
end