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
|
/*
* Copyright (C) 2022 NotEnoughUpdates contributors
*
* This file is part of NotEnoughUpdates.
*
* NotEnoughUpdates is free software: you can redistribute it
* and/or modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation, either
* version 3 of the License, or (at your option) any later version.
*
* NotEnoughUpdates is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with NotEnoughUpdates. If not, see <https://www.gnu.org/licenses/>.
*/
package io.github.moulberry.notenoughupdates.profileviewer.weight.lily;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import io.github.moulberry.notenoughupdates.profileviewer.ProfileViewer;
import io.github.moulberry.notenoughupdates.profileviewer.weight.weight.DungeonsWeight;
import io.github.moulberry.notenoughupdates.profileviewer.weight.weight.WeightStruct;
import io.github.moulberry.notenoughupdates.util.Constants;
import io.github.moulberry.notenoughupdates.util.Utils;
import java.util.Map;
public class LilyDungeonsWeight extends DungeonsWeight {
private final JsonObject profileJson;
public LilyDungeonsWeight(Map<String, ProfileViewer.Level> player, JsonObject profileJson) {
super(player);
this.profileJson = profileJson;
}
@Override
public void getDungeonWeight() {
ProfileViewer.Level catacombs = player.get("catacombs");
double extra = 0;
double n = 0;
if (catacombs.totalXp < CATACOMBS_LEVEL_50_XP) {
n = 0.2 * Math.pow(catacombs.level / 50, 1.538679118869934);
} else {
extra = 500.0 * Math.pow((catacombs.totalXp - CATACOMBS_LEVEL_50_XP) / 142452410.0, 1.0 / 1.781925776625157);
}
if (catacombs.level != 0) {
if (catacombs.totalXp < CATACOMBS_LEVEL_50_XP) {
weightStruct.add(
new WeightStruct(
Utils.getElement(Constants.WEIGHT, "lily.dungeons.overall").getAsDouble() *
((Math.pow(1.18340401286164044, (catacombs.level + 1)) - 1.05994990217254) * (1 + n))
)
);
} else {
weightStruct.add(new WeightStruct((4100 + extra) * 2));
}
}
}
public void getDungeonCompletionWeight(String cataMode) {
JsonObject dungeonsCompletionWorth = Utils.getElement(Constants.WEIGHT, "lily.dungeons.completion_worth").getAsJsonObject();
JsonObject dungeonsCompletionBuffs = Utils.getElement(Constants.WEIGHT, "lily.dungeons.completion_buffs").getAsJsonObject();
double max1000 = 0;
double mMax1000 = 0;
for (Map.Entry<String, JsonElement> dcwEntry : dungeonsCompletionWorth.entrySet()) {
if (dcwEntry.getKey().startsWith("catacombs_")) {
max1000 += dcwEntry.getValue().getAsDouble();
} else {
mMax1000 += dcwEntry.getValue().getAsDouble();
}
}
max1000 *= 1000;
mMax1000 *= 1000;
double upperBound = 1500;
double score = 0;
if (cataMode.equals("normal")) {
if (Utils.getElement(profileJson, "dungeons.dungeon_types.catacombs.tier_completions") == null) {
return;
}
for (Map.Entry<String, JsonElement> normalFloor : Utils
.getElement(profileJson, "dungeons.dungeon_types.catacombs.tier_completions")
.getAsJsonObject()
.entrySet()) {
if (dungeonsCompletionWorth.has("catacombs_" + normalFloor.getKey())) {
int amount = normalFloor.getValue().getAsInt();
double excess = 0;
if (amount > 1000) {
excess = amount - 1000;
amount = 1000;
}
double floorScore = amount * dungeonsCompletionWorth.get("catacombs_" + normalFloor.getKey()).getAsDouble();
if (excess > 0) floorScore *= Math.log(excess / 1000 + 1) / Math.log(7.5) + 1;
score += floorScore;
}
}
weightStruct.add(new WeightStruct(score / max1000 * upperBound * 2));
} else {
if (Utils.getElement(profileJson, "dungeons.dungeon_types.master_catacombs.tier_completions") == null) {
return;
}
for (Map.Entry<String, JsonElement> masterFloor : Utils
.getElement(profileJson, "dungeons.dungeon_types.master_catacombs.tier_completions")
.getAsJsonObject()
.entrySet()) {
if (dungeonsCompletionBuffs.has(masterFloor.getKey())) {
int amount = masterFloor.getValue().getAsInt();
double threshold = 20;
if (amount >= threshold) {
upperBound += dungeonsCompletionBuffs.get(masterFloor.getKey()).getAsInt();
} else {
upperBound +=
dungeonsCompletionBuffs.get(masterFloor.getKey()).getAsInt() * Math.pow((amount / threshold), 1.840896416);
}
}
if (dungeonsCompletionWorth.has("master_catacombs_" + masterFloor.getKey())) {
int amount = masterFloor.getValue().getAsInt();
double excess = 0;
if (amount > 1000) {
excess = amount - 1000;
amount = 1000;
}
double floorScore = amount * dungeonsCompletionWorth.get("master_catacombs_" + masterFloor.getKey()).getAsDouble();
if (excess > 0) floorScore *= (Math.log((excess / 1000) + 1) / Math.log(6)) + 1;
score += floorScore;
}
}
weightStruct.add(new WeightStruct((score / mMax1000) * upperBound * 2));
}
}
}
|