-
Notifications
You must be signed in to change notification settings - Fork 3
/
simple-calc.html
194 lines (194 loc) · 8.45 KB
/
simple-calc.html
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
<!doctype html>
<html>
<head>
<meta charset="utf-8" />
<style>
html,body{margin:0;padding:6px;}
.container{float:left;min-width:500px;}
h1+p{width:450px;}
#mw thead td{background-color:green;color:white;text-align:center;}
#mw thead td:nth-child(1){width:160px;}
#mw thead td:nth-child(2){width:80px;}
#mw thead td:nth-child(3){width:80px;}
#mw thead td:nth-last-child(1){width:100px;}
#mw tbody tr:nth-child(even) td{background-color:#eee;}
#mw tbody input{width:40px;}
#fs thead td{background-color:green;color:white;text-align:center;width:70px;}
#fs thead td:nth-child(1){width:130px;}
#fs tbody tr:nth-child(even) td{background-color:#eee;}
button{width:80px;height:28px;color:#002700;font-weight:700;font-size:1em;border-radius:6px;border:2px solid #245A37;background-image:linear-gradient(#A0E48A,#DBE6DD);margin-top:10px;}
</style>
<script>
function c(nw,bw,mw,uw,ps1,ms1,ns1,cs1,us1,ps2,ms2,ns2,cs2,us2,wp){
//前四个参数所填为武器本数,后五个参数所填为UP倍数
//nw普通攻刃,bw巴哈攻刃,mw马古纳攻刃,uw未知系列
//ps属性召唤,ms马古纳召唤,ns课金方阵召唤,cs角色加护召唤,us神崎兰子
//console.log(nw,bw,mw,uw,ps1,ms1,ns1,cs1,us1,ps2,ms2,ns2,cs2,us2);
// 普通攻刃区 巴武区 角色攻刃 马古纳区 UK区 属性加护
var result = ( 1+nw*(1+ns1+ns2) + bw + cs1+cs2 ) * ( 1+mw*(1+ms1+ms2) ) * ( 1+uw*(1+us1+us2) ) * (1+ps1+ps2+wp);
return Math.round(result*1000)/1000;
}
var wList = {
'普通攻刃(小)':[0,0.01,0.02,0.03,0.04,0.05,0.06,0.07,0.08,0.09,0.10,0.104,0.108,0.112,0.116,0.12],
'普通攻刃(中)':[0,0.03,0.04,0.05,0.06,0.07,0.08,0.09,0.10,0.11,0.12],
'普通攻刃(大)':[0,0.06,0.07,0.08,0.09,0.10,0.11,0.12,0.13,0.14,0.15,0.156,0.162,0.168,0.174,0.18],
'普通攻刃II(大)':[0,0.07,0.08,0.09,0.10,0.11,0.12,0.13,0.14,0.15,0.16,0.168,0.176,0.184,0.192,0.20],
'巴哈攻刃(全攻)':[1,0.20,0.21,0.22,0.23,0.24,0.25,0.26,0.27,0.28,0.30],
'巴哈攻刃(攻血)':[1,0.10,0.105,0.11,0.115,0.12,0.125,0.13,0.135,0.14,0.15],
'玛古纳攻刃I(中)':[2,0.03,0.04,0.05,0.06,0.07,0.08,0.09,0.10,0.11,0.12,0.126,0.132,0.138,0.144,0.15],
'玛古纳攻刃II(大)':[2,0.06,0.07,0.08,0.09,0.10,0.11,0.12,0.13,0.14,0.15,0.156,0.162,0.168,0.174,0.18],
'未知系列ATK(中)':[3,0.03,0.04,0.05,0.06,0.07,0.08,0.09,0.10,0.11,0.12],
'未知系列ATKII(大)':[3,0.06,0.07,0.08,0.09,0.10,0.11,0.12,0.13,0.14,0.15]
};
var sList = {
'属性30':[0.3,0,0,0,0],
'属性40':[0.4,0,0,0,0],
'属性50':[0.5,0,0,0,0],
'属性60':[0.6,0,0,0,0],
'属性75':[0.75,0,0,0,0],
'属性80':[0.8,0,0,0,0],
'属性100':[1,0,0,0,0],
'属性120':[1.2,0,0,0,0],
'马古纳50':[0,0.5,0,0,0],
'马古纳100':[0,1,0,0,0],
'课金80':[0,0,0.8,0,0],
'课金120':[0,0,1.2,0,0],
'角色攻刃25':[0,0,0,0.25,0],
'角色攻刃40':[0,0,0,0.4,0],
'角色攻刃60':[0,0,0,0.6,0],
'大公100':[0,0,0,1,0],
'大公200':[0,0,0,2,0],
'奥丁终解':[0.75,0,0,0.3,0],
'神崎兰子30':[0,0,0,0,0.3],
'神崎兰子50':[0,0,0,0,0.5]
};
function calcResult(){
clearResult();
var mainSummon = sList[document.querySelector('#ms select').value];
var weapons = [0,0,0,0];
var wp = document.querySelector('#iw input').checked ? 0.5 : 0;
Array.prototype.forEach.call(document.querySelectorAll('#mw tbody tr'),function(v,i){
var m = v.children[0].querySelector('select').value,
s = ~~v.children[1].querySelector('select').value,
q = ~~v.children[2].querySelector('input').value;
weapons[wList[m][0]] += wList[m][s]*q;
});
Array.prototype.forEach.call(document.querySelectorAll('#fs tbody tr'),function(v,i){
if(v.children[0].querySelector('input').checked){
var summonName = v.children[0].querySelector('label').textContent;
var summon = sList[summonName];
var arg = weapons.concat(mainSummon,summon,wp);
v.children[1].innerHTML = c.apply(null,arg.concat(100));
v.children[2].innerHTML = c.apply(null,arg.concat(90));
v.children[3].innerHTML = c.apply(null,arg.concat(75));
v.children[4].innerHTML = c.apply(null,arg.concat(50));
v.children[5].innerHTML = c.apply(null,arg.concat(25));
v.children[6].innerHTML = c.apply(null,arg.concat(10));
v.children[7].innerHTML = c.apply(null,arg.concat(1));
}
});
}
function clearResult(){
Array.prototype.forEach.call(document.querySelectorAll('#fs tbody tr'),function(v,i){
v.children[1].innerHTML = '';
v.children[2].innerHTML = '';
v.children[3].innerHTML = '';
v.children[4].innerHTML = '';
v.children[5].innerHTML = '';
v.children[6].innerHTML = '';
v.children[7].innerHTML = '';
});
}
function copyWeapon(){
if(document.querySelectorAll('#mw tbody tr').length>=10){
return;
}
var source = document.querySelector('#mw tbody tr').cloneNode(true);
source.children[3].innerHTML = '<a href="javascript:void(0)">移除</a>';
document.querySelector('#mw tbody').appendChild(source);
recountTotalWeapon();
}
function recountTotalWeapon(){
var total = 0, elTC = document.querySelector('#mwtc');
Array.prototype.forEach.call(document.querySelectorAll('#mw tbody tr td:nth-child(3) input'),function(v,i){
total += ~~v.value;
});
elTC.innerHTML = total;
if(total>10){
elTC.style.color = 'red';
}else{
elTC.style.color = '';
}
}
function weaponChangeManage(ev){
if(ev.target.tagName.toUpperCase()=='SELECT'){
if(ev.target.dataset.type=='m'){
var l = wList[ev.target.value].length;
var s = ev.target.parentNode.nextSibling.children[0];
s.length=0;
for(var i=1;i<l;i++){
var option = new Option();
option.text = i;
s.add(option);
}
}
}else if(ev.target.tagName.toUpperCase() == 'INPUT'){
recountTotalWeapon();
}
}
function weaponClickManage(ev){
if(ev.target.tagName.toUpperCase()=='A'){
var n = ev.target.parentNode.parentNode;
n.parentNode.removeChild(n);
recountTotalWeapon();
}
}
window.addEventListener('load',function(){
var elMW = document.querySelector('#mw tbody'), elMS = document.querySelector('#ms select'), elFS = document.querySelector('#fs tbody');
var row = document.createElement('tr');
row.innerHTML = '<td><select data-type="m"></select></td><td><select></select></td><td><input type="number" value="1" /></td><td></td>';
elMW.appendChild(row);
var s1 = row.querySelector('select');
for(var key in wList){
var option = new Option();
option.text = key;
s1.add(option);
}
elMW.addEventListener('change',weaponChangeManage,false);
elMW.addEventListener('click',weaponClickManage,false);
var ev = document.createEvent('UIEvents');
ev.initEvent('change',true,true);
s1.dispatchEvent(ev);
for(var key in sList){
var option = new Option();
option.text = key;
elMS.add(option);
var row = document.createElement('tr');
row.innerHTML = '<td><label><input type="checkbox" />'+key+'</label></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td>';
elFS.appendChild(row);
}
document.querySelectorAll('button')[0].addEventListener('click',copyWeapon,false);
document.querySelectorAll('button')[1].addEventListener('click',calcResult,false);
document.querySelectorAll('button')[2].addEventListener('click',clearResult,false);
},false);
</script>
</head>
<body>
<div class="container">
<h1>这是什么?</h1>
<p>当你想打怪却发现没有好的召唤可以组时,想折衷点选一个却不知道选哪个好?那就用这个简单的计算器算一下吧!如果你只是想找武器构成的最佳方案,推荐你用<a href="http://hibin0.web.fc2.com/grbr_weapon_calc/weapon_calc.html">日比野君的计算器</a>。</p>
<h2>你会带什么武器?</h2>
<table id="mw"><thead><tr><td>技能</td><td>等级</td><td>数量</td><td></td></tr></thead><tbody></tbody><tfoot><tr><td>总计:</td><td></td><td id="mwtc">1</td><td></td></tr></tfoot></table>
<button>增加</button>
<h2>你的主召唤是?</h2>
<p id="ms"><select></select></p>
<h2>是否对克制属性?</h2>
<p id="iw"><label><input type="checkbox" value="1" />对克制属性请打勾</label></p>
</div>
<div class="container">
<h2>能组的召唤有?</h2>
<table id="fs"><thead><tr><td>HP%</td><td>100</td><td>90</td><td>75</td><td>50</td><td>25</td><td>10</td><td>1</td></tr></thead><tbody></tbody></table>
<button>计算</button> <button>清空</button>
</div>
</body>
</html>