-
Notifications
You must be signed in to change notification settings - Fork 1
/
GearExtension.html
236 lines (213 loc) · 6.24 KB
/
GearExtension.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
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
<script>
/**
*
* @param {any} bdLike
* @returns Decimal
*/
function fromBD(bdLike) {
if (!bdLike) {
return new Decimal(0);
}
const { mantissa, exponent } = bdLike;
return Decimal.fromMantissaExponent(mantissa, exponent);
}
/**
* PowerMod is the scaling Oni has set for each bonus
* @param {number} bonusId
* @param {Decimal} powerBD
* @returns
*/
function PowerMod(bonusId, powerBD) {
if (powerBD.equals(Decimal.ZERO)) {
return Decimal.fromNumber(0);
}
const powlog = (base, log, mul = 1.0) => {
return Decimal.fromNumber(base).pow(powerBD.log(log)).mul(mul);
};
switch (bonusId) {
case 1:
case 2:
case 3:
case 4:
case 5:
case 6:
case 7:
if (powerBD.cmp(100) >= 0) {
const c = Decimal.fromNumber(powerBD.log(5)).mul(0.5);
return c.sub(0.93);
// return Number.Log(power, 5) * 0.5 - 0.93;
}
return powerBD.mul(0.005);
case 8:
return powerBD.mul(0.001);
case 9:
return powerBD.mul(0.001);
case 10:
return powerBD.mul(0.0005);
case 11:
return powerBD.mul(0.0005);
case 12:
return powlog(1.1, 1.5, 0.02);
case 13:
return powerBD.mul(0.0001);
case 14:
return powlog(1.2, 1.5, 0.003);
case 15:
return powerBD.mul(5e-5);
case 16:
return powerBD.mul(2.5e-5);
case 17:
return powlog(1.19, 1.52, 0.002);
case 18:
return powlog(1.16, 1.57, 0.00075);
case 19:
return powlog(1.15, 1.58, 0.001);
case 20:
return powlog(7.0, 10, 5e-7);
case 21:
return powlog(1.1, 1.75, 0.005);
case 22:
return powlog(1.14, 1.61, 0.0025);
case 23:
return powlog(1.08, 1.8, 0.001);
case 24:
return powlog(1.13, 1.65, 5e-5);
case 25:
return powlog(1.11, 1.71, 0.0001);
case 26:
return powlog(1.04, 2.51, 0.0035);
case 27:
return powlog(1.045, 2.45, 0.005);
default:
return Decimal.fromNumber(0);
}
}
function getEquipedItems(data) {
const items = data.EquippedItems.map((item) => {
return {
...item,
BonusList: item.BonusList.map((bonus) => {
return {
...bonus,
powerDecimal: fromBD(bonus.PowerBD),
};
}),
};
});
return items;
}
function getItemTotalRating(item) {
let sum = Decimal.fromNumber(0);
for (let i = 0; i < item.BonusList.length; i++) {
sum = sum.add(item.BonusList[i].powerDecimal);
}
return sum;
}
// STR / DEX etc are flat stats, and are scaled differently
function bonusIsFlat(bonusId) {
return bonusId <= 7;
}
function getBonus2(bonusId, data) {
const equipedItems = getEquipedItems(data);
const AscensionBestItemRatingBD = fromBD(data.AscensionBestItemRatingBD);
let sum = Decimal.fromNumber(0);
for (let i = 0; i < equipedItems.length; i++) {
if (!equipedItems[i]) {
continue;
}
const item = equipedItems[i];
// console.log(item);
const totalRating = getItemTotalRating(item);
const bestRatingRatio = AscensionBestItemRatingBD.div(totalRating);
for (let j = 0; j < item.BonusList.length; j++) {
const bonus = item.BonusList[j];
if (bonusId === bonus.BonusID) {
const refinePowerCoeff =
1.0 + (item.RefineLevel + item.FreeRefineLevel) * data.EnhancingPower;
const itemRatingLimiterCoeff =
data.AscensionCount >= 11 && bestRatingRatio.cmp(0.999) > 0
? 1
: Decimal.min(1, bestRatingRatio);
const bonusPower = bonus.powerDecimal
.mul(refinePowerCoeff)
.mul(itemRatingLimiterCoeff);
let expeShop_bonusOnRarity = 1.0;
if (
!bonusIsFlat(bonusId) &&
data.ExpeShopEquipmentBonusOnRarityLevel > 0 &&
item.ItemRarity > 15
) {
expeShop_bonusOnRarity = Decimal.fromNumber(
1.0 + data.ExpeShopEquipmentBonusOnRarityLevel * 0.01
).pow(item.ItemRarity - 15);
}
const powerMod = PowerMod(bonusId, bonusPower).mul(
expeShop_bonusOnRarity
);
sum = sum.add(powerMod);
}
}
}
return sum;
}
const BONUS_ID_TO_TEXT = {
1: "STR",
2: "CON",
3: "DEX",
4: "AGI",
5: "LCK",
6: "STR",
7: "CON",
8: "Potatoes",
9: "ClassExp",
10: "Skulls",
11: "ConfectionExp",
12: "ReincarnationExp",
13: "Poop",
14: "Milk",
15: "WhackScore",
16: "BrewingExp",
17: "Calcium",
18: "WormsQuantity",
19: "FermentingExp",
20: "LarvaEfficiency",
21: "Residue",
22: "LarvaQuantity",
23: "PetLevelExp",
24: "PetDamage",
25: "PetRankExp",
26: "CardPower",
27: "CardExp",
};
const CELL_GEAR_SHEET = 'Gear'; // need to be changed
const CELL_GEAR_TOT_COL = 'R'; // need to be changed
const CELL_GEAR_TOT_LINE = 6; // need to be changed
function getAllGearBonuses(data) {
let str = '';
for (let bonusId = 1; bonusId < 28; bonusId++) {
// SO STR is bonus 1 + 6
// and CON is bonus 2 + 7
// so we skip the first 2 and Add them later
if (bonusId === 1 || bonusId === 2) continue;
let bonusBD = getBonus2(bonusId, data);
if (bonusId === 6) {
bonusBD = bonusBD.add(getBonus2(1, data));
}
if (bonusId === 7) {
bonusBD = bonusBD.add(getBonus2(2, data));
}
// this part is to get exactly the same value as the gear panel in game
// but it shouldn't be needed in the cells?
//if (bonusIsFlat(bonusId)) {
// a = a.add(1);
//} else {
// a = a.mul(100);
//}
// const bonusName = BONUS_ID_TO_TEXT[bonusId];
// console.log(bonusName + " " + bonusId, a.toExponential(3));
// str += bonusName + " " + bonusId+ " " + a.toExponential(3)
const bonus = bonusBD.toPrecision(4); // I used a precision of 4 but you might need to use 5 or more...
updateCell(CELL_GEAR_SHEET, `${CELL_GEAR_TOT_COL}${CELL_GEAR_TOT_LINE + bonusId - 3}`, bonus);
}
}
</script>