Class: SplendorGame::Options
Constant Summary collapse
- NOBLES_AVAILABLE =
{ 2 => 3, 3 => 4, 4 => 5}
- STARTING_GOLD_TOKENS =
5
- STARTING_NON_GOLD_TOKENS =
{ 2 => 4, 3 => 5, 4 => 7}
- DISPLAY_CARDS_PER_ROW =
4
- WINNING_SCORE =
15
- MIN_TO_TAKE_TWO =
4
- PLAYER_TOKEN_LIMIT =
10
Instance Attribute Summary collapse
-
#bank ⇒ Object
readonly
Returns the value of attribute bank.
-
#deck ⇒ Object
readonly
Returns the value of attribute deck.
-
#display ⇒ Object
readonly
Returns the value of attribute display.
-
#nobles ⇒ Object
readonly
Returns the value of attribute nobles.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
-
#players ⇒ Object
readonly
Returns the value of attribute players.
Instance Method Summary collapse
- #clean_user_options ⇒ Object
- #default_options ⇒ Object
-
#give_options ⇒ Object
Take the user values if they are valid, else use defaults.
-
#initialize(user_options = nil) ⇒ Options
constructor
A new instance of Options.
Constructor Details
#initialize(user_options = nil) ⇒ Options
Returns a new instance of Options.
12 13 14 15 16 17 18 |
# File 'lib/splendor_game/options.rb', line 12 def initialize( = nil) if .is_a?(Hash) @user_options = else @user_options = Hash.new() end end |
Instance Attribute Details
#bank ⇒ Object (readonly)
Returns the value of attribute bank.
11 12 13 |
# File 'lib/splendor_game/options.rb', line 11 def bank @bank end |
#deck ⇒ Object (readonly)
Returns the value of attribute deck.
11 12 13 |
# File 'lib/splendor_game/options.rb', line 11 def deck @deck end |
#display ⇒ Object (readonly)
Returns the value of attribute display.
11 12 13 |
# File 'lib/splendor_game/options.rb', line 11 def display @display end |
#nobles ⇒ Object (readonly)
Returns the value of attribute nobles.
11 12 13 |
# File 'lib/splendor_game/options.rb', line 11 def nobles @nobles end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
11 12 13 |
# File 'lib/splendor_game/options.rb', line 11 def @options end |
#players ⇒ Object (readonly)
Returns the value of attribute players.
11 12 13 |
# File 'lib/splendor_game/options.rb', line 11 def players @players end |
Instance Method Details
#clean_user_options ⇒ Object
20 21 22 23 24 25 26 |
# File 'lib/splendor_game/options.rb', line 20 def [:starting_non_gold_tokens, :nobles_available].each do |key| if @user_options[key].respond_to?(:keys) @user_options.delete(key) if !([2,3,4] - @user_options[key].keys).empty? end end end |
#default_options ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/splendor_game/options.rb', line 28 def output = Hash.new() output[:display_cards_per_row] = DISPLAY_CARDS_PER_ROW output[:winning_score] = WINNING_SCORE output[:min_to_take_two] = MIN_TO_TAKE_TWO output[:starting_gold_tokens] = STARTING_GOLD_TOKENS output[:starting_non_gold_tokens] = STARTING_NON_GOLD_TOKENS output[:nobles_available] = NOBLES_AVAILABLE output[:player_token_limit] = PLAYER_TOKEN_LIMIT output end |
#give_options ⇒ Object
Take the user values if they are valid, else use defaults
41 42 43 44 |
# File 'lib/splendor_game/options.rb', line 41 def @user_options.merge() end |