Skip to content

Commit

Permalink
配置干员指令添加空值
Browse files Browse the repository at this point in the history
  • Loading branch information
Funny-ppt committed Jan 23, 2024
1 parent eff6bb7 commit 04a0cdb
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions InfrastSim/TimeDriven/ScriptHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,17 @@ public static void SetOpState(Simulator simu, string[] args) {

var op = simu.GetOperatorNoThrow(args[0]) ??
throw new ScriptException($"{args[0]} 干员不存在");
if (!int.TryParse(args[1], out var upgraded)) {
int upgraded = -1;
double mood = double.NaN;

if (args[1] != "_" && !int.TryParse(args[1], out upgraded)) {
throw new ScriptException($"{args[1]} 不是一个有效的整数");
}
if (!double.TryParse(args[2], out var mood)) {
if (args[2] != "_" && !double.TryParse(args[2], out mood)) {
throw new ScriptException($"{args[2]} 不是一个有效的浮点数");
}
op.Upgraded = upgraded;
op.SetMood(mood);
if (upgraded != -1) op.Upgraded = upgraded;
if (mood != double.NaN) op.SetMood(mood);
}

[Alias(Language.CN, "设置等级")]
Expand Down

0 comments on commit 04a0cdb

Please sign in to comment.