Class: AlienSwarmMission

Inherits:
Object
  • Object
show all
Defined in:
lib/steam/community/alien_swarm/alien_swarm_mission.rb

Overview

This class holds statistical information about missions played by a player in Alien Swarm

Author:

  • Sebastian Staudt

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(map_name, mission_data) ⇒ AlienSwarmMission

Creates a new mission instance of based on the given XML data

Parameters:

  • map_name (String)

    The name of the mission’s map

  • mission_data (Hash<String, Object>)

    The data representing this mission



94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
# File 'lib/steam/community/alien_swarm/alien_swarm_mission.rb', line 94

def initialize(map_name, mission_data)
  @avg_damage_taken       = mission_data['damagetakenavg'].to_f
  @avg_friendly_fire      = mission_data['friendlyfireavg'].to_f
  @avg_kills              = mission_data['killsavg'].to_f
  @best_difficulty        = mission_data['bestdifficulty']
  @damage_taken           = mission_data['damagetaken'].to_i
  @friendly_fire          = mission_data['friendlyfire'].to_i
  @games_successful       = mission_data['gamessuccess'].to_i
  @img                    = AlienSwarmStats::BASE_URL + mission_data['image']
  @kills                  = mission_data['kills'].to_i
  @map_name               = map_name
  @name                   = mission_data['name']
  @total_games            = mission_data['gamestotal'].to_i
  @total_games_percentage = mission_data['gamestotalpct'].to_f

  @time = {
    :average => mission_data['avgtime'],
    :brutal  => mission_data['brutaltime'],
    :easy    => mission_data['easytime'],
    :hard    => mission_data['hardtime'],
    :insane  => mission_data['insanetime'],
    :normal  => mission_data['normaltime'],
    :total   => mission_data['totaltime']
  }
end

Instance Attribute Details

#avg_damage_takenFloat (readonly)

Returns the avarage damage taken by the player while playing a round in this mission

Returns:

  • (Float)

    The average damage taken by the player



16
17
18
# File 'lib/steam/community/alien_swarm/alien_swarm_mission.rb', line 16

def avg_damage_taken
  @avg_damage_taken
end

#avg_friendly_fireFloat (readonly)

Returns the avarage damage dealt by the player to team mates while playing a round in this mission

Returns:

  • (Float)

    The average damage dealt by the player to team mates



22
23
24
# File 'lib/steam/community/alien_swarm/alien_swarm_mission.rb', line 22

def avg_friendly_fire
  @avg_friendly_fire
end

#avg_killsFloat (readonly)

Returns the avarage number of aliens killed by the player while playing a round in this mission

Returns:

  • (Float)

    The avarage number of aliens killed by the player



28
29
30
# File 'lib/steam/community/alien_swarm/alien_swarm_mission.rb', line 28

def avg_kills
  @avg_kills
end

#best_difficultyString (readonly)

Returns the highest difficulty the player has beat this mission in

Returns:

  • (String)

    The highest difficulty the player has beat this mission in



33
34
35
# File 'lib/steam/community/alien_swarm/alien_swarm_mission.rb', line 33

def best_difficulty
  @best_difficulty
end

#damage_takenFixnum (readonly)

Returns the total damage taken by the player in this mission

Returns:

  • (Fixnum)

    The total damage taken by the player



38
39
40
# File 'lib/steam/community/alien_swarm/alien_swarm_mission.rb', line 38

def damage_taken
  @damage_taken
end

#friendly_fireFixnum (readonly)

Returns the total damage dealt by the player to team mates in this mission

Returns:

  • (Fixnum)

    The total damage dealt by the player to team mates



43
44
45
# File 'lib/steam/community/alien_swarm/alien_swarm_mission.rb', line 43

def friendly_fire
  @friendly_fire
end

#games_successfulFixnum (readonly)

Returns the number of successful rounds the player played in this mission

Returns:

  • (Fixnum)

    The number of successful rounds of this mission



48
49
50
# File 'lib/steam/community/alien_swarm/alien_swarm_mission.rb', line 48

def games_successful
  @games_successful
end

#imgString (readonly)

Returns the URL to a image displaying the mission

Returns:

  • (String)

    The URL of the mission’s image



53
54
55
# File 'lib/steam/community/alien_swarm/alien_swarm_mission.rb', line 53

def img
  @img
end

#killsFixnum (readonly)

Returns the total number of aliens killed by the player in this mission

Returns:

  • (Fixnum)

    The total number of aliens killed by the player



58
59
60
# File 'lib/steam/community/alien_swarm/alien_swarm_mission.rb', line 58

def kills
  @kills
end

#map_nameString (readonly)

Returns the file name of the mission’s map

Returns:

  • (String)

    The file name of the mission’s map



63
64
65
# File 'lib/steam/community/alien_swarm/alien_swarm_mission.rb', line 63

def map_name
  @map_name
end

#nameString (readonly)

Returns the name of the mission

Returns:

  • (String)

    The name of the mission



68
69
70
# File 'lib/steam/community/alien_swarm/alien_swarm_mission.rb', line 68

def name
  @name
end

#timeHash<Symbol, String> (readonly)

Returns various statistics about the times needed to accomplish this mission

This includes the best times for each difficulty, the average time and the total time spent in this mission.

Returns:

  • (Hash<Symbol, String>)

    Various time statistics about this mission



77
78
79
# File 'lib/steam/community/alien_swarm/alien_swarm_mission.rb', line 77

def time
  @time
end

#total_gamesFixnum (readonly)

Returns the number of games played in this mission

Returns:

  • (Fixnum)

    The number of games played in this mission



82
83
84
# File 'lib/steam/community/alien_swarm/alien_swarm_mission.rb', line 82

def total_games
  @total_games
end

#total_games_percentageFloat (readonly)

Returns the percentage of successful games played in this mission

Returns:

  • (Float)

    The percentage of successful games played in this mission



87
88
89
# File 'lib/steam/community/alien_swarm/alien_swarm_mission.rb', line 87

def total_games_percentage
  @total_games_percentage
end