-
-
Notifications
You must be signed in to change notification settings - Fork 216
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Backend: Remove Neu Constant (#1191)
Co-authored-by: CalMWolfs <94038482+CalMWolfs@users.noreply.github.com> Co-authored-by: hannibal2 <24389977+hannibal00212@users.noreply.github.com>
- Loading branch information
1 parent
7960d2a
commit 5ff5796
Showing
14 changed files
with
182 additions
and
114 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 changes: 9 additions & 0 deletions
9
src/main/java/at/hannibal2/skyhanni/data/jsonobjects/repo/neu/NeuRNGScore.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package at.hannibal2.skyhanni.data.jsonobjects.repo.neu | ||
|
||
import at.hannibal2.skyhanni.utils.NEUInternalName | ||
import com.google.gson.annotations.Expose | ||
|
||
data class NeuRNGScore( | ||
@Expose val catacombs: Map<String, Map<NEUInternalName, Long>>, | ||
@Expose val slayer: Map<String, Map<NEUInternalName, Long>> | ||
) |
63 changes: 63 additions & 0 deletions
63
src/main/java/at/hannibal2/skyhanni/data/jsonobjects/repo/neu/NeuReforgeStoneJson.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
package at.hannibal2.skyhanni.data.jsonobjects.repo.neu; | ||
|
||
import at.hannibal2.skyhanni.utils.LorenzRarity | ||
import at.hannibal2.skyhanni.utils.NEUInternalName | ||
import com.google.gson.annotations.Expose | ||
import com.google.gson.annotations.SerializedName | ||
|
||
data class NeuReforgeStoneJson( | ||
@Expose val internalName: NEUInternalName, | ||
@Expose val reforgeName: String, | ||
@Expose @SerializedName("itemTypes") val rawItemTypes: Any, | ||
@Expose val requiredRarities: List<LorenzRarity>, | ||
@Expose val reforgeCosts: Map<LorenzRarity, Long>, | ||
@Expose val reforgeStats: Map<LorenzRarity, Map<String, Double>>, | ||
@Expose @SerializedName("reforgeAbility") val rawReforgeAbility: Any?, | ||
) { | ||
|
||
private lateinit var reforgeAbilityField: Map<LorenzRarity, String> | ||
|
||
val reforgeAbility | ||
get() = if (this::reforgeAbilityField.isInitialized) reforgeAbilityField | ||
else { | ||
reforgeAbilityField = when (this.rawReforgeAbility) { | ||
is String -> { | ||
this.requiredRarities.associateWith { this.rawReforgeAbility } | ||
} | ||
|
||
is Map<*, *> -> (this.rawReforgeAbility as? Map<String, String>)?.mapKeys { | ||
LorenzRarity.valueOf( | ||
it.key.uppercase().replace(" ", "_") | ||
) | ||
} ?: emptyMap() | ||
|
||
else -> emptyMap() | ||
} | ||
reforgeAbilityField | ||
} | ||
|
||
/* used in ReforgeAPI which isn't in beta yet | ||
val itemType: Pair<String, List<NEUInternalName>> by lazy { | ||
val any = this.rawItemTypes | ||
return@lazy when (any) { | ||
is String -> { | ||
any.replace("/", "_AND_").uppercase() to emptyList() | ||
} | ||
is Map<*, *> -> { | ||
val type = "SPECIAL_ITEMS" | ||
val map = any as? Map<String, List<String>> ?: return@lazy type to emptyList() | ||
val internalNames = map["internalName"]?.map { it.asInternalName() } ?: emptyList() | ||
val itemType = map["itemid"]?.map { | ||
NEUItems.getInternalNamesForItemId(Item.getByNameOrId(it)) | ||
}?.flatten() | ||
?: emptyList() | ||
type to (internalNames + itemType) | ||
} | ||
else -> throw IllegalStateException() | ||
} | ||
} | ||
*/ | ||
} | ||
|
3 changes: 1 addition & 2 deletions
3
...ni/data/jsonobjects/other/NeuSacksJson.kt → ...data/jsonobjects/repo/neu/NeuSacksJson.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 8 additions & 0 deletions
8
src/main/java/at/hannibal2/skyhanni/data/jsonobjects/repo/neu/NeuSkillLevelJson.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package at.hannibal2.skyhanni.data.jsonobjects.repo.neu | ||
|
||
import com.google.gson.annotations.Expose | ||
import com.google.gson.annotations.SerializedName | ||
|
||
data class NeuSkillLevelJson( | ||
@Expose @SerializedName("leveling_xp") val levelingXp: List<Int> | ||
) |
17 changes: 17 additions & 0 deletions
17
src/main/java/at/hannibal2/skyhanni/events/NeuRepositoryReloadEvent.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,28 @@ | ||
package at.hannibal2.skyhanni.events | ||
|
||
import at.hannibal2.skyhanni.config.ConfigManager | ||
import at.hannibal2.skyhanni.test.command.ErrorManager | ||
import at.hannibal2.skyhanni.utils.NEUItems.manager | ||
import at.hannibal2.skyhanni.utils.fromJson | ||
import com.google.gson.JsonObject | ||
import com.google.gson.JsonSyntaxException | ||
import java.io.File | ||
|
||
class NeuRepositoryReloadEvent : LorenzEvent() { | ||
fun getConstant(file: String): JsonObject? { | ||
return manager.getJsonFromFile(File(manager.repoLocation, "constants/$file.json")) | ||
} | ||
|
||
inline fun <reified T : Any> readConstant(file: String): T { | ||
val data = getConstant(file) ?: ErrorManager.skyHanniError("$file failed to load from neu repo!") | ||
return try { | ||
ConfigManager.gson.fromJson<T>(data) | ||
} catch (e: JsonSyntaxException) { | ||
ErrorManager.logErrorWithData( | ||
e, "$file failed to read from neu repo!", | ||
"data" to data | ||
) | ||
throw e | ||
} | ||
} | ||
} |
Oops, something went wrong.