CoC-Calc 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. checksums.yaml +7 -0
  2. data/lib/CoC-Calc.rb +277 -0
  3. metadata +45 -0
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 9b6f91f5cccf742958d38cbec043d0e2ef18250c
4
+ data.tar.gz: 7c50f2414670efa703bc5a59fc37b179dcc6de79
5
+ SHA512:
6
+ metadata.gz: ffdd285b90a027da91d85f1daecb502e203f9ea25c87dcdc3de6b2cc9e798a45da48b3457c717e85c129168af71d1ae57d56402976aef6456deed2c8d686a102
7
+ data.tar.gz: 5456c275740778cdbfe96ec576891a023199e41843c434e98cd65e8b542cf8ea061c547d3f177916541d1f45500de551e8aa6a5b37e86f9ebf1729fa42be793c
@@ -0,0 +1,277 @@
1
+ def init
2
+ if Dir.exists? "/CoC-Calc-Saves"
3
+ else
4
+ Dir.mkdir "/CoC-Calc-Saves"
5
+ end
6
+ if File.file? "/CoC-Calc-Saves/lvl.txt"
7
+ $lvlSaveContent = File.read("/CoC-Calc-Saves/lvl.txt")
8
+ else
9
+ $lvlSaveFile = File.new("/CoC-Calc-Saves/lvl.txt", "w")
10
+ $lvlSaveContent = ""
11
+ end
12
+
13
+ $lvls = $lvlSaveContent.split('||')
14
+ $lvls.each do |i|
15
+ i = i.to_i
16
+ end
17
+ end
18
+
19
+ def initPuts
20
+ if Dir.exists? "/CoC-Calc-Saves"
21
+ else
22
+ Dir.mkdir "/CoC-Calc-Saves"
23
+ end
24
+
25
+ if File.file? "/CoC-Calc-Saves/lvl.txt"
26
+ $lvlSaveContent = File.read("/CoC-Calc-Saves/lvl.txt")
27
+ else
28
+ $lvlSaveFile = File.new("/CoC-Calc-Saves/lvl.txt", "w")
29
+ puts "You need to enter the levels of your troops by running 'ruby CoC-Calc.rb set_troop_lvl' if you need futher help run 'ruby CoC-Calc.rb set_troop_lvl help'!"
30
+ $lvlSaveContent = ""
31
+ end
32
+
33
+ if $lvlSaveContent == ""
34
+ puts "You need to enter the levels of your troops by running 'ruby CoC-Calc.rb set_troop_lvl' if you need futher help run 'ruby CoC-Calc.rb set_troop_lvl help'!"
35
+ end
36
+
37
+ $lvls = $lvlSaveContent.split('||')
38
+ $lvls.each do |i|
39
+ i = i.to_i
40
+ end
41
+ end
42
+
43
+ def get_troop_cost
44
+
45
+ #Barbs
46
+ if $lvls[0].to_i == 1
47
+ $cost_barbarians = 25
48
+ elsif $lvls[0].to_i == 2
49
+ $cost_barbarians = 40
50
+ elsif $lvls[0].to_i == 3
51
+ $cost_barbarians = 60
52
+ elsif $lvls[0].to_i == 4
53
+ $cost_barbarians = 80
54
+ elsif $lvls[0].to_i == 5
55
+ $cost_barbarians = 100
56
+ elsif $lvls[0].to_i == 6
57
+ $cost_barbarians = 150
58
+ else
59
+ puts "Your barbarian lvl is invalid"
60
+ $troopLvlErr = true
61
+ end
62
+
63
+ #Archers
64
+ if $lvls[1].to_i == 1
65
+ $cost_archers = 50
66
+ elsif $lvls[1].to_i == 2
67
+ $cost_archers = 80
68
+ elsif $lvls[1].to_i == 3
69
+ $cost_archers = 120
70
+ elsif $lvls[1].to_i == 4
71
+ $cost_archers = 160
72
+ elsif $lvls[1].to_i == 5
73
+ $cost_archers = 200
74
+ elsif $lvls[1].to_i == 6
75
+ $cost_archers = 300
76
+ else
77
+ puts "Your archer lvl (#{$lvls[1]}) is invalid"
78
+ $troopLvlErr = true
79
+ end
80
+
81
+ #gobs
82
+ if $lvls[2].to_i == 1
83
+ $cost_goblins = 25
84
+ elsif $lvls[2].to_i == 2
85
+ $cost_goblins = 40
86
+ elsif $lvls[2].to_i == 3
87
+ $cost_goblins = 60
88
+ elsif $lvls[2].to_i == 4
89
+ $cost_goblins = 80
90
+ elsif $lvls[2].to_i == 5
91
+ $cost_goblins = 100
92
+ elsif $lvls[2].to_i == 6
93
+ $cost_goblins = 150
94
+ else
95
+ puts "Your goblin lvl is invalid"
96
+ $troopLvlErr = true
97
+ end
98
+
99
+ #giants
100
+ if $lvls[3].to_i == 1
101
+ $cost_giants = 500
102
+ elsif $lvls[3].to_i == 2
103
+ $cost_giants = 1000
104
+ elsif $lvls[3].to_i == 3
105
+ $cost_giants = 1500
106
+ elsif $lvls[3].to_i == 4
107
+ $cost_giants = 2000
108
+ elsif $lvls[3].to_i == 5
109
+ $cost_giants = 2500
110
+ elsif $lvls[3].to_i == 6
111
+ $cost_giants = 3000
112
+ else
113
+ puts "Your giant lvl is invalid"
114
+ $troopLvlErr = true
115
+ end
116
+
117
+ #wallies
118
+ if $lvls[4].to_i == 1
119
+ $cost_wallbreakers = 1000
120
+ elsif $lvls[4].to_i == 2
121
+ $cost_wallbreakers = 1500
122
+ elsif $lvls[4].to_i == 3
123
+ $cost_wallbreakers = 2000
124
+ elsif $lvls[4].to_i == 4
125
+ $cost_wallbreakers = 2500
126
+ elsif $lvls[4].to_i == 5
127
+ $cost_wallbreakers = 3000
128
+ elsif $lvls[4].to_i == 6
129
+ $cost_wallbreakers = 3500
130
+ else
131
+ puts "Your wallbreaker lvl is invalid"
132
+ $troopLvlErr = true
133
+ end
134
+
135
+ #ballons
136
+ if $lvls[5].to_i == 1
137
+ $cost_ballons = 2000
138
+ elsif $lvls[5].to_i == 2
139
+ $cost_ballons = 2500
140
+ elsif $lvls[5].to_i == 3
141
+ $cost_ballons = 3000
142
+ elsif $lvls[5].to_i == 4
143
+ $cost_ballons = 3500
144
+ elsif $lvls[5].to_i == 5
145
+ $cost_ballons = 4000
146
+ elsif $lvls[5].to_i == 6
147
+ $cost_ballons = 4500
148
+ else
149
+ puts "Your ballon lvl is invalid"
150
+ $troopLvlErr = true
151
+ end
152
+
153
+ #wizards
154
+ if $lvls[6].to_i == 1
155
+ $cost_wizards = 1500
156
+ elsif $lvls[6].to_i == 2
157
+ $cost_wizards = 2000
158
+ elsif $lvls[6].to_i == 3
159
+ $cost_wizards = 2500
160
+ elsif $lvls[6].to_i == 4
161
+ $cost_wizards = 3000
162
+ elsif $lvls[6].to_i == 5
163
+ $cost_wizards = 3500
164
+ elsif $lvls[6].to_i == 6
165
+ $cost_wizards = 4000
166
+ else
167
+ puts "Your wizard lvl is invalid"
168
+ $troopLvlErr = true
169
+ end
170
+
171
+ #healers
172
+ if $lvls[7].to_i == 1
173
+ $cost_healers = 5000
174
+ elsif $lvls[7].to_i == 2
175
+ $cost_healers = 6000
176
+ elsif $lvls[7].to_i == 3
177
+ $cost_healers = 8000
178
+ elsif $lvls[7].to_i == 4
179
+ $cost_healers = 10000
180
+ else
181
+ puts "Your healer lvl is invalid"
182
+ $troopLvlErr = true
183
+ end
184
+
185
+ #dragons
186
+ if $lvls[8].to_i == 1
187
+ $cost_dragons = 25000
188
+ elsif $lvls[8].to_i == 2
189
+ $cost_dragons = 30000
190
+ elsif $lvls[8].to_i == 3
191
+ $cost_dragons = 36000
192
+ elsif $lvls[8].to_i == 4
193
+ $cost_dragons = 42000
194
+ else
195
+ puts "Your dragon lvl is invalid"
196
+ $troopLvlErr = true
197
+ end
198
+
199
+ #pekkas
200
+ if $lvls[9].to_i == 1
201
+ $cost_pekkas = 30000
202
+ elsif $lvls[9].to_i == 2
203
+ $cost_pekkas = 35000
204
+ elsif $lvls[9].to_i == 3
205
+ $cost_pekkas = 42000
206
+ elsif $lvls[9].to_i == 4
207
+ $cost_pekkas = 45000
208
+ elsif $lvls[9].to_i == 5
209
+ $cost_pekkas = 50000
210
+ else
211
+ puts "Your pekka lvl is invalid"
212
+ $troopLvlErr = true
213
+ end
214
+
215
+ end
216
+
217
+ def set_troop_lvl
218
+ if ARGV[1].downcase == 'help'
219
+ puts "To save the lvl of your troop enter 'ruby CoC-Calc.rb set_troop_lvl [lvl of barbarians] [lvl of archers] [lvl of goblins] [lvl of giants] [lvl of wallbreakers] [lvl of ballons] [lvl of wizards] [lvl of healers] [lvl of dragons] [lvl of pekkas]'"
220
+ else
221
+ $lvls = [ARGV[1], ARGV[2], ARGV[3], ARGV[4], ARGV[5],ARGV[6], ARGV[7], ARGV[8], ARGV[9], ARGV[10]]
222
+ $lvlSaveFile = File.new("/CoC-Calc-Saves/lvl.txt", "w")
223
+ $lvlSaveFile.puts $lvls.join('||')
224
+ end
225
+ end
226
+
227
+ def calc
228
+ if ARGV[1].downcase == 'help'
229
+ puts 'Calc the training time and cost of your troops run "ruby CoC-Calc.rb calc [amount of barbarians] [amount of archers] [amount of goblins] [amount of giants] [amount of wallbreakers] [amount of ballons] [amount of wizards] [amount of healers] [amount of dragons] [amount of pekkas]"'
230
+ elsif File.file? "/CoC-Calc-Saves/lvl.txt"
231
+ totalCost = 0
232
+ totalTime = 0
233
+
234
+ get_troop_cost
235
+
236
+ if $troopLvlErr
237
+
238
+ else
239
+ totalCost += ARGV[1].to_i * $cost_barbarians
240
+ totalCost += ARGV[2].to_i * $cost_archers
241
+ totalCost += ARGV[3].to_i * $cost_goblins
242
+ totalCost += ARGV[4].to_i * $cost_giants
243
+ totalCost += ARGV[5].to_i * $cost_wallbreakers
244
+ totalCost += ARGV[6].to_i * $cost_ballons
245
+ totalCost += ARGV[7].to_i * $cost_wizards
246
+ totalCost += ARGV[8].to_i * $cost_healers
247
+ totalCost += ARGV[9].to_i * $cost_dragons
248
+ totalCost += ARGV[10].to_i * $cost_pekkas
249
+
250
+ totalTime += ARGV[1].to_i * 20
251
+ totalTime += ARGV[2].to_i * 25
252
+ totalTime += ARGV[3].to_i * 30
253
+ totalTime += ARGV[4].to_i * 120
254
+ totalTime += ARGV[5].to_i * 120
255
+ totalTime += ARGV[6].to_i * 380
256
+ totalTime += ARGV[7].to_i * 380
257
+ totalTime += ARGV[8].to_i * 900
258
+ totalTime += ARGV[9].to_i * 1800
259
+ totalTime += ARGV[10].to_i * 2700
260
+
261
+ puts "Your Troops will cost #{totalCost} elixir."
262
+ puts "Your total training time is #{totalTime}s."
263
+ end
264
+ else
265
+ puts "You need to enter the levels of your troops by running 'ruby CoC-Calc.rb set_troop_lvl' if you need futher help run 'ruby CoC-Calc.rb set_troop_lvl help'!"
266
+ end
267
+ end
268
+
269
+ init
270
+
271
+ if ARGV[0] == 'test'
272
+ initPuts
273
+ elsif ARGV[0] == 'set_troop_lvl'
274
+ set_troop_lvl
275
+ elsif ARGV[0]== 'calc'
276
+ calc
277
+ end
metadata ADDED
@@ -0,0 +1,45 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: CoC-Calc
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Ben Bals
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-07-22 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: Calculate your troop training cost and time for Clash of Clans! Written
14
+ in Ruby (runns on Mac, Windows and Linux)
15
+ email: benjustusbals@gmail.com
16
+ executables: []
17
+ extensions: []
18
+ extra_rdoc_files: []
19
+ files:
20
+ - lib/CoC-Calc.rb
21
+ homepage: https://github.com/BenBals/CoC-Calc
22
+ licenses:
23
+ - MIT
24
+ metadata: {}
25
+ post_install_message:
26
+ rdoc_options: []
27
+ require_paths:
28
+ - lib
29
+ required_ruby_version: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - '>='
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ required_rubygems_version: !ruby/object:Gem::Requirement
35
+ requirements:
36
+ - - '>='
37
+ - !ruby/object:Gem::Version
38
+ version: '0'
39
+ requirements: []
40
+ rubyforge_project:
41
+ rubygems_version: 2.3.0
42
+ signing_key:
43
+ specification_version: 4
44
+ summary: Calculate your troop training cost and time for Clash of Clans!
45
+ test_files: []