mirror of
https://github.com/Grasscutters/Grasscutter.git
synced 2026-02-08 02:56:45 +01:00
Run Spotless on src/main
This commit is contained in:
@@ -1,19 +1,19 @@
|
||||
package emu.grasscutter.data.common;
|
||||
|
||||
public class CurveInfo {
|
||||
private String type;
|
||||
private String arith;
|
||||
private float value;
|
||||
|
||||
public String getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public String getArith() {
|
||||
return arith;
|
||||
}
|
||||
|
||||
public float getValue() {
|
||||
return value;
|
||||
}
|
||||
}
|
||||
package emu.grasscutter.data.common;
|
||||
|
||||
public class CurveInfo {
|
||||
private String type;
|
||||
private String arith;
|
||||
private float value;
|
||||
|
||||
public String getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public String getArith() {
|
||||
return arith;
|
||||
}
|
||||
|
||||
public float getValue() {
|
||||
return value;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,97 +1,105 @@
|
||||
package emu.grasscutter.data.common;
|
||||
|
||||
import it.unimi.dsi.fastutil.floats.FloatArrayList;
|
||||
import it.unimi.dsi.fastutil.objects.Object2FloatArrayMap;
|
||||
import it.unimi.dsi.fastutil.objects.Object2FloatMap;
|
||||
import lombok.val;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
public class DynamicFloat {
|
||||
public static DynamicFloat ZERO = new DynamicFloat(0f);
|
||||
private List<StackOp> ops;
|
||||
private boolean dynamic = false;
|
||||
private float constant = 0f;
|
||||
public DynamicFloat(float constant) {
|
||||
this.constant = constant;
|
||||
}
|
||||
|
||||
public DynamicFloat(String key) {
|
||||
this.dynamic = true;
|
||||
this.ops = List.of(new StackOp(key));
|
||||
}
|
||||
|
||||
public DynamicFloat(boolean b) {
|
||||
this.dynamic = true;
|
||||
this.ops = List.of(new StackOp(String.valueOf(b)));
|
||||
}
|
||||
|
||||
public DynamicFloat(List<StackOp> ops) {
|
||||
this.dynamic = true;
|
||||
this.ops = ops;
|
||||
}
|
||||
|
||||
public String toString(boolean nextBoolean) {
|
||||
String key = String.valueOf(nextBoolean);
|
||||
this.ops = List.of(new StackOp(key));
|
||||
return ops.toString();
|
||||
}
|
||||
|
||||
public float get() {
|
||||
return this.get(new Object2FloatArrayMap<String>());
|
||||
}
|
||||
|
||||
public float get(Object2FloatMap<String> props) {
|
||||
if (!dynamic)
|
||||
return constant;
|
||||
|
||||
val fl = new FloatArrayList();
|
||||
for (var op : this.ops) {
|
||||
switch (op.op) {
|
||||
case CONSTANT -> fl.push(op.fValue);
|
||||
case KEY -> fl.push(props.getOrDefault(op.sValue, 0f));
|
||||
case ADD -> fl.push(fl.popFloat() + fl.popFloat());
|
||||
case SUB ->
|
||||
fl.push(-fl.popFloat() + fl.popFloat()); // [f0, f1, f2] -> [f0, f1-f2] (opposite of RPN order)
|
||||
case MUL -> fl.push(fl.popFloat() * fl.popFloat());
|
||||
case DIV -> fl.push((1f / fl.popFloat()) * fl.popFloat()); // [f0, f1, f2] -> [f0, f1/f2]
|
||||
case NEXBOOLEAN -> fl.push(props.getOrDefault(Optional.of(op.bValue), 0f));
|
||||
}
|
||||
}
|
||||
|
||||
return fl.popFloat(); // well-formed data will always have only one value left at this point
|
||||
}
|
||||
|
||||
public static class StackOp {
|
||||
public Op op;
|
||||
|
||||
public float fValue;
|
||||
public String sValue;
|
||||
public boolean bValue;
|
||||
public StackOp(String s) {
|
||||
switch (s.toUpperCase()) {
|
||||
case "ADD" -> this.op = Op.ADD;
|
||||
case "SUB" -> this.op = Op.SUB;
|
||||
case "MUL" -> this.op = Op.MUL;
|
||||
case "DIV" -> this.op = Op.DIV;
|
||||
default -> {
|
||||
this.op = Op.KEY;
|
||||
this.sValue = s;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public StackOp(boolean b) {
|
||||
this.op = Op.NEXBOOLEAN;
|
||||
this.bValue = Boolean.parseBoolean(String.valueOf(b));
|
||||
}
|
||||
|
||||
public StackOp(float f) {
|
||||
this.op = Op.CONSTANT;
|
||||
this.fValue = f;
|
||||
}
|
||||
|
||||
enum Op {CONSTANT, KEY, ADD, SUB, MUL, DIV, NEXBOOLEAN}
|
||||
}
|
||||
}
|
||||
package emu.grasscutter.data.common;
|
||||
|
||||
import it.unimi.dsi.fastutil.floats.FloatArrayList;
|
||||
import it.unimi.dsi.fastutil.objects.Object2FloatArrayMap;
|
||||
import it.unimi.dsi.fastutil.objects.Object2FloatMap;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import lombok.val;
|
||||
|
||||
public class DynamicFloat {
|
||||
public static DynamicFloat ZERO = new DynamicFloat(0f);
|
||||
private List<StackOp> ops;
|
||||
private boolean dynamic = false;
|
||||
private float constant = 0f;
|
||||
|
||||
public DynamicFloat(float constant) {
|
||||
this.constant = constant;
|
||||
}
|
||||
|
||||
public DynamicFloat(String key) {
|
||||
this.dynamic = true;
|
||||
this.ops = List.of(new StackOp(key));
|
||||
}
|
||||
|
||||
public DynamicFloat(boolean b) {
|
||||
this.dynamic = true;
|
||||
this.ops = List.of(new StackOp(String.valueOf(b)));
|
||||
}
|
||||
|
||||
public DynamicFloat(List<StackOp> ops) {
|
||||
this.dynamic = true;
|
||||
this.ops = ops;
|
||||
}
|
||||
|
||||
public String toString(boolean nextBoolean) {
|
||||
String key = String.valueOf(nextBoolean);
|
||||
this.ops = List.of(new StackOp(key));
|
||||
return ops.toString();
|
||||
}
|
||||
|
||||
public float get() {
|
||||
return this.get(new Object2FloatArrayMap<String>());
|
||||
}
|
||||
|
||||
public float get(Object2FloatMap<String> props) {
|
||||
if (!dynamic) return constant;
|
||||
|
||||
val fl = new FloatArrayList();
|
||||
for (var op : this.ops) {
|
||||
switch (op.op) {
|
||||
case CONSTANT -> fl.push(op.fValue);
|
||||
case KEY -> fl.push(props.getOrDefault(op.sValue, 0f));
|
||||
case ADD -> fl.push(fl.popFloat() + fl.popFloat());
|
||||
case SUB -> fl.push(
|
||||
-fl.popFloat() + fl.popFloat()); // [f0, f1, f2] -> [f0, f1-f2] (opposite of RPN order)
|
||||
case MUL -> fl.push(fl.popFloat() * fl.popFloat());
|
||||
case DIV -> fl.push((1f / fl.popFloat()) * fl.popFloat()); // [f0, f1, f2] -> [f0, f1/f2]
|
||||
case NEXBOOLEAN -> fl.push(props.getOrDefault(Optional.of(op.bValue), 0f));
|
||||
}
|
||||
}
|
||||
|
||||
return fl.popFloat(); // well-formed data will always have only one value left at this point
|
||||
}
|
||||
|
||||
public static class StackOp {
|
||||
public Op op;
|
||||
|
||||
public float fValue;
|
||||
public String sValue;
|
||||
public boolean bValue;
|
||||
|
||||
public StackOp(String s) {
|
||||
switch (s.toUpperCase()) {
|
||||
case "ADD" -> this.op = Op.ADD;
|
||||
case "SUB" -> this.op = Op.SUB;
|
||||
case "MUL" -> this.op = Op.MUL;
|
||||
case "DIV" -> this.op = Op.DIV;
|
||||
default -> {
|
||||
this.op = Op.KEY;
|
||||
this.sValue = s;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public StackOp(boolean b) {
|
||||
this.op = Op.NEXBOOLEAN;
|
||||
this.bValue = Boolean.parseBoolean(String.valueOf(b));
|
||||
}
|
||||
|
||||
public StackOp(float f) {
|
||||
this.op = Op.CONSTANT;
|
||||
this.fValue = f;
|
||||
}
|
||||
|
||||
enum Op {
|
||||
CONSTANT,
|
||||
KEY,
|
||||
ADD,
|
||||
SUB,
|
||||
MUL,
|
||||
DIV,
|
||||
NEXBOOLEAN
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,25 +1,25 @@
|
||||
package emu.grasscutter.data.common;
|
||||
|
||||
import emu.grasscutter.game.props.FightProperty;
|
||||
|
||||
public class FightPropData {
|
||||
private String propType;
|
||||
private FightProperty prop;
|
||||
private float value;
|
||||
|
||||
public String getPropType() {
|
||||
return propType;
|
||||
}
|
||||
|
||||
public float getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public FightProperty getProp() {
|
||||
return prop;
|
||||
}
|
||||
|
||||
public void onLoad() {
|
||||
this.prop = FightProperty.getPropByName(propType);
|
||||
}
|
||||
}
|
||||
package emu.grasscutter.data.common;
|
||||
|
||||
import emu.grasscutter.game.props.FightProperty;
|
||||
|
||||
public class FightPropData {
|
||||
private String propType;
|
||||
private FightProperty prop;
|
||||
private float value;
|
||||
|
||||
public String getPropType() {
|
||||
return propType;
|
||||
}
|
||||
|
||||
public float getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public FightProperty getProp() {
|
||||
return prop;
|
||||
}
|
||||
|
||||
public void onLoad() {
|
||||
this.prop = FightProperty.getPropByName(propType);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,36 +1,39 @@
|
||||
package emu.grasscutter.data.common;
|
||||
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
|
||||
// Used in excels
|
||||
public class ItemParamData {
|
||||
@SerializedName(value = "id", alternate = {"itemId"})
|
||||
private int id;
|
||||
|
||||
@SerializedName(value = "count", alternate = {"itemCount"})
|
||||
private int count;
|
||||
|
||||
public ItemParamData() {
|
||||
}
|
||||
|
||||
public ItemParamData(int id, int count) {
|
||||
this.id = id;
|
||||
this.count = count;
|
||||
}
|
||||
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public int getItemId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public int getCount() {
|
||||
return count;
|
||||
}
|
||||
|
||||
public int getItemCount() {
|
||||
return count;
|
||||
}
|
||||
}
|
||||
package emu.grasscutter.data.common;
|
||||
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
|
||||
// Used in excels
|
||||
public class ItemParamData {
|
||||
@SerializedName(
|
||||
value = "id",
|
||||
alternate = {"itemId"})
|
||||
private int id;
|
||||
|
||||
@SerializedName(
|
||||
value = "count",
|
||||
alternate = {"itemCount"})
|
||||
private int count;
|
||||
|
||||
public ItemParamData() {}
|
||||
|
||||
public ItemParamData(int id, int count) {
|
||||
this.id = id;
|
||||
this.count = count;
|
||||
}
|
||||
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public int getItemId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public int getCount() {
|
||||
return count;
|
||||
}
|
||||
|
||||
public int getItemCount() {
|
||||
return count;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,27 +1,26 @@
|
||||
package emu.grasscutter.data.common;
|
||||
|
||||
public class ItemParamStringData {
|
||||
private int id;
|
||||
private String count;
|
||||
|
||||
public ItemParamStringData() {
|
||||
}
|
||||
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public String getCount() {
|
||||
return count;
|
||||
}
|
||||
|
||||
public ItemParamData toItemParamData() {
|
||||
if (count.contains(";")) {
|
||||
String[] split = count.split(";");
|
||||
count = count.split(";")[split.length - 1];
|
||||
} else if (count.contains(".")) {
|
||||
return new ItemParamData(id, (int) Math.ceil(Double.parseDouble(count)));
|
||||
}
|
||||
return new ItemParamData(id, Integer.parseInt(count));
|
||||
}
|
||||
}
|
||||
package emu.grasscutter.data.common;
|
||||
|
||||
public class ItemParamStringData {
|
||||
private int id;
|
||||
private String count;
|
||||
|
||||
public ItemParamStringData() {}
|
||||
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public String getCount() {
|
||||
return count;
|
||||
}
|
||||
|
||||
public ItemParamData toItemParamData() {
|
||||
if (count.contains(";")) {
|
||||
String[] split = count.split(";");
|
||||
count = count.split(";")[split.length - 1];
|
||||
} else if (count.contains(".")) {
|
||||
return new ItemParamData(id, (int) Math.ceil(Double.parseDouble(count)));
|
||||
}
|
||||
return new ItemParamData(id, Integer.parseInt(count));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,58 +1,61 @@
|
||||
package emu.grasscutter.data.common;
|
||||
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
import emu.grasscutter.Grasscutter;
|
||||
import emu.grasscutter.data.GameData;
|
||||
import emu.grasscutter.data.excels.DailyDungeonData;
|
||||
import emu.grasscutter.utils.Position;
|
||||
import it.unimi.dsi.fastutil.ints.IntArrayList;
|
||||
import it.unimi.dsi.fastutil.ints.IntList;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
public class PointData {
|
||||
@Getter
|
||||
@Setter
|
||||
private int id;
|
||||
private String $type;
|
||||
@Getter
|
||||
private Position tranPos;
|
||||
|
||||
@SerializedName(value = "dungeonIds", alternate = {"JHHFPGJNMIN"})
|
||||
@Getter
|
||||
private int[] dungeonIds;
|
||||
|
||||
@SerializedName(value = "dungeonRandomList", alternate = {"OIBKFJNBLHO"})
|
||||
@Getter
|
||||
private int[] dungeonRandomList;
|
||||
|
||||
@SerializedName(value = "tranSceneId", alternate = {"JHBICGBAPIH"})
|
||||
@Getter
|
||||
@Setter
|
||||
private int tranSceneId;
|
||||
|
||||
public String getType() {
|
||||
return $type;
|
||||
}
|
||||
|
||||
public void updateDailyDungeon() {
|
||||
if (this.dungeonRandomList == null || this.dungeonRandomList.length == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
IntList newDungeons = new IntArrayList();
|
||||
int day = Grasscutter.getCurrentDayOfWeek();
|
||||
|
||||
for (int randomId : this.dungeonRandomList) {
|
||||
DailyDungeonData data = GameData.getDailyDungeonDataMap().get(randomId);
|
||||
|
||||
if (data != null) {
|
||||
for (int d : data.getDungeonsByDay(day)) {
|
||||
newDungeons.add(d);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
this.dungeonIds = newDungeons.toIntArray();
|
||||
}
|
||||
}
|
||||
package emu.grasscutter.data.common;
|
||||
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
import emu.grasscutter.Grasscutter;
|
||||
import emu.grasscutter.data.GameData;
|
||||
import emu.grasscutter.data.excels.DailyDungeonData;
|
||||
import emu.grasscutter.utils.Position;
|
||||
import it.unimi.dsi.fastutil.ints.IntArrayList;
|
||||
import it.unimi.dsi.fastutil.ints.IntList;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
public class PointData {
|
||||
@Getter @Setter private int id;
|
||||
private String $type;
|
||||
@Getter private Position tranPos;
|
||||
|
||||
@SerializedName(
|
||||
value = "dungeonIds",
|
||||
alternate = {"JHHFPGJNMIN"})
|
||||
@Getter
|
||||
private int[] dungeonIds;
|
||||
|
||||
@SerializedName(
|
||||
value = "dungeonRandomList",
|
||||
alternate = {"OIBKFJNBLHO"})
|
||||
@Getter
|
||||
private int[] dungeonRandomList;
|
||||
|
||||
@SerializedName(
|
||||
value = "tranSceneId",
|
||||
alternate = {"JHBICGBAPIH"})
|
||||
@Getter
|
||||
@Setter
|
||||
private int tranSceneId;
|
||||
|
||||
public String getType() {
|
||||
return $type;
|
||||
}
|
||||
|
||||
public void updateDailyDungeon() {
|
||||
if (this.dungeonRandomList == null || this.dungeonRandomList.length == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
IntList newDungeons = new IntArrayList();
|
||||
int day = Grasscutter.getCurrentDayOfWeek();
|
||||
|
||||
for (int randomId : this.dungeonRandomList) {
|
||||
DailyDungeonData data = GameData.getDailyDungeonDataMap().get(randomId);
|
||||
|
||||
if (data != null) {
|
||||
for (int d : data.getDungeonsByDay(day)) {
|
||||
newDungeons.add(d);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
this.dungeonIds = newDungeons.toIntArray();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,15 +1,14 @@
|
||||
package emu.grasscutter.data.common;
|
||||
|
||||
public class PropGrowCurve {
|
||||
private String type;
|
||||
private String growCurve;
|
||||
|
||||
public String getType() {
|
||||
return this.type;
|
||||
}
|
||||
|
||||
public String getGrowCurve() {
|
||||
return this.growCurve;
|
||||
}
|
||||
|
||||
}
|
||||
package emu.grasscutter.data.common;
|
||||
|
||||
public class PropGrowCurve {
|
||||
private String type;
|
||||
private String growCurve;
|
||||
|
||||
public String getType() {
|
||||
return this.type;
|
||||
}
|
||||
|
||||
public String getGrowCurve() {
|
||||
return this.growCurve;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user