Skip to content

Commit

Permalink
Version 4.7.1
Browse files Browse the repository at this point in the history
* 戦闘:連合vs連合でエラーが発生するのを修正 (#294)
  • Loading branch information
andanteyk committed Nov 23, 2021
1 parent 60876d2 commit 469015b
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 15 deletions.
35 changes: 23 additions & 12 deletions ElectronicObserver/Data/Battle/Phase/PhaseTorpedo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -111,27 +111,38 @@ public override void EmulateBattle(int[] hps, int[] damages)



private T[] GetConcatArray<T>(string friendName, string enemyName, T defaultValue)
private T[] GetConcatArray<T>(string friendName, string enemyName, T defaultValue) where T : struct
{
var friend = (T[])TorpedoData[friendName];
var enemy = (T[])TorpedoData[enemyName];
var friend = ConvertToArray<T>(TorpedoData[friendName], 12, defaultValue);
var enemy = ConvertToArray<T>(TorpedoData[enemyName], 12, defaultValue);

var ret = new T[24];

for (int i = 0; i < 12; i++)
{
if (i < friend.Length)
ret[i] = friend[i];
else
ret[i] = defaultValue;

if (i < enemy.Length)
ret[i + 12] = enemy[i];
else
ret[i + 12] = defaultValue;
ret[i] = friend[i];
ret[i + 12] = enemy[i];
}

return ret;
}

/// <summary>
/// 基本的には `(T[])json` と等価ですが、特定の状況下におけるデータエラーを回避するための実装が含まれています
/// https://github.com/andanteyk/ElectronicObserver/issues/294
/// </summary>
private static T[] ConvertToArray<T>(dynamic json, int maxLength, T defaultValue) where T : struct
{
var ret = Enumerable.Repeat(defaultValue, maxLength).ToArray();
int i = 0;
foreach (var member in json)
{
ret[i++ % maxLength] =
member is KeyValuePair<string, dynamic> pair ? (T)pair.Value :
member != null ? (T)member :
default(T);
}
return ret;
}
}
}
6 changes: 3 additions & 3 deletions ElectronicObserver/Utility/SoftwareInformation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,20 +29,20 @@ public static class SoftwareInformation
/// <summary>
/// バージョン(日本語, ソフトウェア名を含みます)
/// </summary>
public static string VersionJapanese => SoftwareNameJapanese + "四七型";
public static string VersionJapanese => SoftwareNameJapanese + "四七型改";


/// <summary>
/// バージョン(英語)
/// </summary>
public static string VersionEnglish => "4.7.0";
public static string VersionEnglish => "4.7.1";



/// <summary>
/// 更新日時
/// </summary>
public static DateTime UpdateTime => DateTimeHelper.CSVStringToTime("2021/09/19 18:30:00");
public static DateTime UpdateTime => DateTimeHelper.CSVStringToTime("2021/11/23 18:30:00");



Expand Down

0 comments on commit 469015b

Please sign in to comment.