Skip to content

Commit

Permalink
Merge branch 'pr/10' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
myangelkamikaze committed Sep 30, 2019
2 parents fcac5b7 + f044108 commit e717f92
Show file tree
Hide file tree
Showing 23 changed files with 4,140 additions and 3,150 deletions.
Binary file modified ElectronicObserver/Assets.zip
Binary file not shown.
340 changes: 326 additions & 14 deletions ElectronicObserver/Assets/Record/EnemyFleetRecord.csv

Large diffs are not rendered by default.

1,629 changes: 1,047 additions & 582 deletions ElectronicObserver/Assets/Record/ShipParameterRecord.csv

Large diffs are not rendered by default.

50 changes: 25 additions & 25 deletions ElectronicObserver/Data/Constants.cs
Original file line number Diff line number Diff line change
Expand Up @@ -89,33 +89,33 @@ public static string GetShipRarity(int value)
}
}

/// <summary>
/// 装備のレアリティを表す文字列を取得します。
/// </summary>
public static string GetEquipmentRarity(int value)
{
switch (value)
{
case 0:
return ConstantsRes.Common;
case 1:
return ConstantsRes.Rare;
case 2:
return ConstantsRes.Holo;
case 3:
return ConstantsRes.SHolo;
case 4:
return ConstantsRes.SSHolo;
case 5:
return ConstantsRes.EXHolo;
case 6:
return ConstantsRes.SSHoloPlus;
/// <summary>
/// 装備のレアリティを表す文字列を取得します。
/// </summary>
public static string GetEquipmentRarity(int value)
{
switch (value)
{
case 0:
return "コモン";
case 1:
return "レア";
case 2:
return "ホロ";
case 3:
return "Sホロ";
case 4:
return "SSホロ";
case 5:
return "SSホロ'";
case 6:
return "SSホロ+";
case 7:
return "SS++";
default:
return ConstantsRes.Unknown;
}
}
default:
return "不明";
}
}

/// <summary>
/// 装備のレアリティの画像インデックスを取得します。
Expand Down
136 changes: 136 additions & 0 deletions ElectronicObserver/Data/DevelopmentData.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,136 @@
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ElectronicObserver.Data
{
public class DevelopmentData : APIWrapper
{
// request

/// <summary> 投入燃料(1回分) </summary>
public int Fuel { get; private set; }

/// <summary> 投入弾薬(1回分) </summary>
public int Ammo { get; private set; }

/// <summary> 投入鋼材(1回分) </summary>
public int Steel { get; private set; }

/// <summary> 投入ボーキサイト(1回分) </summary>
public int Bauxite { get; private set; }

/// <summary> 開発の試行回数 </summary>
public int DevelopmentTrials { get; private set; }


// response

/// <summary> 開発に成功したか </summary>
public bool IsSucceeded { get; private set; }

/// <summary> 開発後の各種保有資源 </summary>
public ReadOnlyCollection<int> Materials { get; private set; }


public class DevelopmentResult
{
public readonly int MasterID;
public readonly int EquipmentID;

public bool IsSucceeded => MasterID != -1;
public EquipmentData Equipment => KCDatabase.Instance.Equipments[MasterID];
public EquipmentDataMaster MasterEquipment => Equipment?.MasterEquipment;

public DevelopmentResult() : this(null) { }
public DevelopmentResult(dynamic data)
{
MasterID = (int?)data?.api_id ?? -1;
EquipmentID = (int?)data?.api_slotitem_id ?? -1;
}

public override string ToString()
{
return IsSucceeded ? $"{MasterEquipment.CategoryTypeInstance.Name}{MasterEquipment.Name}」" : "失敗";
}
}
/// <summary> 開発結果 </summary>
public ReadOnlyCollection<DevelopmentResult> Results { get; private set; }


public override void LoadFromRequest(string apiname, Dictionary<string, string> data)
{
base.LoadFromRequest(apiname, data);

Fuel = int.Parse(data["api_item1"]);
Ammo = int.Parse(data["api_item2"]);
Steel = int.Parse(data["api_item3"]);
Bauxite = int.Parse(data["api_item4"]);

if (data.ContainsKey("api_multiple_flag"))
DevelopmentTrials = int.Parse(data["api_multiple_flag"]) != 0 ? 3 : 1;
else
DevelopmentTrials = 1;


IsSucceeded = false;
Materials = null;
Results = null;
}

public override void LoadFromResponse(string apiname, dynamic data)
{
base.LoadFromResponse(apiname, (object)data);

IsSucceeded = (int)data.api_create_flag != 0;
Materials = Array.AsReadOnly((int[])data.api_material);


void AddToDatabase(dynamic equipmentData)
{
var eq = new EquipmentData();
eq.LoadFromResponse(apiname, Codeplex.Data.DynamicJson.Parse(equipmentData.ToString()));
KCDatabase.Instance.Equipments.Add(eq);
}


bool isOldAPI = data.api_shizai_flag();

if (isOldAPI)
{
// 旧 API フォーマット (-2019/09/30 12:00)
Results = Array.AsReadOnly(new[] {
IsSucceeded ?
new DevelopmentResult(data.api_slot_item) :
new DevelopmentResult()
});

if (IsSucceeded)
AddToDatabase(data.api_slot_item);
}
else
{
// 新 API フォーマット (2019/09/30 21:00-)
dynamic[] elems = data.api_get_items;
var results = new DevelopmentResult[elems.Length];

for (int i = 0; i < elems.Length; i++)
{
results[i] = new DevelopmentResult(elems[i]);

if (results[i].IsSucceeded)
AddToDatabase(elems[i]);
}

Results = Array.AsReadOnly(results);
}

KCDatabase.Instance.Material.LoadFromResponse(apiname, data.api_material);

}

}
}
6 changes: 6 additions & 0 deletions ElectronicObserver/Data/KCDatabase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,11 @@ public sealed class KCDatabase
/// </summary>
public IDDictionary<DockData> Docks { get; private set; }

/// <summary>
/// 開発データ
/// </summary>
public DevelopmentData Development { get; private set; }


/// <summary>
/// 艦隊データ
Expand Down Expand Up @@ -175,6 +180,7 @@ private KCDatabase()
UseItems = new IDDictionary<UseItem>();
Arsenals = new IDDictionary<ArsenalData>();
Docks = new IDDictionary<DockData>();
Development = new DevelopmentData();
Fleet = new FleetManager();
Material = new MaterialData();
Quest = new QuestManager();
Expand Down
Loading

0 comments on commit e717f92

Please sign in to comment.