Class: Sc2::PortConfig
- Inherits:
-
Object
- Object
- Sc2::PortConfig
- Defined in:
- lib/sc2ai/ports.rb
Overview
A port configuration for a Match which allows generating Api::PortSet
Instance Attribute Summary collapse
-
#client_port_sets ⇒ Object
Returns the value of attribute client_port_sets.
-
#server_port_set ⇒ Object
Returns the value of attribute server_port_set.
-
#start_port ⇒ Object
Returns the value of attribute start_port.
Instance Method Summary collapse
-
#initialize(start_port:, num_players:, ports: []) ⇒ PortConfig
constructor
A new instance of PortConfig.
Constructor Details
#initialize(start_port:, num_players:, ports: []) ⇒ PortConfig
Returns a new instance of PortConfig.
147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 |
# File 'lib/sc2ai/ports.rb', line 147 def initialize(start_port:, num_players:, ports: []) @start_port = start_port @server_port_set = nil @client_port_sets = [] return if num_players <= 1 return if ports.empty? @server_port_set = Api::PortSet.new(game_port: ports.shift, base_port: ports.shift) @client_port_sets = [] (num_players - 1).times do @client_port_sets << Api::PortSet.new(game_port: ports.shift, base_port: ports.shift) end end |
Instance Attribute Details
#client_port_sets ⇒ Object
Returns the value of attribute client_port_sets.
142 143 144 |
# File 'lib/sc2ai/ports.rb', line 142 def client_port_sets @client_port_sets end |
#server_port_set ⇒ Object
Returns the value of attribute server_port_set.
139 140 141 |
# File 'lib/sc2ai/ports.rb', line 139 def server_port_set @server_port_set end |
#start_port ⇒ Object
Returns the value of attribute start_port.
136 137 138 |
# File 'lib/sc2ai/ports.rb', line 136 def start_port @start_port end |