2021-09-21 00:16:38 +02:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.IO;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
using System.Windows.Forms;
|
2023-02-16 19:01:06 +01:00
|
|
|
|
using Newtonsoft.Json;
|
2023-02-16 18:59:12 +01:00
|
|
|
|
|
2021-09-21 00:16:38 +02:00
|
|
|
|
namespace TJAPlayer3
|
|
|
|
|
{
|
|
|
|
|
class NamePlateConfig
|
|
|
|
|
{
|
|
|
|
|
public void tNamePlateConfig()
|
|
|
|
|
{
|
2023-02-16 18:59:12 +01:00
|
|
|
|
// Deprecated, only converts to new format
|
|
|
|
|
/*
|
2021-09-21 00:16:38 +02:00
|
|
|
|
if (!File.Exists("NamePlate.json"))
|
2021-11-06 19:21:22 +01:00
|
|
|
|
tSaveFile();
|
2023-02-16 18:59:12 +01:00
|
|
|
|
*/
|
2021-09-21 00:16:38 +02:00
|
|
|
|
|
2021-11-06 19:21:22 +01:00
|
|
|
|
tLoadFile();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#region [Medals]
|
|
|
|
|
|
|
|
|
|
public void tEarnCoins(int[] amounts)
|
|
|
|
|
{
|
|
|
|
|
if (amounts.Length < 2)
|
|
|
|
|
return;
|
|
|
|
|
|
2023-02-15 01:27:05 +01:00
|
|
|
|
for (int i = 0; i < 5; i++)
|
2021-12-10 02:08:35 +01:00
|
|
|
|
{
|
|
|
|
|
int p = TJAPlayer3.GetActualPlayer(i);
|
2021-11-06 19:21:22 +01:00
|
|
|
|
|
2021-12-10 02:08:35 +01:00
|
|
|
|
data.Medals[p] += amounts[i];
|
|
|
|
|
}
|
2021-11-06 19:21:22 +01:00
|
|
|
|
tSaveFile();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Return false if the current amount of coins is to low
|
|
|
|
|
public bool tSpendCoins(int amount, int player)
|
|
|
|
|
{
|
|
|
|
|
if (player > 1 || player < 0)
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
if (data.Medals[player] < amount)
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
data.Medals[player] -= amount;
|
|
|
|
|
|
|
|
|
|
tSaveFile();
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
2021-11-09 16:33:47 +01:00
|
|
|
|
#region [Dan titles]
|
|
|
|
|
|
2022-01-06 12:37:45 +01:00
|
|
|
|
public bool tUpdateDanTitle(string title, bool isGold, int clearStatus, int player)
|
2021-11-09 16:33:47 +01:00
|
|
|
|
{
|
2022-01-06 12:37:45 +01:00
|
|
|
|
bool changed = false;
|
|
|
|
|
|
2021-11-09 16:33:47 +01:00
|
|
|
|
bool iG = isGold;
|
|
|
|
|
int cs = clearStatus;
|
|
|
|
|
|
|
|
|
|
if (TJAPlayer3.NamePlateConfig.data.DanTitles[player] == null)
|
2023-02-16 18:59:12 +01:00
|
|
|
|
TJAPlayer3.NamePlateConfig.data.DanTitles[player] = new Dictionary<string, SaveFile.CDanTitle>();
|
2021-11-09 16:33:47 +01:00
|
|
|
|
|
|
|
|
|
if (TJAPlayer3.NamePlateConfig.data.DanTitles[player].ContainsKey(title))
|
|
|
|
|
{
|
|
|
|
|
if (TJAPlayer3.NamePlateConfig.data.DanTitles[player][title].clearStatus > cs)
|
|
|
|
|
cs = TJAPlayer3.NamePlateConfig.data.DanTitles[player][title].clearStatus;
|
|
|
|
|
if (TJAPlayer3.NamePlateConfig.data.DanTitles[player][title].isGold)
|
|
|
|
|
iG = true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Automatically set the dan to nameplate if new
|
|
|
|
|
// Add a function within the NamePlate.cs file to update the title texture
|
2022-01-06 12:37:45 +01:00
|
|
|
|
|
2021-11-09 16:33:47 +01:00
|
|
|
|
if (!TJAPlayer3.NamePlateConfig.data.DanTitles[player].ContainsKey(title) || cs != clearStatus || iG != isGold)
|
|
|
|
|
{
|
2022-01-06 12:37:45 +01:00
|
|
|
|
changed = true;
|
|
|
|
|
/*
|
2021-11-09 16:33:47 +01:00
|
|
|
|
TJAPlayer3.NamePlateConfig.data.Dan[player] = title;
|
|
|
|
|
TJAPlayer3.NamePlateConfig.data.DanGold[player] = iG;
|
|
|
|
|
TJAPlayer3.NamePlateConfig.data.DanType[player] = cs;
|
2022-01-06 12:37:45 +01:00
|
|
|
|
*/
|
2021-11-09 16:33:47 +01:00
|
|
|
|
}
|
2022-01-06 12:37:45 +01:00
|
|
|
|
|
2021-11-09 16:33:47 +01:00
|
|
|
|
|
2023-02-16 18:59:12 +01:00
|
|
|
|
SaveFile.CDanTitle danTitle = new SaveFile.CDanTitle(iG, cs);
|
2021-11-09 16:33:47 +01:00
|
|
|
|
|
|
|
|
|
TJAPlayer3.NamePlateConfig.data.DanTitles[player][title] = danTitle;
|
|
|
|
|
|
|
|
|
|
tSaveFile();
|
2022-01-06 12:37:45 +01:00
|
|
|
|
|
|
|
|
|
return changed;
|
2021-11-09 16:33:47 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region [Auxilliary classes]
|
|
|
|
|
|
|
|
|
|
public class CDanTitle
|
|
|
|
|
{
|
|
|
|
|
public CDanTitle(bool iG, int cs)
|
|
|
|
|
{
|
|
|
|
|
isGold = iG;
|
|
|
|
|
clearStatus = cs;
|
|
|
|
|
}
|
|
|
|
|
|
2022-02-05 16:25:58 +01:00
|
|
|
|
[JsonProperty("isGold")]
|
2021-11-09 16:33:47 +01:00
|
|
|
|
public bool isGold;
|
2022-02-05 16:25:58 +01:00
|
|
|
|
|
|
|
|
|
[JsonProperty("clearStatus")]
|
2021-11-09 16:33:47 +01:00
|
|
|
|
public int clearStatus;
|
|
|
|
|
}
|
|
|
|
|
|
2021-11-16 15:00:09 +01:00
|
|
|
|
public class CNamePlateTitle
|
|
|
|
|
{
|
|
|
|
|
public CNamePlateTitle(int type)
|
|
|
|
|
{
|
|
|
|
|
iType = type;
|
|
|
|
|
}
|
|
|
|
|
|
2022-02-05 16:25:58 +01:00
|
|
|
|
[JsonProperty("iType")]
|
2021-11-16 15:00:09 +01:00
|
|
|
|
public int iType;
|
|
|
|
|
}
|
|
|
|
|
|
2021-11-09 16:33:47 +01:00
|
|
|
|
#endregion
|
|
|
|
|
|
2021-11-13 16:39:23 +01:00
|
|
|
|
#region [Heya]
|
2021-11-09 16:33:47 +01:00
|
|
|
|
|
2022-06-10 19:51:18 +02:00
|
|
|
|
public void tReindexCharacter(int p, string[] characterNamesList)
|
|
|
|
|
{
|
|
|
|
|
string character = this.data.CharacterName[p];
|
|
|
|
|
|
|
|
|
|
if (characterNamesList.Contains(character))
|
|
|
|
|
this.data.Character[p] = characterNamesList.ToList().IndexOf(character);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void tUpdateCharacterName(int p, string newChara)
|
|
|
|
|
{
|
|
|
|
|
this.data.CharacterName[p] = newChara;
|
|
|
|
|
}
|
|
|
|
|
|
2021-11-13 16:39:23 +01:00
|
|
|
|
public void tApplyHeyaChanges()
|
|
|
|
|
{
|
|
|
|
|
this.tSaveFile();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion
|
2021-11-09 16:33:47 +01:00
|
|
|
|
|
2021-09-21 00:16:38 +02:00
|
|
|
|
public class Data
|
|
|
|
|
{
|
2022-02-05 16:25:58 +01:00
|
|
|
|
[JsonProperty("name")]
|
2023-02-15 01:27:05 +01:00
|
|
|
|
public string[] Name = { "プレイヤー1", "プレイヤー2", "プレイヤー3", "プレイヤー4", "プレイヤー5" };
|
2022-02-05 16:25:58 +01:00
|
|
|
|
|
|
|
|
|
[JsonProperty("title")]
|
2023-02-15 01:27:05 +01:00
|
|
|
|
public string[] Title = { "初心者", "初心者", "初心者", "初心者", "初心者" };
|
2022-02-05 16:25:58 +01:00
|
|
|
|
|
|
|
|
|
[JsonProperty("dan")]
|
2023-02-15 01:27:05 +01:00
|
|
|
|
public string[] Dan = { "新人", "新人", "新人", "新人", "新人" };
|
2021-09-21 00:16:38 +02:00
|
|
|
|
|
2022-02-05 16:25:58 +01:00
|
|
|
|
[JsonProperty("danGold")]
|
2023-02-15 01:27:05 +01:00
|
|
|
|
public bool[] DanGold = { false, false, false, false, false };
|
2021-09-21 00:16:38 +02:00
|
|
|
|
|
2022-02-05 16:25:58 +01:00
|
|
|
|
[JsonProperty("danType")]
|
2023-02-15 01:27:05 +01:00
|
|
|
|
public int[] DanType = { 0, 0, 0, 0, 0 };
|
2022-02-05 16:25:58 +01:00
|
|
|
|
|
|
|
|
|
[JsonProperty("titleType")]
|
2023-02-15 01:27:05 +01:00
|
|
|
|
public int[] TitleType = { 0, 0, 0, 0, 0 };
|
2021-10-02 17:20:28 +02:00
|
|
|
|
|
2022-02-05 16:25:58 +01:00
|
|
|
|
[JsonProperty("puchiChara")]
|
2023-02-15 01:27:05 +01:00
|
|
|
|
public string[] PuchiChara = { "0", "0", "0", "0", "0" };
|
2021-11-06 19:21:22 +01:00
|
|
|
|
|
2022-02-05 16:25:58 +01:00
|
|
|
|
[JsonProperty("medals")]
|
2023-02-15 01:27:05 +01:00
|
|
|
|
public int[] Medals = { 0, 0, 0, 0, 0 };
|
2021-11-07 09:43:42 +01:00
|
|
|
|
|
2022-02-05 16:25:58 +01:00
|
|
|
|
[JsonProperty("character")]
|
2023-02-15 01:27:05 +01:00
|
|
|
|
public int[] Character = { 0, 0, 0, 0, 0 };
|
2021-11-09 16:33:47 +01:00
|
|
|
|
|
2022-06-10 19:51:18 +02:00
|
|
|
|
[JsonProperty("characterName")]
|
2023-02-15 01:27:05 +01:00
|
|
|
|
public string[] CharacterName = { "0", "0", "0", "0", "0" };
|
2022-06-10 19:51:18 +02:00
|
|
|
|
|
2022-02-05 16:25:58 +01:00
|
|
|
|
[JsonProperty("danTitles")]
|
2023-02-16 18:59:12 +01:00
|
|
|
|
public Dictionary<string, SaveFile.CDanTitle>[] DanTitles = new Dictionary<string, SaveFile.CDanTitle>[5];
|
2021-11-16 15:00:09 +01:00
|
|
|
|
|
2022-02-05 16:25:58 +01:00
|
|
|
|
[JsonProperty("namePlateTitles")]
|
2023-02-16 18:59:12 +01:00
|
|
|
|
public Dictionary<string, SaveFile.CNamePlateTitle>[] NamePlateTitles = new Dictionary<string, SaveFile.CNamePlateTitle>[5];
|
2022-02-06 13:59:32 +01:00
|
|
|
|
|
|
|
|
|
[JsonProperty("unlockedPuchicharas")]
|
2023-02-15 01:27:05 +01:00
|
|
|
|
public List<string>[] UnlockedPuchicharas = new List<string>[5]
|
2022-02-06 13:59:32 +01:00
|
|
|
|
{
|
2023-02-15 01:27:05 +01:00
|
|
|
|
new List<string>(),
|
|
|
|
|
new List<string>(),
|
|
|
|
|
new List<string>(),
|
2022-06-04 19:52:08 +02:00
|
|
|
|
new List<string>(),
|
|
|
|
|
new List<string>()
|
2022-02-06 13:59:32 +01:00
|
|
|
|
};
|
|
|
|
|
|
2021-09-21 00:16:38 +02:00
|
|
|
|
}
|
|
|
|
|
|
2021-11-06 19:21:22 +01:00
|
|
|
|
public Data data = new Data();
|
|
|
|
|
|
|
|
|
|
#region [private]
|
|
|
|
|
|
|
|
|
|
private void tSaveFile()
|
|
|
|
|
{
|
|
|
|
|
ConfigManager.SaveConfig(data, "NamePlate.json");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void tLoadFile()
|
|
|
|
|
{
|
2023-02-16 18:59:12 +01:00
|
|
|
|
//data = ConfigManager.GetConfig<Data>(@"NamePlate.json");
|
|
|
|
|
|
|
|
|
|
if (!File.Exists("NamePlate.json"))
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
var _data = ConfigManager.GetConfig<Data>(@"NamePlate.json");
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < _data.Name.Length; i++)
|
|
|
|
|
{
|
|
|
|
|
var _sf = new SaveFile();
|
|
|
|
|
_sf.tSaveFile((i + 1) + "P");
|
|
|
|
|
_sf.data.Name = _data.Name[i];
|
|
|
|
|
_sf.data.Title = _data.Title[i];
|
|
|
|
|
_sf.data.Dan = _data.Dan[i];
|
|
|
|
|
_sf.data.DanGold = _data.DanGold[i];
|
|
|
|
|
_sf.data.DanType = _data.DanType[i];
|
|
|
|
|
_sf.data.TitleType = _data.TitleType[i];
|
|
|
|
|
_sf.data.PuchiChara = _data.PuchiChara[i];
|
|
|
|
|
_sf.data.Medals = _data.Medals[i];
|
|
|
|
|
_sf.data.Character = _data.Character[i];
|
|
|
|
|
_sf.data.CharacterName = _data.CharacterName[i];
|
|
|
|
|
_sf.data.DanTitles = _data.DanTitles[i];
|
|
|
|
|
_sf.data.NamePlateTitles = _data.NamePlateTitles[i];
|
|
|
|
|
_sf.data.UnlockedPuchicharas = _data.UnlockedPuchicharas[i];
|
|
|
|
|
_sf.tApplyHeyaChanges();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
System.IO.File.Move(@"NamePlate.json", @"NamePlate_old.json");
|
2021-11-06 19:21:22 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion
|
2021-09-21 00:16:38 +02:00
|
|
|
|
}
|
|
|
|
|
}
|