Skip to content

Commit

Permalink
优化数据输出
Browse files Browse the repository at this point in the history
  • Loading branch information
Funny-ppt committed Mar 23, 2024
1 parent 087fb16 commit db0c063
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 11 deletions.
2 changes: 1 addition & 1 deletion InfrastSim/TimeDriven/FacilityBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ public void ToJson(Utf8JsonWriter writer, bool detailed = false) {

if (detailed) {
writer.WriteNumber("base-efficiency", (100 + EffiencyModifier) / 100.0);
writer.WriteNumber("operators-efficiency", WorkingOperators.Sum(op => op.EfficiencyModifier));
writer.WriteNumber("operators-efficiency", WorkingOperators.Sum(op => op.EfficiencyModifier) / 100.0);
}

writer.WriteEndObject();
Expand Down
2 changes: 1 addition & 1 deletion InfrastSim/TimeDriven/ManufacturingStation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,8 @@ public int ApplyDrones(Simulator simu, int amount) {

protected override void WriteDerivedContent(Utf8JsonWriter writer, bool detailed = false) {
writer.WriteNumber("product-index", Array.IndexOf(Product.AllProducts, Product));
writer.WriteNumber("progress", Progress);
writer.WriteNumber("product-count", ProductCount);
writer.WriteNumber("progress", Progress);

if (detailed) {
if (Product != null) writer.WriteString("product", Product.Name);
Expand Down
16 changes: 8 additions & 8 deletions InfrastSim/TimeDriven/Simulator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -361,15 +361,15 @@ public void ToJson(Utf8JsonWriter writer, bool detailed = false) {
Random.ToJson(writer);
writer.WriteNumber("drones", _drones);
writer.WriteNumber("refresh", _refresh);
writer.WriteNumber("total-manu-product", _totalManuProgress);
writer.WriteNumber("total-trad-product", _totalTradProgress);
writer.WriteNumber("total-office-product", _totalOfficeProgress);
writer.WriteNumber("total-drones-product", _totalDronesProgress);
writer.WriteNumber("total-manu-progress", _totalManuProgress);
writer.WriteNumber("total-trad-progress", _totalTradProgress);
writer.WriteNumber("total-office-progress", _totalOfficeProgress);
writer.WriteNumber("total-drones-progress", _totalDronesProgress);
if (detailed) {
writer.WriteNumber("drones-efficiency", DronesEfficiency);
writer.WriteNumber("office-efficiency", OfficeEfficiency);
writer.WriteNumber("manufacturing-efficiency", ManufacturingEfficiency);
writer.WriteNumber("trading-efficiency", TradingEfficiency);
writer.WriteNumber("drones-efficiency", DronesEfficiency / 100.0);
writer.WriteNumber("office-efficiency", OfficeEfficiency / 100.0);
writer.WriteNumber("manufacturing-efficiency", ManufacturingEfficiency / 100.0);
writer.WriteNumber("trading-efficiency", TradingEfficiency / 100.0);
}

writer.WritePropertyName("operators");
Expand Down
2 changes: 1 addition & 1 deletion InfrastSim/TimeDriven/TradingStation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -140,9 +140,9 @@ public int ApplyDrones(Simulator simu, int amount) {


protected override void WriteDerivedContent(Utf8JsonWriter writer, bool detailed = false) {
writer.WriteString("strategy", Strategy.ToString());
writer.WriteItem("current-order", CurrentOrder, detailed);
writer.WriteNumber("progress", Progress); ;
writer.WriteString("strategy", Strategy.ToString());
writer.WritePropertyName("orders");
writer.WriteStartArray();
foreach (var order in Orders) {
Expand Down

0 comments on commit db0c063

Please sign in to comment.