urbanterror 0.4 → 0.5
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/urbanterror.rb +26 -54
- metadata +3 -3
data/lib/urbanterror.rb
CHANGED
@@ -52,65 +52,37 @@ class UrbanTerror
|
|
52
52
|
end
|
53
53
|
end
|
54
54
|
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
'pistols' => 8,
|
64
|
-
'autos' => 16,
|
65
|
-
'negev' => 32
|
66
|
-
}
|
67
|
-
|
68
|
-
gearArray.each do |w|
|
69
|
-
if gearMaster.has_key? w
|
70
|
-
selected << gearMaster[w]
|
71
|
-
end
|
72
|
-
end
|
55
|
+
GEAR_TYPES = {
|
56
|
+
'grenades' => 1,
|
57
|
+
'snipers' => 2,
|
58
|
+
'spas' => 4,
|
59
|
+
'pistols' => 8,
|
60
|
+
'autos' => 16,
|
61
|
+
'negev' => 32
|
62
|
+
}
|
73
63
|
|
74
|
-
|
75
|
-
|
64
|
+
MAX_GEAR = 63
|
65
|
+
|
66
|
+
def self.gearCalc(gearArray)
|
67
|
+
MAX_GEAR - gearArray.select{|w| GEAR_TYPES.has_key? w }.map{|w| GEAR_TYPES[w] }.reduce(:+)
|
76
68
|
end
|
77
69
|
|
78
70
|
def self.reverseGearCalc(number)
|
79
|
-
|
80
|
-
gearMaster = {
|
81
|
-
1 => 'grenades',
|
82
|
-
2 => 'snipers',
|
83
|
-
4 => 'spas',
|
84
|
-
8 => 'pistols',
|
85
|
-
16 => 'autos',
|
86
|
-
32 => 'negev'
|
87
|
-
}
|
88
|
-
|
89
|
-
gearMaster.each do |num, weapon|
|
90
|
-
if number & num == 0
|
91
|
-
weapons << weapon
|
92
|
-
end
|
93
|
-
end
|
94
|
-
return weapons
|
71
|
+
GEAR_TYPES.select{|weapon, gear_val| number & gear_val == 0 }.map(&:first)
|
95
72
|
end
|
73
|
+
|
74
|
+
GAME_MODES = {
|
75
|
+
0 => ['Free For All', 'FFA'],
|
76
|
+
3 => ['Team Death Match', 'TDM'],
|
77
|
+
4 => ['Team Survivor', 'TS'],
|
78
|
+
5 => ['Follow the Leader', 'FTL'],
|
79
|
+
6 => ['Capture and Hold', 'CAH'],
|
80
|
+
7 => ['Capture the Flag', 'CTF'],
|
81
|
+
8 => ['Bomb mode', 'BOMB']
|
82
|
+
}
|
96
83
|
|
97
84
|
def self.matchType(number, abbreviate=false)
|
98
|
-
#
|
99
|
-
match
|
100
|
-
0 => ['Free For All', 'FFA'],
|
101
|
-
3 => ['Team Death Match', 'TDM'],
|
102
|
-
4 => ['Team Survivor', 'TS'],
|
103
|
-
5 => ['Follow the Leader', 'FTL'],
|
104
|
-
6 => ['Capture and Hold', 'CAH'],
|
105
|
-
7 => ['Capture the Flag', 'CTF'],
|
106
|
-
8 => ['Bomb mode', 'BOMB']
|
107
|
-
}
|
108
|
-
|
109
|
-
throw "#{number} is not a valid gametype." if not match.has_key? number
|
110
|
-
if abbreviate
|
111
|
-
match[number][1]
|
112
|
-
else
|
113
|
-
match[number][0]
|
114
|
-
end
|
85
|
+
raise "#{number} is not a valid gametype." unless GAME_MODES.has_key? number
|
86
|
+
match[number][abbreviate ? 1 : 0]
|
115
87
|
end
|
116
|
-
end
|
88
|
+
end
|
metadata
CHANGED