mirror of
https://github.com/Melledy/Nebula.git
synced 2026-09-19 17:19:58 +02:00
Filter emblem elemental affixes not matching the trekker's element
This commit is contained in:
@@ -7,6 +7,7 @@ import emu.nebula.data.BaseDef;
|
||||
import emu.nebula.data.GameData;
|
||||
import emu.nebula.data.ResourceType;
|
||||
import emu.nebula.data.resources.CharGemAttrValueDef;
|
||||
import emu.nebula.game.character.GameCharacter;
|
||||
import emu.nebula.util.WeightedList;
|
||||
import it.unimi.dsi.fastutil.ints.IntArrayList;
|
||||
import it.unimi.dsi.fastutil.ints.IntList;
|
||||
@@ -42,7 +43,7 @@ public class CharGemAttrGroupDef extends BaseDef {
|
||||
return this.uniqueAttrNum.next();
|
||||
}
|
||||
|
||||
public CharGemAttrTypeData getRandomAttributeType(IntList list) {
|
||||
public CharGemAttrTypeData getRandomAttributeType(GameCharacter character, IntList list) {
|
||||
// Setup blacklist to prevent the same attribute from showing up twice
|
||||
var blacklist = new IntOpenHashSet();
|
||||
|
||||
@@ -58,13 +59,23 @@ public class CharGemAttrGroupDef extends BaseDef {
|
||||
var random = new WeightedList<CharGemAttrTypeData>();
|
||||
|
||||
for (var type : this.getAttributeTypes()) {
|
||||
// Don't add types that we already have in the emblem
|
||||
if (blacklist.contains(type.getId())) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// Skip attributes that don't match the trekker's element
|
||||
if (type.isElementalAttr() && !character.getElementType().getGemAttrTypes().contains(type.getFirstSubType())) {
|
||||
continue;
|
||||
}
|
||||
|
||||
random.add(100, type);
|
||||
}
|
||||
|
||||
if (random.size() == 0) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return random.next();
|
||||
}
|
||||
|
||||
@@ -91,6 +102,7 @@ public class CharGemAttrGroupDef extends BaseDef {
|
||||
@Getter
|
||||
public static class CharGemAttrTypeData {
|
||||
private int id;
|
||||
private int firstSubType;
|
||||
private WeightedList<CharGemAttrValueDef> values;
|
||||
|
||||
public CharGemAttrTypeData(int id) {
|
||||
@@ -98,7 +110,12 @@ public class CharGemAttrGroupDef extends BaseDef {
|
||||
this.values = new WeightedList<>();
|
||||
}
|
||||
|
||||
public boolean isElementalAttr() {
|
||||
return this.getFirstSubType() >= 17 && this.getFirstSubType() <= 28;
|
||||
}
|
||||
|
||||
public void addValue(CharGemAttrValueDef value) {
|
||||
this.firstSubType = value.getAttrTypeFirstSubtype();
|
||||
this.values.add(value.getRarity(), value);
|
||||
}
|
||||
|
||||
|
||||
@@ -12,6 +12,7 @@ public class CharGemAttrValueDef extends BaseDef {
|
||||
private int Id;
|
||||
private int TypeId;
|
||||
private int AttrType;
|
||||
private int AttrTypeFirstSubtype;
|
||||
private int Rarity;
|
||||
|
||||
@Override
|
||||
|
||||
@@ -4,6 +4,7 @@ import emu.nebula.data.BaseDef;
|
||||
import emu.nebula.data.GameData;
|
||||
import emu.nebula.data.ResourceType;
|
||||
import emu.nebula.data.custom.CharGemAttrGroupDef;
|
||||
import emu.nebula.game.character.GameCharacter;
|
||||
import emu.nebula.util.Utils;
|
||||
import emu.nebula.util.WeightedList;
|
||||
import emu.nebula.util.ints.CustomIntArray;
|
||||
@@ -35,8 +36,8 @@ public class CharGemSlotControlDef extends BaseDef {
|
||||
return Id;
|
||||
}
|
||||
|
||||
public IntList generateAttributes() {
|
||||
return this.generateAttributes(new CustomIntArray());
|
||||
public IntList generateAttributes(GameCharacter character) {
|
||||
return this.generateAttributes(character, new CustomIntArray());
|
||||
}
|
||||
|
||||
// Check if we should add unique attributes based on the probablity
|
||||
@@ -45,14 +46,18 @@ public class CharGemSlotControlDef extends BaseDef {
|
||||
return random <= this.UniqueAttrGroupProb;
|
||||
}
|
||||
|
||||
public IntList generateAttributes(CustomIntArray list) {
|
||||
public IntList generateAttributes(GameCharacter character, CustomIntArray list) {
|
||||
// Add unique attributes
|
||||
if (this.UniqueAttrGroupId > 0 && this.shouldAddUniqueAttr()) {
|
||||
var group = GameData.getCharGemAttrGroupDataTable().get(this.UniqueAttrGroupId);
|
||||
int num = group.getRandomUniqueAttrNum();
|
||||
|
||||
for (int i = 0; i < num; i++) {
|
||||
var attributeType = group.getRandomAttributeType(list);
|
||||
var attributeType = group.getRandomAttributeType(character, list);
|
||||
if (attributeType == null) {
|
||||
break;
|
||||
}
|
||||
|
||||
list.add(attributeType.getRandomValue());
|
||||
}
|
||||
|
||||
@@ -76,7 +81,8 @@ public class CharGemSlotControlDef extends BaseDef {
|
||||
// Add up to 4 attributes
|
||||
while (list.getValueCount() < this.MaxAlterNum) {
|
||||
var group = random.next();
|
||||
var attributeType = group.getRandomAttributeType(list);
|
||||
var attributeType = group.getRandomAttributeType(character, list);
|
||||
|
||||
list.add(attributeType.getRandomValue());
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user