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
readonly
Returns the value of attribute client_port_sets.
-
#server_port_set ⇒ Object
readonly
Returns the value of attribute server_port_set.
-
#start_port ⇒ Object
readonly
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.
135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 |
# File 'lib/sc2ai/ports.rb', line 135 def initialize(start_port:, num_players:, ports: []) @start_port = start_port @server_port_set = nil @client_port_sets = nil 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 (readonly)
Returns the value of attribute client_port_sets.
133 134 135 |
# File 'lib/sc2ai/ports.rb', line 133 def client_port_sets @client_port_sets end |
#server_port_set ⇒ Object (readonly)
Returns the value of attribute server_port_set.
133 134 135 |
# File 'lib/sc2ai/ports.rb', line 133 def server_port_set @server_port_set end |
#start_port ⇒ Object (readonly)
Returns the value of attribute start_port.
133 134 135 |
# File 'lib/sc2ai/ports.rb', line 133 def start_port @start_port end |