Material Calculation
This page will tell you how to calculate weapon, character, artifact costs.
Calculating Character Ascension Materials
To do this, you can use the following code snippet:
// you need to call this to load caches once,
// if you already have this somewhere in your code, don't bother.
new EnkaNetworkAPI();
// We are saying that our character is ascension 0,
// and we want all items up to ascension 6 (Level 90)
// 10000026 = Xiao
final GenshinCalculator calculator = GenshinCalculator.create(CalculatorType.CHARACTER)
.setCurrentAscensionLevel(0)
.setTargetAscensionLevel(6)
.setCharacterId(10000026);
final List<GenshinAscensionMaterial> materials = calculator.calculate();
for (GenshinAscensionMaterial material : materials) {
final GenshinMaterial genshinMaterial = material.getItem();
System.out.println("x" + material.getAmount() + " " + genshinMaterial.getName());
}Expected output:
x1 Vayuda Turquoise Sliver
x3 Qingxin
x3 Slime Condensate
x3 Vayuda Turquoise Fragment
x2 Juvenile Jade
x10 Qingxin
x15 Slime Condensate
...
x420000 MoraPredefined Character object
Lets say, you don't have an id of a character or just want to calculate the ascension cost of ANY character within fetching a user. To do this we can just use the predefined createCharacter method.
final EnkaNetworkAPI api = ...;
final long uid = ...;
api.fetchGenshinUser(uid, (user) -> {
final GenshinUserInformation converted = user.toGenshinUser();
for (GenshinUserCharacter character : converted.getCharacters()) {
final GenshinCalculator calculator = GenshinCalculator.createCharacter(character, 6);
final List<GenshinAscensionMaterial> materials = calculator.calculate();
for (GenshinAscensionMaterial material : materials) {
final GenshinMaterial genshinMaterial = material.getItem();
System.out.println("x" + material.getAmount() + " " + genshinMaterial.getName());
}
}
});Note that this is the same concept for Honkai: Star Rail and I hope I don't need to explain how do this for artifacts & weapons.
I will leave a table below which shows what each factory method needs in order to work / not give an IllegalArgumentException.
setCurrentArtifactRarity(x)
setWeaponId(x)
setCharacterId(x)
setCharacterId(x)
setCurrentArtifactLevel(y)
setCurrentAscensionLevel(y)
setCurrentAscensionLevel(y)
setCurrentTalents(y)
setTargetArtifactLevel(z)
setTargetAscensionLevel(z)
setTargetAscensionLevel(z)
setTargetTalentDesire(z)
Last updated
Was this helpful?