-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathindex.html
More file actions
480 lines (465 loc) · 11.5 KB
/
index.html
File metadata and controls
480 lines (465 loc) · 11.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
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
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
<!-- saved from url=(0065)file:///C:/Users/mlichtenauer/Downloads/cropcalcT44_extended.html -->
<html><head><meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<script>
var o0=3, mill=0, bake=0, hm=0, o1=0, o2=0, o3=0, o1p=0, o2p=0, o3p=0, cap=0, gold=1.25, waterwork=0, egypt=0;
costs=new Object();
costs.m = new Array(0,2560,4605,8295,14925,26875);
costs.b = new Array(0,5150,9270,16690,30035,54060);
costs.hm= new Array(0,114240,383295,1595070);
costs.ww= new Array(0,3105,4065,5325,6980,9145,11975,15695,20555,26925,35280,46215,60545,79310,103895,136105,178300,233560,305965,400815,525070);
field=new Object();
field.fields = new Array(0,0,0,0,0,0);
//field.values = new Array(2,5,9,15,22,33,50,70,100,145,200,280,375,495,635,800,1000,1300,1600,2000,2450,3050);
field.values = new Array(3,7,13,21,31,46,70,98,140,203,280,392,525,691,889,1120,1400,1820,2240,2800,3430,4270);
//field.increase = new Array(0,3,4,6,7,11,17,20,30,45,55,80,95,120,140,165,200,300,300,400,450,600);
field.increase = new Array(0,4,6,8,10,15,24,28,42,63,77,112,133,168,196,231,280,420,420,560,630,840);
field.costs = new Array(0,250,415,695,1165,1945,3250,5425,9055,15125,25255,42180,70445,117650,196445,328070,547880,914960,1527985,2551735,4261410,7116555);
field.lowest = function()
{
return field.fields[o0-1];
}
field.highest = function()
{
return field.fields[0];
}
field.uplowest = function()
{
for(var i=0;i<o0;i++)
{
if (field.fields[i] <= field.lowest())
{
field.fields[i]=field.fields[i]+1;
return field.fields[i];
}
}
return ;
}
field.uphighest = function()
{
field.fields[0]=field.fields[0]+1;
}
field.tprod = function()
{
var valuei, tprod=0;
for(var i=0;i<o0;i++)
{
valuei = field.fields[i];
tprod=tprod+field.values[valuei];
}
return tprod;
}
function seto0(select)
{
o0 = select;
if (o0==3)
field.fields=[0,0,0];
else if (o0==4)
field.fields=[0,0,0,0];
else if (o0==5)
field.fields=[0,0,0,0,0];
else if (o0==6)
field.fields=[0,0,0,0,0,0];
else if (o0==7)
field.fields=[0,0,0,0,0,0,0];
else if (o0==9)
field.fields=[0,0,0,0,0,0,0,0,0];
else if (o0==15)
field.fields=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0];
else
field.fields=[];
}
function totalprod()
{
return field.tprod()*(1+o1*o1p*(1+waterwork*.05)+o2*o2p*(1+waterwork*.05)+o3*o3p*(1+waterwork*.05)+bake*.05+mill*.05);
}
function totalprodn(f,m)
{ z.innerHTML=f +'-'+ m
return (field.tprod()+f)*(1+o1*o1p*(1+waterwork*.05)+o2*o2p*(1+waterwork*.05)+o3*o3p*(1+waterwork*.05)+bake*.05+mill*.05+m);
}
function seto1(select)
{
o1 = parseFloat(select);
}
function seto2(select)
{
o2 = parseFloat(select);
}
function seto3(select)
{
o3 = parseFloat(select);
}
function seto4(select)
{
cap = parseFloat(select);
}
function seto5(select)
{
gold = parseFloat(select);
}
function seto6(select)
{
egypt = parseFloat(select);
}
function reset()
{
if (cap == 1)
field.costs[11]=1000000
else
field.costs[11]=42180
seto0(o0);
hm =0;
mill =0;
bake =0;
o1p =0;
o2p =0;
o3p =0;
waterwork=0;
}
function getNextStep()
{
var output = "";
var lowest = 0;
var efflowest = 1000000;
var temp = 0;
//test lowest field
if(field.fields[o0-1]<=10 || cap != 1)
efflowest = field.costs[field.fields[o0-1]+1]/(totalprodn(field.increase[field.fields[o0-1]+1],0) - totalprod());
//test mill/bake rush if applicable
if (field.fields[0]<10)
{
if (field.fields[0]<5)
{
var tfi=0; tfc=0;
for(var i=field.fields[0]+1;i<6;i++)
{
tfi=tfi+field.increase[i];
tfc=tfc+field.costs[i];
}
//try all mill level rushes
tfc = tfc+costs.m[1];
temp = tfc/(totalprodn(tfi,.05)-totalprod());
if (temp <= efflowest)
{
efflowest=temp;
lowest=1;
}
tfc = tfc+costs.m[2];
temp = tfc/(totalprodn(tfi,.1)-totalprod());
if (temp <= efflowest)
{
efflowest=temp;
lowest=1;
}
tfc = tfc+costs.m[3];
temp = tfc/(totalprodn(tfi,.15)-totalprod());
if (temp <= efflowest)
{
efflowest=temp;
lowest=1;
}
tfc = tfc+costs.m[4];
temp = tfc/(totalprodn(tfi,.2)-totalprod());
if (temp <= efflowest)
{
efflowest=temp;
lowest=1;
}
tfc = tfc+costs.m[5];
temp = tfc/(totalprodn(tfi,.25)-totalprod());
if (temp <= efflowest)
{
efflowest=temp;
lowest=1;
}
}
else if(field.fields[o0-1]<=10|| cap == 0)
{
var tfi=0; tfc=0; tfm=0;
for(var i=field.fields[0]+1;i<11;i++)
{
tfi=tfi+field.increase[i];
tfc=tfc+field.costs[i];
}
if (mill<5)
{
for(var i=mill; i<5; i++)
{
tfc+=costs.m[i+1];
tfm+=.05;
}
}
//try all mill level rushes
tfc = tfc+costs.b[1];
temp = tfc/(totalprodn(tfi,.05+tfm)-totalprod());
if (temp <= efflowest)
{
efflowest=temp;
lowest=1;
}
tfc = tfc+costs.b[2];
temp = tfc/(totalprodn(tfi,.1+tfm)-totalprod());
if (temp <= efflowest)
{
efflowest=temp;
lowest=1;
}
tfc = tfc+costs.b[3];
temp = tfc/(totalprodn(tfi,.15+tfm)-totalprod());
if (temp <= efflowest)
{
efflowest=temp;
lowest=1;
}
tfc = tfc+costs.b[4];
temp = tfc/(totalprodn(tfi,.2+tfm)-totalprod());
if (temp <= efflowest)
{
efflowest=temp;
lowest=1;
}
tfc = tfc+costs.b[5];
temp = tfc/(totalprodn(tfi,.25+tfm)-totalprod());
if (temp <= efflowest)
{
efflowest=temp;
lowest=1;
}
}
}
//test flowermill/bake special case
if (mill<5 && field.fields[0]>=10)
{
var tfi=0; tfc=0; tfm=0;
if (mill<5)
{
for(var i=mill; i<5; i++)
{
tfc+=costs.m[i+1];
tfm+=.05;
}
}
//try all mill level rushes
tfc = tfc+costs.b[1];
temp = tfc/(totalprodn(tfi,.05+tfm)-totalprod());
if (temp <= efflowest)
{
efflowest=temp;
lowest=2;
}
tfc = tfc+costs.b[2];
temp = tfc/(totalprodn(tfi,.1+tfm)-totalprod());
if (temp <= efflowest)
{
efflowest=temp;
lowest=2;
}
tfc = tfc+costs.b[3];
temp = tfc/(totalprodn(tfi,.15+tfm)-totalprod());
if (temp <= efflowest)
{
efflowest=temp;
lowest=2;
}
tfc = tfc+costs.b[4];
temp = tfc/(totalprodn(tfi,.2+tfm)-totalprod());
if (temp <= efflowest)
{
efflowest=temp;
lowest=2;
}
tfc = tfc+costs.b[5];
temp = tfc/(totalprodn(tfi,.25+tfm)-totalprod());
if (temp <= efflowest)
{
efflowest=temp;
lowest=2;
}
}
//test waterwark
if (hm >= 10 && egypt==1)
{
temp = costs.ww[waterwork+1]/(totalprodn(0,o1*o1p*.05+o2*o2p*.05+o3*o3p*.05)-totalprod());
if (temp <= efflowest)
{
efflowest = temp;
waterwork++;
lowest = 5;
}
}
//test mill
if (field.fields[0]>=5 && mill<5)
{
temp = costs.m[mill+1]/(totalprodn(0,.05)-totalprod());
if (temp <= efflowest)
{
efflowest = temp;
lowest = 2;
}
}
//test bake
if (field.highest()>=10 && bake<5 && mill == 5)
{
temp = costs.b[bake+1]/(totalprodn(0,.05)-totalprod());
if (temp <= efflowest)
{
efflowest = temp;
lowest = 3;
}
}
//test oasis
if (o1p == 0)
{
temp = costs.hm[1]/(totalprodn(0,o1)-totalprod());
if (temp <= efflowest)
{
efflowest = temp;
o1p = 1;
hm = 10;
lowest = 4;
}
}
else if (o2p == 0)
{
temp = costs.hm[2]/(totalprodn(0,o2)-totalprod());
if (temp <= efflowest)
{
efflowest = temp;
o2p = 1;
hm = 15;
lowest = 4;
}
}
else if (o3p == 0)
{
temp = costs.hm[3]/(totalprodn(0,o3)-totalprod());
if (temp <= efflowest)
{
efflowest = temp;
o3p = 1;
hm = 20;
lowest = 4;
}
}
else if (efflowest == 1000000)
return;
if (lowest == 0)
{
if (cap==1 && field.lowest()==10)
return;
output = output + field.uplowest();
return "Upgrade a crop field to level " + output + ". </td><td>" + Math.round(efflowest/gold/.24)/100 + "</td>";
}
if (lowest == 1)
{
if (cap==1 && field.lowest()==10)
return;
field.uphighest();
return "<b>Upgrade a crop field to level " + field.fields[0] + "</b>. </td><td>" + Math.round(efflowest/gold/.24)/100 + "</td>";
}
if (lowest == 2)
{
mill++;
return "<b>Upgrade the flour mill to level " + mill + "</b>. </td><td>" + Math.round(efflowest/gold/.24)/100 + "</td>";
}
if (lowest == 3)
{
bake++;
return "<b>Upgrade the bakery to level " + bake + "</b>. </td><td>" + Math.round(efflowest/gold/.24)/100 + "</td>";
}
if (lowest == 4)
{
return "<b>Upgrade the hero's mansion to level " + hm + " and capture your oasis</b>. </td><td>" + Math.round(efflowest/gold/.24)/100 + "</td>";
}
if (lowest == 5)
{
return "<b>Upgrade the waterworks to level " + waterwork + "</b>. </td><td>" + Math.round(efflowest/gold/.24)/100 + "</td>";
}
}
function getOrder()
{
reset();
z=document.getElementById("demo"); // nothing
z.innerHTML="Calculating...";
var output="<table border><tr><td>[M,B,H,W]</td><td>[Fields]</td><td>Production</td><td>Action</td><td>Days for ROI</td><tr>";
var i=0;
if (cap == 0)
{
while(field.lowest()<21)
{
i = i+1;
output=output+"<tr><td>["+mill+","+bake+","+hm+","+waterwork+"]</td>"+"<td>["+field.fields+"]</td>"+"<td>"+Math.round(totalprod()*gold)+"</td><td>Step "+i+":"+getNextStep()+"</td></tr>";
}
}
else if (cap == 1)
{
i = 0;
while(field.lowest()<10||mill<5||bake<5||(hm<10&&o1!=0)||(hm<15&&o1!=0&&o2!=0)||(hm<20&&o1!=0&&o2!=0&&o3!=0))
{
i = i+1;
output=output+"<tr><td>["+mill+","+bake+","+hm+","+waterwork+"]</td>"+"<td>["+field.fields+"]</td>"+"<td>"+Math.round(totalprod()*gold)+"</td><td>Step "+i+":"+getNextStep()+"</td></tr>";
}
}
output=output+"<tr><td>["+mill+","+bake+","+hm+","+waterwork+"]</td>"+"<td>["+field.fields+"]</td>"+"<td>"+Math.round(totalprod()*gold)+"</td><td>Done</td></table>";
x=document.getElementById("demo"); // Find the element
x.innerHTML=output; // Change the content
}
</script>
<style>@media print {#ghostery-purple-box {display:none !important}}</style></head>
<body>
<h1>Travian Capital Crop/Oasis/Bakery Order</h1>
written by Bryan H - modified by MaTzE aka BrothersInArms (SkypeID: eymatze)
<br><br>Field Count
<form name="o0">
<select name="no0" onchange="seto0(document.o0.no0.options[document.o0.no0.options.selectedIndex].value)">
<option value="6">6Crop</option>
<option value="7">7Crop</option>
<option value="9">9Crop</option>
<option value="15">15Crop</option>
</select>
</form>
Capital?
<form name="o4">
<select name="no4" onchange="seto4(document.o4.no4.options[document.o4.no4.options.selectedIndex].value)">
<option value="0">Yes</option>
<option value="1">No</option>
</select>
</form>
Egyptian?
<form name="o6">
<select name="no6" onchange="seto6(document.o6.no6.options[document.o6.no6.options.selectedIndex].value)">
<option value="0">No</option>
<option value="1">Yes</option>
</select>
</form>
Crop Oasis Types (put highest first please)
<form name="o1">
<select name="no1" onchange="seto1(document.o1.no1.options[document.o1.no1.options.selectedIndex].value)">
<option value="0">0%</option>
<option value=".25">25%</option>
<option value=".50">50%</option>
</select>
</form>
<form name="o2">
<select name="no2" onchange="seto2(document.o2.no2.options[document.o2.no2.options.selectedIndex].value)">
<option value="0">0%</option>
<option value=".25">25%</option>
<option value=".50">50%</option>
</select>
</form>
<form name="o3">
<select name="no3" onchange="seto3(document.o3.no3.options[document.o3.no3.options.selectedIndex].value)">
<option value="0">0%</option>
<option value=".25">25%</option>
<option value=".50">50%</option>
</select>
</form>
Gold Production Bonus? (Order stays the same)
<form name="o5">
<select name="no5" onchange="seto5(document.o5.no5.options[document.o5.no5.options.selectedIndex].value)">
<option value="1.25">Yes (25%)</option>
<option value="1">No</option>
</select>
</form>
<button type="button" onclick="getOrder()">Calculate</button>
<p id="demo"></p>
</div></body></html>