1
0
mirror of synced 2024-11-12 01:50:47 +01:00

Change the nameplate unlockables format from json to sqlite

This commit is contained in:
0auBSQ 2024-06-07 06:13:46 +09:00
parent 8adc819fa9
commit e988b5415a
9 changed files with 99 additions and 835 deletions

1
.gitignore vendored
View File

@ -39,4 +39,5 @@
/OpenTaiko/Global/Characters/Kohaku
*.score.ini
/OpenTaiko Launcher
/OpenTaiko Launcher/node_modules

Binary file not shown.

View File

@ -1,833 +0,0 @@
{
"First Steps": {
"NameplateInfo": {
"iType": 0,
"Localization": {
"strings": {
"default": "First Steps",
"fr": "Premiers Pas",
"ja": "第一歩",
"zh": "初来乍到"
}
}
},
"Rarity": "Common",
"UnlockCondition": {
"condition": "dp",
"type": "me",
"values": [
0,
0,
1
]
}
},
"A Normal Player": {
"NameplateInfo": {
"iType": 0,
"Localization": {
"strings": {
"default": "A Normal Player",
"fr": "Un joueur Normal",
"ja": "ふつうなプレイヤー",
"zh": "平凡无奇"
}
}
},
"Rarity": "Common",
"UnlockCondition": {
"condition": "dp",
"type": "me",
"values": [
1,
0,
1
]
}
},
"A very Normal Player": {
"NameplateInfo": {
"iType": 0,
"Localization": {
"strings": {
"default": "A very Normal Player",
"fr": "Un joueur très Normal",
"ja": "とてもふつうなプレイヤー",
"zh": "非常普通"
}
}
},
"Rarity": "Common",
"UnlockCondition": {
"condition": "dp",
"type": "me",
"values": [
1,
0,
10
]
}
},
"An extremely Normal player": {
"NameplateInfo": {
"iType": 1,
"Localization": {
"strings": {
"default": "An extremely Normal player",
"fr": "Un joueur extrèmement Normal",
"ja": "ずいぶんふつうなプレイヤー",
"zh": "极其普通"
}
}
},
"Rarity": "Common",
"UnlockCondition": {
"condition": "dp",
"type": "me",
"values": [
1,
0,
100
]
}
},
"Hard-boiled": {
"NameplateInfo": {
"iType": 0,
"Localization": {
"strings": {
"default": "Hard-boiled",
"fr": "Dur à cuire",
"ja": "ハードボイルド",
"zh": "玉琢成器"
}
}
},
"Rarity": "Common",
"UnlockCondition": {
"condition": "dp",
"type": "me",
"values": [
2,
0,
1
]
}
},
"Hard as rock": {
"NameplateInfo": {
"iType": 1,
"Localization": {
"strings": {
"default": "Hard as rock",
"fr": "Dur comme la pierre",
"ja": "ロックハード",
"zh": "坚如磐石"
}
}
},
"Rarity": "Common",
"UnlockCondition": {
"condition": "dp",
"type": "me",
"values": [
2,
0,
10
]
}
},
"Hard as diamonds": {
"NameplateInfo": {
"iType": 2,
"Localization": {
"strings": {
"default": "Hard as diamonds",
"fr": "Dur comme du diamant",
"ja": "ダイヤモンドハード",
"zh": "金刚钻"
}
}
},
"Rarity": "Uncommon",
"UnlockCondition": {
"condition": "dp",
"type": "me",
"values": [
2,
0,
100
]
}
},
"My first Extreme": {
"NameplateInfo": {
"iType": 1,
"Localization": {
"strings": {
"default": "My first Extreme",
"fr": "Mon premier Extrème",
"ja": "初めてのおに",
"zh": "首战魔王"
}
}
},
"Rarity": "Common",
"UnlockCondition": {
"condition": "dp",
"type": "me",
"values": [
3,
0,
1
]
}
},
"An Extreme player": {
"NameplateInfo": {
"iType": 2,
"Localization": {
"strings": {
"default": "An Extreme player",
"fr": "Un joueur Extrème",
"ja": "おにのプレイヤー",
"zh": "魔王斗士"
}
}
},
"Rarity": "Uncommon",
"UnlockCondition": {
"condition": "dp",
"type": "me",
"values": [
3,
0,
10
]
}
},
"A very Extreme player": {
"NameplateInfo": {
"iType": 2,
"Localization": {
"strings": {
"default": "A very Extreme player",
"fr": "Un joueur très Extrème",
"ja": "とてもおにのプレイヤー",
"zh": "身经百战"
}
}
},
"Rarity": "Uncommon",
"UnlockCondition": {
"condition": "dp",
"type": "me",
"values": [
3,
0,
100
]
}
},
"An extremely Extreme player": {
"NameplateInfo": {
"iType": 4,
"Localization": {
"strings": {
"default": "An extremely Extreme player",
"fr": "Un joueur extrèmement Extrème",
"ja": "ずいぶんおにのプレイヤー",
"zh": "横扫千军"
}
}
},
"Rarity": "Rare",
"UnlockCondition": {
"condition": "dp",
"type": "me",
"values": [
3,
0,
1000
]
}
},
"Free from errors": {
"NameplateInfo": {
"iType": 2,
"Localization": {
"strings": {
"default": "Free from errors",
"fr": "Exempt d'erreurs",
"ja": "エラーに当たらない",
"zh": "不容差错"
}
}
},
"Rarity": "Uncommon",
"UnlockCondition": {
"condition": "dp",
"type": "me",
"values": [
3,
1,
1
]
}
},
"Unbreakable combo": {
"NameplateInfo": {
"iType": 2,
"Localization": {
"strings": {
"default": "Unbreakable combo",
"fr": "Combo indestructible",
"ja": "アンブレイカブルコンボ",
"zh": "连不可破"
}
}
},
"Rarity": "Uncommon",
"UnlockCondition": {
"condition": "dp",
"type": "me",
"values": [
3,
1,
10
]
}
},
"Everlasting combo": {
"NameplateInfo": {
"iType": 4,
"Localization": {
"strings": {
"default": "Everlasting combo",
"fr": "Combo éternel",
"ja": "永遠のコンボ",
"zh": "连击永恒"
}
}
},
"Rarity": "Rare",
"UnlockCondition": {
"condition": "dp",
"type": "me",
"values": [
3,
1,
100
]
}
},
"100%": {
"NameplateInfo": {
"iType": 3,
"Localization": {
"strings": {
"default": "100%",
"fr": "100%",
"ja": "100点",
"zh": "百发百中"
}
}
},
"Rarity": "Rare",
"UnlockCondition": {
"condition": "dp",
"type": "me",
"values": [
3,
2,
1
]
}
},
"Aims for perfection": {
"NameplateInfo": {
"iType": 3,
"Localization": {
"strings": {
"default": "Aims for perfection",
"fr": "Vise la perfection",
"ja": "完璧主義",
"zh": "完美主义"
}
}
},
"Rarity": "Rare",
"UnlockCondition": {
"condition": "dp",
"type": "me",
"values": [
3,
2,
10
]
}
},
"Flawless": {
"NameplateInfo": {
"iType": 7,
"Localization": {
"strings": {
"default": "Flawless",
"fr": "Sans défaut",
"ja": "寸分の狂いもない",
"zh": "完美无瑕"
}
}
},
"Rarity": "Epic",
"UnlockCondition": {
"condition": "dp",
"type": "me",
"values": [
3,
2,
100
]
}
},
"Eight stars": {
"NameplateInfo": {
"iType": 1,
"Localization": {
"strings": {
"default": "Eight stars",
"fr": "Huit étoiles",
"ja": "八つ星",
"zh": "八颗星"
}
}
},
"Rarity": "Common",
"UnlockCondition": {
"condition": "lp",
"type": "me",
"values": [
8,
0,
1
]
}
},
"Nine stars": {
"NameplateInfo": {
"iType": 1,
"Localization": {
"strings": {
"default": "Nine stars",
"fr": "Neuf étoiles",
"ja": "九つ星",
"zh": "九颗星"
}
}
},
"Rarity": "Common",
"UnlockCondition": {
"condition": "lp",
"type": "me",
"values": [
9,
0,
1
]
}
},
"Challenger": {
"NameplateInfo": {
"iType": 2,
"Localization": {
"strings": {
"default": "Challenger",
"fr": "Challenger",
"ja": "チャレンジャー",
"zh": "挑战者"
}
}
},
"Rarity": "Uncommon",
"UnlockCondition": {
"condition": "lp",
"type": "me",
"values": [
10,
0,
1
]
}
},
"Sweaty challenger": {
"NameplateInfo": {
"iType": 6,
"Localization": {
"strings": {
"default": "Sweaty challenger",
"fr": "Challenger en sueur",
"ja": "汗だくのチャレンジャー",
"zh": "汗流浃背"
}
}
},
"Rarity": "Rare",
"UnlockCondition": {
"condition": "lp",
"type": "me",
"values": [
11,
0,
1
]
}
},
"Challenger from another world": {
"NameplateInfo": {
"iType": 11,
"Localization": {
"strings": {
"default": "Challenger from another world",
"fr": "Challenger d'un autre monde",
"ja": "異世界から来たチャレンジャー",
"zh": "来自异世界的挑战者"
}
}
},
"Rarity": "Rare",
"UnlockCondition": {
"condition": "lp",
"type": "me",
"values": [
12,
0,
1
]
}
},
"Unbeatable warrior": {
"NameplateInfo": {
"iType": 13,
"Localization": {
"strings": {
"default": "Unbeatable warrior",
"fr": "Guerrier imbattable",
"ja": "無敵の勇者",
"zh": "所向披靡"
}
}
},
"Rarity": "Epic",
"UnlockCondition": {
"condition": "lp",
"type": "me",
"values": [
13,
0,
1
]
}
},
"Eight shining stars": {
"NameplateInfo": {
"iType": 2,
"Localization": {
"strings": {
"default": "Eight shining stars",
"fr": "Huit étoiles brillantes",
"ja": "光る八つ星",
"zh": "闪亮八星"
}
}
},
"Rarity": "Uncommon",
"UnlockCondition": {
"condition": "lp",
"type": "me",
"values": [
8,
1,
1
]
}
},
"Nine shining stars": {
"NameplateInfo": {
"iType": 2,
"Localization": {
"strings": {
"default": "Nine shining stars",
"fr": "Neuf étoiles brillantes",
"ja": "光る九つ星",
"zh": "闪亮九星"
}
}
},
"Rarity": "Uncommon",
"UnlockCondition": {
"condition": "lp",
"type": "me",
"values": [
9,
1,
1
]
}
},
"Talented drummer": {
"NameplateInfo": {
"iType": 12,
"Localization": {
"strings": {
"default": "Talented drummer",
"fr": "Batteur talentueux",
"ja": "有能なドラマー",
"zh": "实力鼓手"
}
}
},
"Rarity": "Rare",
"UnlockCondition": {
"condition": "lp",
"type": "me",
"values": [
10,
1,
1
]
}
},
"Tenacious warrior": {
"NameplateInfo": {
"iType": 7,
"Localization": {
"strings": {
"default": "Tenacious warrior",
"fr": "Guerrier tenace",
"ja": "粘り強い勇者",
"zh": "坚韧不拔"
}
}
},
"Rarity": "Epic",
"UnlockCondition": {
"condition": "lp",
"type": "me",
"values": [
11,
1,
1
]
}
},
"Drummer from another world": {
"NameplateInfo": {
"iType": 8,
"Localization": {
"strings": {
"default": "Drummer from another world",
"fr": "Batteur d'un autre monde",
"ja": "異世界から来たドラマー",
"zh": "来自异世界的鼓手"
}
}
},
"Rarity": "Legendary",
"UnlockCondition": {
"condition": "lp",
"type": "me",
"values": [
12,
1,
1
]
}
},
"Celestial divinity": {
"NameplateInfo": {
"iType": 9,
"Localization": {
"strings": {
"default": "Celestial divinity",
"fr": "Divinité celeste",
"ja": "天の神性",
"zh": "天禀神赋"
}
}
},
"Rarity": "Legendary",
"UnlockCondition": {
"condition": "lp",
"type": "me",
"values": [
13,
1,
1
]
}
},
"Eight sparkling stars": {
"NameplateInfo": {
"iType": 3,
"Localization": {
"strings": {
"default": "Eight sparkling stars",
"fr": "Huit étoiles étincelantes",
"ja": "輝く八つ星",
"zh": "闪耀八星"
}
}
},
"Rarity": "Rare",
"UnlockCondition": {
"condition": "lp",
"type": "me",
"values": [
8,
2,
1
]
}
},
"Nine sparkling stars": {
"NameplateInfo": {
"iType": 7,
"Localization": {
"strings": {
"default": "Nine sparkling stars",
"fr": "Neuf étoiles étincelantes",
"ja": "輝く九つ星",
"zh": "闪耀九星"
}
}
},
"Rarity": "Epic",
"UnlockCondition": {
"condition": "lp",
"type": "me",
"values": [
9,
2,
1
]
}
},
"Outstanding drummer": {
"NameplateInfo": {
"iType": 7,
"Localization": {
"strings": {
"default": "Outstanding drummer",
"fr": "Batteur d'exception",
"ja": "優秀なドラマー",
"zh": "杰出鼓手"
}
}
},
"Rarity": "Epic",
"UnlockCondition": {
"condition": "lp",
"type": "me",
"values": [
10,
2,
1
]
}
},
"Eternal legend": {
"NameplateInfo": {
"iType": 8,
"Localization": {
"strings": {
"default": "Eternal legend",
"fr": "Légende éternelle",
"ja": "永遠の伝説",
"zh": "永恒传说"
}
}
},
"Rarity": "Legendary",
"UnlockCondition": {
"condition": "lp",
"type": "me",
"values": [
11,
2,
1
]
}
},
"Drummer from another dimension": {
"NameplateInfo": {
"iType": 8,
"Localization": {
"strings": {
"default": "Drummer from another dimension",
"fr": "Batteur d'une autre dimention",
"ja": "異次元から来たドラマー",
"zh": "来自异次元的鼓手"
}
}
},
"Rarity": "Legendary",
"UnlockCondition": {
"condition": "lp",
"type": "me",
"values": [
12,
2,
1
]
}
},
"I sold my real life": {
"NameplateInfo": {
"iType": 10,
"Localization": {
"strings": {
"default": "I sold my real life",
"fr": "J'ai vendu ma vie réele",
"ja": "現実に手を離れてしまいました",
"zh": "超越现世"
}
}
},
"Rarity": "Poor",
"UnlockCondition": {
"condition": "lp",
"type": "me",
"values": [
13,
2,
1
]
}
},
"First Secret": {
"NameplateInfo": {
"iType": 15,
"Localization": {
"strings": {
"default": "First Secret",
"fr": "Mon premier secret",
"ja": "初めての秘密",
"zh": "第一份秘密"
}
}
},
"Rarity": "Common",
"UnlockCondition": {
"condition": "sg",
"type": "me",
"values": [
1,
-1,
0
],
"references": [
"Dashy's Secrets"
]
}
}
}

