Class: Australium::Game

Inherits:
Object
  • Object
show all
Defined in:
lib/australium/game.rb

Overview

Represents a full game of TF2, comprised of individual Events.

Instance Attribute Summary collapse

Event filters collapse

Instance Method Summary collapse

Constructor Details

#initialize(events) ⇒ Game

Returns a new instance of Game.

Parameters:

  • events (Array<Events>)

    events that took place during the game



24
25
26
# File 'lib/australium/game.rb', line 24

def initialize(events)
  @events = events
end

Instance Attribute Details

#eventsObject (readonly)

Returns the value of attribute events.



21
22
23
# File 'lib/australium/game.rb', line 21

def events
  @events
end

Instance Method Details

#chat_messagesArray<PlayerSay>

Returns all PlayerSay events.

Returns:



51
# File 'lib/australium/game.rb', line 51

event_selector :chat_messages, PlayerSay

#connectsArray<PlayerConnect>

Returns all PlayerConnect events.

Returns:



45
# File 'lib/australium/game.rb', line 45

event_selector :connects,      PlayerConnect

#disconnectsArray<PlayerDisconnect>

Returns all PlayerDisconnect events.

Returns:



46
# File 'lib/australium/game.rb', line 46

event_selector :disconnects,   PlayerDisconnect

#inspectString

Hide instance variables from #inspect to prevent clutter on interactive terminals.

Returns:

  • (String)


58
# File 'lib/australium/game.rb', line 58

def inspect ; self.to_s end

#killsArray<PlayerKill>

Returns all PlayerKill events.

Returns:



49
# File 'lib/australium/game.rb', line 49

event_selector :kills,         PlayerKill

#map_nameString

Returns the name of the map that was played.

Returns:

  • (String)

    map name



40
41
42
# File 'lib/australium/game.rb', line 40

def map_name
  @events.select { |e| e.is_a?(MapStart) }.last.map_name
end

#name_changesArray<PlayerNameChange>

Returns all PlayerNameChange events.

Returns:



50
# File 'lib/australium/game.rb', line 50

event_selector :name_changes,  PlayerNameChange

#playersArray<Player>

Returns an array of all Players who connected to the server during this game. Caches the return value after the first call.

Returns:

  • (Array<Player>)

    players who participated in the game



31
32
33
34
35
36
# File 'lib/australium/game.rb', line 31

def players
  @players ||= @events.reverse.each_with_object([]) do |event, all_players|
    break all_players if event.state.nil? || event.state.players.nil?
    all_players.concat event.state.players.reject { |p| all_players.include?(p) }
  end
end

#role_changesArray<PlayerRoleChange>

Returns all PlayerRoleChange events.

Returns:



47
# File 'lib/australium/game.rb', line 47

event_selector :role_changes,  PlayerRoleChange

#suicidesArray<PlayerSuicide>

Returns all PlayerSuicide events.

Returns:



52
# File 'lib/australium/game.rb', line 52

event_selector :suicides,      PlayerSuicide

#team_joinsArray<PlayerJoinTeam>

Returns all PlayerJoinTeam events.

Returns:



48
# File 'lib/australium/game.rb', line 48

event_selector :team_joins,    PlayerJoinTeam

#triggersArray<Trigger>

Returns all Trigger events.

Returns:



53
# File 'lib/australium/game.rb', line 53

event_selector :triggers,      Trigger