class SplendorGame::Options
Constants
- DISPLAY_CARDS_PER_ROW
- MIN_TO_TAKE_TWO
- NOBLES_AVAILABLE
- PLAYER_TOKEN_LIMIT
- STARTING_GOLD_TOKENS
- STARTING_NON_GOLD_TOKENS
- WINNING_SCORE
Attributes
bank[R]
deck[R]
display[R]
nobles[R]
options[R]
players[R]
Public Class Methods
new(user_options = nil)
click to toggle source
# File lib/splendor_game/options.rb, line 12 def initialize(user_options = nil) if user_options.is_a?(Hash) @user_options = user_options else @user_options = Hash.new() end end
Public Instance Methods
clean_user_options()
click to toggle source
# File lib/splendor_game/options.rb, line 20 def clean_user_options [: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()
click to toggle source
# File lib/splendor_game/options.rb, line 28 def default_options 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()
click to toggle source
Take the user values if they are valid, else use defaults
# File lib/splendor_game/options.rb, line 41 def give_options clean_user_options @user_options.merge(default_options) end