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 emu.lunarcore.util.Utils;
|
||||||
import it.unimi.dsi.fastutil.ints.Int2IntMap;
|
import it.unimi.dsi.fastutil.ints.Int2IntMap;
|
||||||
import it.unimi.dsi.fastutil.ints.Int2IntOpenHashMap;
|
import it.unimi.dsi.fastutil.ints.Int2IntOpenHashMap;
|
||||||
|
import it.unimi.dsi.fastutil.objects.ObjectOpenHashSet;
|
||||||
|
import it.unimi.dsi.fastutil.objects.ObjectSet;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
@@ -28,6 +30,7 @@ public class CommandArgs {
|
|||||||
private int stage = -1;
|
private int stage = -1;
|
||||||
|
|
||||||
private Int2IntMap map;
|
private Int2IntMap map;
|
||||||
|
private ObjectSet<String> flags;
|
||||||
|
|
||||||
public CommandArgs(Player sender, List<String> args) {
|
public CommandArgs(Player sender, List<String> args) {
|
||||||
this.sender = sender;
|
this.sender = sender;
|
||||||
@@ -64,6 +67,10 @@ public class CommandArgs {
|
|||||||
this.stage = Utils.parseSafeInt(arg.substring(1));
|
this.stage = Utils.parseSafeInt(arg.substring(1));
|
||||||
it.remove();
|
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(":")) {
|
} else if (arg.contains(":")) {
|
||||||
String[] split = arg.split(":");
|
String[] split = arg.split(":");
|
||||||
if (split.length >= 2) {
|
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
|
// Utility commands
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -161,6 +173,17 @@ public class CommandArgs {
|
|||||||
hasChanged = true;
|
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;
|
return hasChanged;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -237,6 +260,15 @@ public class CommandArgs {
|
|||||||
|
|
||||||
hasChanged = true;
|
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;
|
return hasChanged;
|
||||||
|
|||||||
@@ -195,6 +195,17 @@ public class GameAvatar implements GameEntity {
|
|||||||
this.heroPath.setAvatar(this);
|
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) {
|
public boolean hasTakenReward(int promotion) {
|
||||||
return (this.rewards & (1 << promotion)) != 0;
|
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.proto.RelicAffixOuterClass.RelicAffix;
|
||||||
import emu.lunarcore.util.Utils;
|
import emu.lunarcore.util.Utils;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
|
import lombok.Setter;
|
||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
@Entity(useDiscriminator = false)
|
@Entity(useDiscriminator = false)
|
||||||
public class GameItemSubAffix {
|
public class GameItemSubAffix {
|
||||||
private int id; // Affix id
|
private int id; // Affix id
|
||||||
private int count;
|
|
||||||
private int step;
|
@Setter private int count;
|
||||||
|
@Setter private int step;
|
||||||
|
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public GameItemSubAffix() {
|
public GameItemSubAffix() {
|
||||||
|
|||||||
Reference in New Issue
Block a user