mirror of
https://github.com/Melledy/LunarCore.git
synced 2025-12-17 15:54:36 +01:00
Add -maxsteps and -takerewards flags to commands
This commit is contained in:
@@ -11,6 +11,8 @@ import emu.lunarcore.game.player.Player;
|
||||
import emu.lunarcore.util.Utils;
|
||||
import it.unimi.dsi.fastutil.ints.Int2IntMap;
|
||||
import it.unimi.dsi.fastutil.ints.Int2IntOpenHashMap;
|
||||
import it.unimi.dsi.fastutil.objects.ObjectOpenHashSet;
|
||||
import it.unimi.dsi.fastutil.objects.ObjectSet;
|
||||
import lombok.Getter;
|
||||
|
||||
@Getter
|
||||
@@ -28,6 +30,7 @@ public class CommandArgs {
|
||||
private int stage = -1;
|
||||
|
||||
private Int2IntMap map;
|
||||
private ObjectSet<String> flags;
|
||||
|
||||
public CommandArgs(Player sender, List<String> args) {
|
||||
this.sender = sender;
|
||||
@@ -64,6 +67,10 @@ public class CommandArgs {
|
||||
this.stage = Utils.parseSafeInt(arg.substring(1));
|
||||
it.remove();
|
||||
}
|
||||
} else if (arg.startsWith("-")) { // Flag
|
||||
if (this.flags == null) this.flags = new ObjectOpenHashSet<>();
|
||||
this.flags.add(arg);
|
||||
it.remove();
|
||||
} else if (arg.contains(":")) {
|
||||
String[] split = arg.split(":");
|
||||
if (split.length >= 2) {
|
||||
@@ -118,6 +125,11 @@ public class CommandArgs {
|
||||
}
|
||||
}
|
||||
|
||||
public boolean hasFlag(String flag) {
|
||||
if (this.flags == null) return false;
|
||||
return this.flags.contains(flag);
|
||||
}
|
||||
|
||||
// Utility commands
|
||||
|
||||
/**
|
||||
@@ -161,6 +173,17 @@ public class CommandArgs {
|
||||
hasChanged = true;
|
||||
}
|
||||
|
||||
// Handle flags
|
||||
if (this.hasFlag("-takerewards")) {
|
||||
if (avatar.setRewards(0b00101010)) {
|
||||
hasChanged = true;
|
||||
}
|
||||
} else if (this.hasFlag("-clearrewards")) {
|
||||
if (avatar.setRewards(0)) { // Note: Requires the player to restart their game to show
|
||||
hasChanged = true;
|
||||
}
|
||||
}
|
||||
|
||||
return hasChanged;
|
||||
}
|
||||
|
||||
@@ -237,6 +260,15 @@ public class CommandArgs {
|
||||
|
||||
hasChanged = true;
|
||||
}
|
||||
|
||||
// Handle flags
|
||||
if (this.hasFlag("-maxsteps")) {
|
||||
if (item.getSubAffixes() == null) {
|
||||
item.resetSubAffixes();
|
||||
}
|
||||
|
||||
item.getSubAffixes().forEach(subAffix -> subAffix.setStep(subAffix.getCount() * 2));
|
||||
}
|
||||
}
|
||||
|
||||
return hasChanged;
|
||||
|
||||
@@ -195,6 +195,17 @@ public class GameAvatar implements GameEntity {
|
||||
this.heroPath.setAvatar(this);
|
||||
}
|
||||
|
||||
// Rewards
|
||||
|
||||
public boolean setRewards(int flag) {
|
||||
if (this.rewards != flag) {
|
||||
this.rewards = flag;
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean hasTakenReward(int promotion) {
|
||||
return (this.rewards & (1 << promotion)) != 0;
|
||||
}
|
||||
|
||||
@@ -5,13 +5,15 @@ import emu.lunarcore.data.excel.RelicSubAffixExcel;
|
||||
import emu.lunarcore.proto.RelicAffixOuterClass.RelicAffix;
|
||||
import emu.lunarcore.util.Utils;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
@Getter
|
||||
@Entity(useDiscriminator = false)
|
||||
public class GameItemSubAffix {
|
||||
private int id; // Affix id
|
||||
private int count;
|
||||
private int step;
|
||||
|
||||
@Setter private int count;
|
||||
@Setter private int step;
|
||||
|
||||
@Deprecated
|
||||
public GameItemSubAffix() {
|
||||
|
||||
Reference in New Issue
Block a user