Class: Sc2::Player::Enemy
- Inherits:
-
Sc2::Player
- Object
- Sc2::Player
- Sc2::Player::Enemy
- Includes:
- Units
- Defined in:
- lib/sc2ai/player.rb
Overview
A specialized type of player instance which each player has one of This should never be initialized by hand
Constant Summary
Constants inherited from Sc2::Player
Instance Attribute Summary
Attributes included from Units
#all_seen_unit_tags, #all_units, #effects, #event_units_damaged, #event_units_destroyed, #neutral, #placeholders, #power_sources, #radar_rings, #structures, #units, #upgrades_completed
Attributes inherited from Sc2::Player
#IDENTIFIED_RACES, #ai_build, #api, #difficulty, #enable_feature_layer, #interface_options, #name, #opponent_id, #race, #realtime, #step_count, #type
Attributes included from GameState
#chats_received, #data, #game_info, #game_info_loop, #game_loop, #observation, #result, #spent_minerals, #spent_supply, #spent_vespene, #status
Class Method Summary collapse
-
.from_proto(player_info: nil) ⇒ Sc2::Player::Enemy
Creates an Enemy object after game has started using Api::GameInfo’s Api::PlayerInfo.
Instance Method Summary collapse
-
#detect_race_from_units ⇒ false, Integer
Will attempt to loop over player units and set its race if it can detect.
Methods included from Units
#ability_data, #can_afford?, #can_afford_upgrade?, #subtract_cost, #unit_ability_available?, #unit_data, #unit_group_from_tags, #unit_has_attribute?, #units_in_progress, #upgrade_completed?, #upgrade_data, #upgrade_in_progress?, #upgrades_in_progress
Methods inherited from Sc2::Player
#connect, #create_game, #disconnect, #initialize, #join_game, #leave_game, #race_unknown?, #refresh_game_info, #requires_client?
Methods included from GameState
#available_abilities, #common, #game_info_stale?, #on_status_change
Methods included from Connection::StatusListener
Constructor Details
This class inherits a constructor from Sc2::Player
Class Method Details
.from_proto(player_info: nil) ⇒ Sc2::Player::Enemy
Creates an Enemy object after game has started using Api::GameInfo’s Api::PlayerInfo
394 395 396 397 398 399 400 |
# File 'lib/sc2ai/player.rb', line 394 def from_proto(player_info: nil) Sc2::Player::Enemy.new(race: player_info.race_requested, name: player_info.player_name, type: player_info.type, difficulty: player_info.difficulty, ai_build: player_info.ai_build) end |
Instance Method Details
#detect_race_from_units ⇒ false, Integer
Will attempt to loop over player units and set its race if it can detect. Generally only used for enemy
406 407 408 409 410 411 412 413 |
# File 'lib/sc2ai/player.rb', line 406 def detect_race_from_units return false unless race_unknown? return false if units.nil? unit_race = Api::Race.resolve(units.first.unit_data.race) if Sc2::Player::IDENTIFIED_RACES.include?(unit_race) self.race = unit_race end end |