tclog 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- data/README.mkd +0 -2
- data/VERSION +1 -1
- data/lib/tclog.rb +70 -19
- data/tclog.gemspec +2 -2
- metadata +3 -3
data/README.mkd
CHANGED
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.1
|
data/lib/tclog.rb
CHANGED
@@ -1,6 +1,13 @@
|
|
1
|
+
# = TCLog
|
2
|
+
# Author:: Shota Fukumori (sora_h)
|
3
|
+
# Copyright:: (c) Shota Fukumori (sora_h) 2010- w/ mit license
|
4
|
+
# License:: MIT License; License terms written in README.mkd
|
5
|
+
#
|
6
|
+
# This library helps TC:E stats parsing.
|
7
|
+
#
|
1
8
|
module TCLog
|
2
9
|
class Game
|
3
|
-
def initialize(orders = [], gametype = :obj)
|
10
|
+
def initialize(orders = [], gametype = :obj) # :nodoc:
|
4
11
|
@orders = orders
|
5
12
|
@gametype = gametype
|
6
13
|
@rounds = []
|
@@ -23,12 +30,12 @@ module TCLog
|
|
23
30
|
end
|
24
31
|
|
25
32
|
|
26
|
-
def add_map(map_name)
|
33
|
+
def add_map(map_name) # :nodoc:
|
27
34
|
@round_r += 1
|
28
35
|
@rounds << Round.new(self, nil, @round_r, :map, true, map_name); self
|
29
36
|
end
|
30
37
|
|
31
|
-
def add_round(specops,terrorists,won)
|
38
|
+
def add_round(specops,terrorists,won) # :nodoc:
|
32
39
|
@round_n += 1
|
33
40
|
@round_r += 1
|
34
41
|
r = Round.new(self, @round_n, @round_r, won)
|
@@ -38,7 +45,7 @@ module TCLog
|
|
38
45
|
self
|
39
46
|
end
|
40
47
|
|
41
|
-
def add_player(name)
|
48
|
+
def add_player(name) # :nodoc:
|
42
49
|
@players[name] = Player.new(name)
|
43
50
|
if 0 <= @round_r
|
44
51
|
@players[name].push_result(@round_r)
|
@@ -47,12 +54,26 @@ module TCLog
|
|
47
54
|
end
|
48
55
|
|
49
56
|
|
50
|
-
def round; @round_n; end
|
57
|
+
def round; @round_n; end # :nodoc:
|
58
|
+
attr_reader :round_r # :nodoc:
|
59
|
+
|
60
|
+
# Has same mean as game.rounds[i]
|
51
61
|
def [](i); @rounds[i]; end
|
52
|
-
|
62
|
+
|
63
|
+
# Logged rounds.
|
64
|
+
attr_reader :rounds
|
65
|
+
|
66
|
+
# All players.
|
67
|
+
attr_reader :players
|
68
|
+
|
69
|
+
# Parser VM call stacks.
|
70
|
+
attr_reader :orders
|
71
|
+
|
72
|
+
# Gametype. obj, bc, ctf.
|
73
|
+
attr_reader :gametype
|
53
74
|
end
|
54
75
|
class Round
|
55
|
-
def initialize(game, n, rn, win, map_changing = false, map_name = nil)
|
76
|
+
def initialize(game, n, rn, win, map_changing = false, map_name = nil) # :nodoc
|
56
77
|
@game = game
|
57
78
|
@won = win
|
58
79
|
@round_number = n
|
@@ -63,33 +84,52 @@ module TCLog
|
|
63
84
|
@map_name = map_name
|
64
85
|
end
|
65
86
|
|
87
|
+
|
88
|
+
# Players which joined at this round.
|
66
89
|
def players
|
67
90
|
@game.players.map do |g|
|
68
91
|
g if @round_number && g.results[@real_round_number]
|
69
92
|
end.compact
|
70
93
|
end
|
71
94
|
|
95
|
+
# Players result which joined at this round.
|
72
96
|
def player_results
|
73
97
|
@game.players.map do |g|
|
74
98
|
g.results[@real_round_number] if @round_number
|
75
99
|
end.compact
|
76
100
|
end
|
77
101
|
|
102
|
+
# Is this round changing map?
|
78
103
|
def map_changing?; @map_changing; end
|
79
|
-
|
80
|
-
|
104
|
+
|
105
|
+
def map_changing=(x); @map_changing = x; end # :nodoc:
|
106
|
+
|
107
|
+
# Next map name if this round changing map.
|
108
|
+
attr_accessor :map_name
|
109
|
+
|
110
|
+
# specops total scores.
|
111
|
+
attr_accessor :specops
|
112
|
+
|
113
|
+
# terrorists total scores.
|
114
|
+
attr_accessor :terrorists
|
115
|
+
|
116
|
+
# Team which won this round.
|
117
|
+
attr_accessor :won
|
118
|
+
|
119
|
+
# Round number at game. (Counted without map changing)
|
81
120
|
attr_reader :round_number
|
82
121
|
end
|
83
122
|
class Player
|
84
|
-
def initialize(name)
|
123
|
+
def initialize(name) # :nodoc:
|
85
124
|
@name = name
|
86
125
|
@results = []
|
87
126
|
end
|
88
127
|
|
89
|
-
def add_result(n, score)
|
128
|
+
def add_result(n, score) # :nodoc:
|
90
129
|
@results[n] = score.merge(:round => n); self
|
91
130
|
end
|
92
131
|
|
132
|
+
# Returns this player's total score.
|
93
133
|
def total
|
94
134
|
a = @results.compact.inject({
|
95
135
|
:name => @name,
|
@@ -114,18 +154,29 @@ module TCLog
|
|
114
154
|
a
|
115
155
|
end
|
116
156
|
|
117
|
-
def push_result(i)
|
157
|
+
def push_result(i) # :nodoc:
|
118
158
|
@results[i] = nil
|
119
159
|
end
|
120
|
-
|
160
|
+
|
161
|
+
# This player's name.
|
162
|
+
attr_reader :name
|
163
|
+
|
164
|
+
# This player's round results.
|
165
|
+
# Use compact method to use Round#round_number.
|
166
|
+
attr_reader :results
|
121
167
|
end
|
122
168
|
|
123
|
-
|
124
|
-
#
|
169
|
+
|
170
|
+
# [logfile]
|
171
|
+
# String or IO. String is filename.
|
172
|
+
#
|
173
|
+
# [gametype]
|
174
|
+
# :obj => "Objective"
|
175
|
+
# :ctf => "Capture The Flag"
|
176
|
+
# :bc => "BodyCount"
|
125
177
|
#
|
126
|
-
#
|
127
|
-
#
|
128
|
-
# :bc => "BodyCount"
|
178
|
+
# Parses TC:E etconsole.log.
|
179
|
+
# You can catch etconsole.log by /set logfile 2 at tc:e console.
|
129
180
|
def self.analyze(logfile, gametype = :obj)
|
130
181
|
# Load file
|
131
182
|
log = case logfile
|
@@ -277,7 +328,7 @@ module TCLog
|
|
277
328
|
game
|
278
329
|
end
|
279
330
|
|
280
|
-
def self.compare_score(terrorists, specops)
|
331
|
+
def self.compare_score(terrorists, specops) # :nodoc:
|
281
332
|
if terrorists[:score] > specops[:score]
|
282
333
|
:terrorists
|
283
334
|
else
|
data/tclog.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{tclog}
|
8
|
-
s.version = "0.1.
|
8
|
+
s.version = "0.1.1"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Shota Fukumori"]
|
12
|
-
s.date = %q{2010-12-
|
12
|
+
s.date = %q{2010-12-25}
|
13
13
|
s.description = %q{Parser for etconsole.log of TrueCombat:Elite (TC:E)}
|
14
14
|
s.email = %q{sorah@tubusu.net}
|
15
15
|
s.extra_rdoc_files = [
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 1
|
8
|
-
-
|
9
|
-
version: 0.1.
|
8
|
+
- 1
|
9
|
+
version: 0.1.1
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Shota Fukumori
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2010-12-
|
17
|
+
date: 2010-12-25 00:00:00 +09:00
|
18
18
|
default_executable:
|
19
19
|
dependencies: []
|
20
20
|
|