击杀阵亡比

This commit is contained in:
lanyi 2021-10-20 22:40:03 +02:00
parent 0863b2fd71
commit 2a96f8efac
3 changed files with 22 additions and 12 deletions

View File

@ -116,6 +116,14 @@ namespace AnotherReplayReader.Apm
dataList.Add(new("局域网 IP", plotter.Players.Select(GetIpAndName))); dataList.Add(new("局域网 IP", plotter.Players.Select(GetIpAndName)));
} }
apmRowIndex = dataList.Count; apmRowIndex = dataList.Count;
// kill-death ratio
if (plotter.Replay.Footer?.TryGetKillDeathRatios() is { } kdRatios)
{
var texts = kdRatios
.Take(plotter.Players.Length)
.Select(x => $"{x:0.##}");
dataList.Add(new("击杀阵亡比(存疑)", texts));
}
// get commands // get commands
var commandCounts = plotter.GetCommandCounts(begin, end); var commandCounts = plotter.GetCommandCounts(begin, end);
// add commands in the order specified by the list // add commands in the order specified by the list

View File

@ -112,13 +112,13 @@ namespace AnotherReplayReader
} }
return plotter.PlayerLifes[i] < begin return plotter.PlayerLifes[i] < begin
? "玩家已战败" ? "玩家已战败"
: $"{v:#.##}"; : $"{v:0.##}";
} }
list.Insert(apmIndex, new(DataRow.PartialApmRow, list.Insert(apmIndex, new(DataRow.PartialApmRow,
instantApms.Select(PartialApmToString))); instantApms.Select(PartialApmToString)));
} }
list.Insert(apmIndex, new(DataRow.AverageApmRow, list.Insert(apmIndex, new(DataRow.AverageApmRow,
avg.Select(v => $"{v:#.##}"))); avg.Select(v => $"{v:0.##}")));
return (list, data, plotter.ReplayLength, isPartial); return (list, data, plotter.ReplayLength, isPartial);
}); });
@ -203,7 +203,7 @@ namespace AnotherReplayReader
private int NormalizeResolutionInput(string text) private int NormalizeResolutionInput(string text)
{ {
if(!int.TryParse(text, out var value)) if (!int.TryParse(text, out var value))
{ {
value = (int)PlotResolution.TotalSeconds; value = (int)PlotResolution.TotalSeconds;
} }

View File

@ -1,5 +1,4 @@
using System; using System;
using System.Collections.Generic;
using System.IO; using System.IO;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
@ -62,18 +61,21 @@ namespace AnotherReplayReader.ReplayFile
_data = new byte[] { 0x02, 0x1A, 0x00, 0x00, 0x00 }; _data = new byte[] { 0x02, 0x1A, 0x00, 0x00, 0x00 };
} }
List<float>? TryGetKillDeathRatio() public float[]? TryGetKillDeathRatios()
{ {
if (_data.Length < 24) if (_data.Length < 24)
{ {
return null; return null;
} }
var ratios = new List<float>(); var ratios = new float[6];
using var stream = new MemoryStream(_data, _data.Length - 24, 24); using var stream = new MemoryStream(_data, _data.Length - 24, 24);
using var reader = new BinaryReader(stream); using var reader = new BinaryReader(stream);
ratios.Add(reader.ReadSingle()); for (var i = 0; i < ratios.Length; ++i)
throw new NotImplementedException(); {
ratios[i] = reader.ReadSingle();
}
return ratios;
} }
public void WriteTo(BinaryWriter writer) public void WriteTo(BinaryWriter writer)