Class: MapRotation
- Inherits:
-
Object
- Object
- MapRotation
- Defined in:
- lib/map_rotation/map_rotation.rb
Class Attribute Summary collapse
-
.default_cfg ⇒ Object
Returns the value of attribute default_cfg.
Instance Method Summary collapse
Class Attribute Details
.default_cfg ⇒ Object
Returns the value of attribute default_cfg.
30 31 32 |
# File 'lib/map_rotation/map_rotation.rb', line 30 def default_cfg @default_cfg end |
Instance Method Details
#run ⇒ Object
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/map_rotation/map_rotation.rb', line 35 def run # Load config cfg = MapRotation.default_cfg.merge begin fn = CONFIG_FN if File.exists?(fn) && (h = YAML::load_file(fn)) h else {} end end cfg["verbose"] = true if ARGV.delete("--verbose") || ARGV.delete("-v") cfg["targetFile"] ||= DEFAULT_TARGET if ARGV.delete("--dump-config") puts cfg.to_yaml exit 0 end results = cfg["tiers"].map do |t| t["maps"].shuffle.take(t["choose"].to_i) end results.shuffle! File.open(cfg["targetFile"], 'w') do |f| results.each do |r| f.puts r puts r if cfg["verbose"] end end exit 0 end |