aboutsummaryrefslogtreecommitdiff
path: root/src/main/kotlin/repo/EssenceRecipeProvider.kt
blob: 38559d56cfe9b2b4a7b037520d00849b98a4ad92 (plain)
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
package moe.nea.firmament.repo

import io.github.moulberry.repo.IReloadable
import io.github.moulberry.repo.NEURepository
import io.github.moulberry.repo.data.NEUIngredient
import io.github.moulberry.repo.data.NEURecipe
import moe.nea.firmament.util.SkyblockId

class EssenceRecipeProvider : IReloadable, ExtraRecipeProvider {
	data class EssenceUpgradeRecipe(
		val itemId: SkyblockId,
		val starCountAfter: Int,
		val essenceCost: Int,
		val essenceType: String, // TODO: replace with proper type
		val extraItems: List<NEUIngredient>,
	) : NEURecipe {
		val essenceIngredient = NEUIngredient.fromString("${essenceType}:$essenceCost")
		val allUpgradeComponents = listOf(essenceIngredient) + extraItems

		override fun getAllInputs(): Collection<NEUIngredient> {
			return listOf(NEUIngredient.fromString(itemId.neuItem + ":1")) + allUpgradeComponents
		}

		override fun getAllOutputs(): Collection<NEUIngredient> {
			return listOf(NEUIngredient.fromString(itemId.neuItem + ":1"))
		}
	}

	var recipes = listOf<EssenceUpgradeRecipe>()
		private set

	override fun provideExtraRecipes(): Iterable<NEURecipe> = recipes

	override fun reload(repository: NEURepository) {
		val recipes = mutableListOf<EssenceUpgradeRecipe>()
		for ((neuId, costs) in repository.constants.essenceCost.costs) {
			// TODO: add dungeonization costs. this is in repo, but not in the repo parser.
			for ((starCountAfter, essenceCost) in costs.essenceCosts.entries) {
				val items = costs.itemCosts[starCountAfter] ?: emptyList()
				recipes.add(
					EssenceUpgradeRecipe(
						SkyblockId(neuId),
						starCountAfter,
						essenceCost,
						"ESSENCE_" + costs.type.uppercase(), // how flimsy
						items.map { NEUIngredient.fromString(it) }))
			}
		}
		this.recipes = recipes
	}
}