Artifact Data
This page will tell you how to get data from an Artifact (by fetching data)
Getting artifact main & sub stats
To retrieve artifact main & sub stats, you need to retrieve data from a uid first. You can then callgetArtifacts
on the character.
Calling ArtifactStat#getStat
will return the main stat. Such as "Energy Recharge", "CRIT Rate", "HP", "ATK"
ArtifactStat#getFormattedValue
will return 123% for Energy Recharge (any other % stats will also be included in this) while ArtifactStat#getRawValue
will return the raw value, such as 123.0 for this example.
api.fetchGenshinUser(722777337, (user) -> {
final GenshinUserInformation info = user.toGenshinUser();
for (GenshinUserCharacter character : info.getCharacters()) {
for (GenshinArtifact artifact : character.getArtifacts()) {
final GenshinArtifact.ArtifactStat main = artifact.getMainStats();
final String stat = main.getStat();
final String value = main.getFormattedValue();
}
}
});
From this GenshinArtifact instance you will be able to get the substats, to do this just simply call getSubStats
on GenshinArtifact
. You can then call the same functions as above to get stat identifier, formatted value, raw value.
getArtifacts
may not always have a list of 5 items, if a user decides to remove an artifact, the list size will be changed, so you should avoid calling get
with fixed indexes and instead loop through the artifacts or substats.
Getting level of artifact & icon identifier
To get the level and icon identifier of an artifact, you can call getLevel
on GenshinArtifact
. The level of an artifact will be a range from 0 to 20.
To get the icon identifier you can call getIcon
on GenshinArtifact
. If you have fetched the identifier you can retrieve the URL by Retrieving image png's.
api.fetchGenshinUser(722777337, (user) -> {
final GenshinUserInformation info = user.toGenshinUser();
for (GenshinUserCharacter character : info.getCharacters()) {
for (GenshinArtifact artifact : character.getArtifacts()) {
final int level = artifact.getLevel();
final String icon = artifact.getIcon();
final String iconURL = api.getGenshinIcon(icon);
}
}
});
Getting name, set name of artifact
In order to retrieve the name of the artifact you need to use getName
on GenshinArtifact
. Same thing applies for the set name.
api.fetchGenshinUser(722777337, (user) -> {
final GenshinUserInformation info = user.toGenshinUser();
for (GenshinUserCharacter character : info.getCharacters()) {
for (GenshinArtifact artifact : character.getArtifacts()) {
final String name = artifact.getName();
final String setName = artifact.getSetName();
System.out.println(name);
System.out.println(setName);
}
}
});
Calculating Roll Data
In this example I am showing calculation of roll data for one artifact. If you would like to calculate all then you need to put data from all artifacts in a Map.
So, we firstly need to define what a "min" and "max" roll is. When rolling CRIT Rate on an artifact, it can have 4 outcomes:
2,7%
Low
0.7
3,1%
Low
0.8
3,5%
Low
0.9
3,9%
High
1
The "effective value" takes count for every single stat, and also ranges from 0.7 to 1, and is also called Affix, where we will be using the class GenshinAffix
later in the code.
final GenshinArtifact artifact = ...;
final GenshinRollData rollData = artifact.getRollData(...);
rollData.getEfficiencyList().entrySet().forEach((entry) -> {
final int key = entry.getKey();
final double totalRv = entry.getValue();
final GenshinAffix affix = api.getGenshinAffix(key);
if (affix == null) return;
final String propType = affix.getPropType();
System.out.println(propType + " : " + totalRv)
});
With this code, we should get the an output like this:
FIGHT_PROP_CRITICAL_HURT : 1.8
FIGHT_PROP_CRITICAL : 1.6
FIGHT_PROP_CRITICAL : 0.7
FIGHT_PROP_CHARGE_EFFICIENCY : 0.9
FIGHT_PROP_CHARGE_EFFICIENCY : 0.8
FIGHT_PROP_ATTACK_PERCENT : 1.0
This means that we had 2 rolls (each 0.9 RV) into CRIT DMG, 2 rolls (each 0.8 RV) into Crit Rate, 1 roll (0.7 RV) into Crit Rate and so on...
getEfficiencyList()
is already calculating the different affixes together and adding them into the total RV count. If you wish to get each roll individually then you will need to calculate the roll count by moduling by the effective values.
Calculating Roll Value individually
// other code
final double totalRv = entry.getValue();
final int rollCount = getRollCount(rv);
final double individualRv = totalRv / rollCount;
private int getRollCount(final double rv) {
int out = 0;
for (double i = 0.7D; i <= 1.0D ; i += 0.1D) {
if ((rv % i) < 0.001D) { // Yeah... floating point precision
out = (int) (rv / i);
}
}
return out;
}
FIGHT_PROP_CRITICAL_HURT |2|0.9|
FIGHT_PROP_CRITICAL |2|0.8|
FIGHT_PROP_CRITICAL |1|0.7|
FIGHT_PROP_CHARGE_EFFICIENCY |1|0.9|
FIGHT_PROP_CHARGE_EFFICIENCY |1|0.8|
FIGHT_PROP_ATTACK_PERCENT |1|1.0|
Last updated
Was this helpful?