Class: Sc2::Cli
- Inherits:
-
Thor
- Object
- Thor
- Sc2::Cli
- Defined in:
- lib/sc2ai/cli/cli.rb,
lib/sc2ai/cli/new.rb,
lib/sc2ai/cli/ladderzip.rb,
lib/sc2ai/cli/versus_bot.rb
Overview
Command line utilities
Defined Under Namespace
Classes: Ladderzip, New, VersusBot
Class Method Summary collapse
Instance Method Summary collapse
- #ladderconfig ⇒ Object
- #laddermatch ⇒ Object
-
#setup410 ⇒ Object
downloads and install SC2 v4.10.
Class Method Details
.exit_on_failure? ⇒ Boolean
13 14 15 |
# File 'lib/sc2ai/cli/cli.rb', line 13 def exit_on_failure? true end |
Instance Method Details
#ladderconfig ⇒ Object
86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 |
# File 'lib/sc2ai/cli/cli.rb', line 86 def ladderconfig require "sc2ai" unless Pathname("./boot.rb").exist? raise Sc2::Error, "boot.rb not found. Bot started from wrong directory." end require "./boot" # Debug Sc2.logger.info "Bot class: #{$bot.class}" Sc2.logger.info "Config:" Sc2.logger.info " in-game name: #{$bot.name}" Sc2.logger.info " race: #{Api::Race.lookup($bot.race)}" Sc2.logger.info " realtime: #{$bot.realtime}" Sc2.logger.info " step_count: #{$bot.step_count}" Sc2.logger.info " enable_feature_layer: #{$bot.enable_feature_layer}" Sc2.logger.info " interface_options: #{$bot.}" end |
#laddermatch ⇒ Object
110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 |
# File 'lib/sc2ai/cli/cli.rb', line 110 def laddermatch require "sc2ai" unless Sc2.ladder? raise Sc2::Error, "This command is only for competing on aiarena.net" end unless Pathname("./boot.rb").exist? raise Sc2::Error, "boot.rb not found. Bot started from wrong directory." end Sc2.logger.level = :info require "./boot" # Ladder specific overrides $bot.realtime = true if [:RealTime] $bot.opponent_id = [:OpponentId] if [:OpponentId] Async do $bot.connect(host: [:LadderServer], port: [:GamePort]) $bot.join_game( server_host: [:LadderServer], port_config: Sc2::Ports.port_config_basic(start_port: [:StartPort], num_players: 2) ) $bot.add_listener($bot, klass: Sc2::Connection::StatusListener) $bot.play end.wait end |
#setup410 ⇒ Object
downloads and install SC2 v4.10
25 26 27 28 29 30 31 32 33 34 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 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 |
# File 'lib/sc2ai/cli/cli.rb', line 25 def setup410 require "sc2ai" Async do Sc2.logger.level = :fatal say " " say "This script sets up SC2 at version 4.10, which we use competitively." say "SC2 will launch a blank window, be unresponsive, but download about 100mb in the background." say "" say "It will appear to hang as it updates. This is normal." say "Let it finish and close itself." say "Press any key to continue..." ask "" say "" say "" say "This will only take a minute..." Sc2.config.version = nil client = Sc2::ClientManager.obtain(0) if Gem.win_platform? sleep(10) end observer = Sc2::Player::Observer.new observer.connect(host: client.host, port: client.port) setup_replay = Sc2::Paths.gem_root.join("data", "setup", "setup.SC2Replay") observer.api.replay_info( replay_data: File.binread(setup_replay), download_data: true ) # Auto-detect executable path and ensure it matched exactly base_build = "75689" path = Sc2::Paths.executable(base_build: base_build) if path.include?(base_build) && Pathname(path).exist? say " " say "Success. Download complete.", :green say " " else say "Error. Slightly worrying, but no fear.", :red say "To manually setup, grab the latest ladder maps and add them to your map folder." say "Grab the latest maps from https://aiarena.net/wiki/maps/" say "Detected map folder: #{Sc2::Paths.maps_dir}" say "Then, download any recent replay from https://aiarena.net/ and double click to launch" end observer.api.quit observer.disconnect say "Generating sc2ai.yml to always use 4.10..." Sc2.config.config_file.write({"version" => "4.10"}.to_yaml.to_s) say "" say "Done. You're good to go." say "To run an example match, execute:" say "" say "ruby run_example_match.rb", :green say "" ensure Sc2::ClientManager.stop(0) end end |