View File

@ -3,6 +3,8 @@
<ProjectReference Include="..\FDK\FDK.csproj" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Data.Sqlite.Core" Version="8.0.6" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="7.0.20" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
<PackageReference Include="SevenZip" Version="19.0.0" />
<PackageReference Include="NLua" Version="1.6.3" />

View File

@ -31,6 +31,11 @@ namespace TJAPlayer3
public void tEarnCoins(int amount)
{
data.Medals += amount;
data.TotalEarnedMedals += amount;
// Small trick here, each actual play (excluding Auto, AI, etc) are worth at least 5 coins for the player, whatever which mode it is (Dan, Tower, Taiko mode, etc)
// Earn Coins is also called once per play, so we just add 1 here to the total playcount
data.TotalPlaycount += 1;
tSaveFile();
}
@ -211,6 +216,12 @@ namespace TJAPlayer3
[JsonProperty("medals")]
public int Medals = 0;
[JsonProperty("totalEarnedMedals")]
public int TotalEarnedMedals = 0;
[JsonProperty("totalPlaycount")]
public int TotalPlaycount = 0;
[JsonProperty("character")]
public int Character = 0;

View File

@ -26,5 +26,10 @@ namespace TJAPlayer3
return Strings["default"];
return defaultsDefault;
}
public void SetString(string langcode, string str)
{
Strings[langcode] = str;
}
}
}

