Class: RubyArmor::WarriorConfig

Inherits:
BaseUserData show all
Defined in:
lib/ruby_armor/warrior_config.rb

Constant Summary collapse

DEFAULT_CONFIG =
File.expand_path "../../../config/default_config.yml", __FILE__
OLD_CONFIG_FILE =
"ruby_armour.yml"
CONFIG_FILE =
"ruby_armor/config.yml"

Instance Method Summary collapse

Constructor Details

#initialize(profile) ⇒ WarriorConfig

Returns a new instance of WarriorConfig.



11
12
13
14
15
16
17
18
19
20
21
# File 'lib/ruby_armor/warrior_config.rb', line 11

def initialize(profile)
  # Originally, config file was just in the folder. Move into its own folder, so we can put more in there.
  old_config_file = File.join(profile.player_path, OLD_CONFIG_FILE)
  config_file = File.join(profile.player_path, CONFIG_FILE)
  if File.exists? old_config_file
    FileUtils.mkdir_p File.dirname(config_file)
    FileUtils.mv old_config_file, config_file
  end

  super config_file, DEFAULT_CONFIG
end

Instance Method Details

#turn_delayObject



23
# File 'lib/ruby_armor/warrior_config.rb', line 23

def turn_delay; data[:turn_delay]; end

#turn_delay=(delay) ⇒ Object



24
25
26
27
# File 'lib/ruby_armor/warrior_config.rb', line 24

def turn_delay=(delay)
  data[:turn_delay] = delay
  save
end

#warrior_classObject



29
# File 'lib/ruby_armor/warrior_config.rb', line 29

def warrior_class; data[:warrior_class]; end

#warrior_class=(warrior_class) ⇒ Object



30
31
32
33
# File 'lib/ruby_armor/warrior_config.rb', line 30

def warrior_class=(warrior_class)
  data[:warrior_class] = warrior_class
  save
end