View File

@ -1,5 +1,7 @@
using System.Collections.Generic;
using Microsoft.Data.Sqlite;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using static TJAPlayer3.DBNameplateUnlockables;
namespace TJAPlayer3
@ -8,8 +10,51 @@ namespace TJAPlayer3
{
public DBNameplateUnlockables()
{
_fn = @$"{TJAPlayer3.strEXEのあるフォルダ}Databases{Path.DirectorySeparatorChar}NameplateUnlockables.json";
base.tDBInitSavable();
//_fn = @$"{TJAPlayer3.strEXEのあるフォルダ}Databases{Path.DirectorySeparatorChar}NameplateUnlockables.json";
//base.tDBInitSavable();
_fn = @$"{TJAPlayer3.strEXEのあるフォルダ}Databases{Path.DirectorySeparatorChar}NameplateUnlockables.db3";
using (var connection = new SqliteConnection(@$"Data Source={_fn}"))
{
connection.Open();
// Get existing languages
List<string> _translations = HDatabaseHelpers.GetAvailableLanguage(connection, "translation");
// Get nameplates
var command = connection.CreateCommand();
command.CommandText =
@$"
SELECT np.*, {String.Join(", ", _translations.Select((code, _) => $@"{code}.String AS {code}_String"))}
FROM nameplates np
{String.Join(Environment.NewLine, _translations.Select((code, _) => $@"LEFT JOIN translation_{code} {code} ON np.NameplateId = {code}.NameplateId"))}
";
var reader = command.ExecuteReader();
while (reader.Read())
{
NameplateUnlockable nu = new NameplateUnlockable();
nu.rarity = (string)reader["Rarity"];
nu.unlockConditions = new DBUnlockables.CUnlockConditions();
nu.unlockConditions.Condition = (string)reader["UnlockCondition"];
nu.unlockConditions.Values = JsonConvert.DeserializeObject<int[]>((string)reader["UnlockValues"]) ?? new int[] { 0 };
nu.unlockConditions.Type = (string)reader["UnlockType"];
nu.unlockConditions.Reference = JsonConvert.DeserializeObject<string[]>((string)reader["UnlockReferences"]) ?? new string[] { "" };
nu.nameplateInfo = new SaveFile.CNamePlateTitle((int)((Int64)reader["NameplateType"]));
nu.nameplateInfo.cld.SetString("default", (string)reader["DefaultString"]);
foreach (string tr in _translations)
{
if (reader[@$"{tr}_String"] != DBNull.Value)
nu.nameplateInfo.cld.SetString(tr, (string)reader[@$"{tr}_String"]);
}
data[((Int64)reader["NameplateId"]).ToString()] = nu;
}
}
}
public class NameplateUnlockable
{

View File

@ -0,0 +1,32 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Microsoft.Data.Sqlite;
namespace TJAPlayer3
{
public static class HDatabaseHelpers
{
public static List<string> GetAvailableLanguage(SqliteConnection connection, string prefix)
{
List<string> _translations = new List<string>();
foreach (string cd in CLangManager.Langcodes)
{
var chk = connection.CreateCommand();
chk.CommandText =
@$"
SELECT count(*) FROM sqlite_master WHERE type='table' AND name='{prefix}_{cd}';
";
var chkreader = chk.ExecuteReader();
while (chkreader.Read())
{
if (chkreader.GetInt32(0) > 0)
_translations.Add(cd);
}
}
return _translations;
}
}
}

View File

@ -107,6 +107,7 @@ namespace TJAPlayer3
}
public static readonly string[] Languages = new string[] { "日本語 (Japanese)", "English", "Français (French)", "Español (Spanish)", "中文 (Chinese)", "nl (WIP)", "ko (WIP)" };
public static readonly string[] Langcodes = new string[] { "ja", "en", "fr", "es", "zh", "nl", "ko" };
public static ILang LangInstance { get; private set; } = new CLang_jp();
}
}