Add few bases for the unlockables system
This commit is contained in:
parent
e8a3f28579
commit
f2e132a08e
@ -16,6 +16,8 @@ namespace TJAPlayer3
|
||||
ObjectCreationHandling = ObjectCreationHandling.Auto,
|
||||
DefaultValueHandling = DefaultValueHandling.Include,
|
||||
// ContractResolver = new CamelCasePropertyNamesContractResolver(),
|
||||
NullValueHandling = NullValueHandling.Ignore,
|
||||
MissingMemberHandling = MissingMemberHandling.Ignore,
|
||||
Converters = new StringEnumConverter[] { new StringEnumConverter() }
|
||||
};
|
||||
|
||||
|
163
TJAPlayer3/Databases/DBUnlockables.cs
Normal file
163
TJAPlayer3/Databases/DBUnlockables.cs
Normal file
@ -0,0 +1,163 @@
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace TJAPlayer3
|
||||
{
|
||||
class DBUnlockables
|
||||
{
|
||||
public void tDBUnlockables()
|
||||
{
|
||||
if (!File.Exists(@".\Databases\Unlockables.json"))
|
||||
tSaveFile();
|
||||
|
||||
tLoadFile();
|
||||
}
|
||||
|
||||
#region [Auxilliary classes]
|
||||
|
||||
public Dictionary<string, int> RequiredArgs = new Dictionary<string, int>()
|
||||
{
|
||||
["ch"] = 1,
|
||||
["cs"] = 1,
|
||||
};
|
||||
|
||||
public class CUnlockConditions
|
||||
{
|
||||
public CUnlockConditions(string cd, int[] vl, string tp, string rf)
|
||||
{
|
||||
Condition = cd;
|
||||
Values = vl;
|
||||
Type = tp;
|
||||
Reference = rf;
|
||||
}
|
||||
|
||||
// Condition type
|
||||
[JsonProperty("condition")]
|
||||
public string Condition;
|
||||
|
||||
// Condition values
|
||||
[JsonProperty("values")]
|
||||
public int[] Values;
|
||||
|
||||
// Condition type
|
||||
[JsonProperty("type")]
|
||||
public string Type;
|
||||
|
||||
// Referenced chart
|
||||
[JsonProperty("reference")]
|
||||
public string Reference;
|
||||
|
||||
[JsonIgnore]
|
||||
private int RequiredArgCount = -1;
|
||||
|
||||
/*
|
||||
* == Types of conditions ==
|
||||
* l : "Less than"
|
||||
* le : "Less or equal"
|
||||
* e : "Equal"
|
||||
* me : "More or equal"
|
||||
* m : "More than" (Default)
|
||||
* d : "Different"
|
||||
*/
|
||||
public bool tValueRequirementMet(int val1, int val2)
|
||||
{
|
||||
switch (this.Type)
|
||||
{
|
||||
case "l":
|
||||
return (val1 < val2);
|
||||
case "le":
|
||||
return (val1 <= val2);
|
||||
case "e":
|
||||
return (val1 == val2);
|
||||
case "me":
|
||||
return (val1 >= val2);
|
||||
case "m":
|
||||
return (val1 > val2);
|
||||
case "d":
|
||||
return (val1 != val2);
|
||||
default:
|
||||
return (val1 > val2);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* == Condition avaliable ==
|
||||
* ch : "Coins here", coin requirement, payable within the heya menu, 1 value : [Coin price]
|
||||
* cs : "Coins shop", coin requirement, payable only within the Medal shop selection screen
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*/
|
||||
public (bool, string) tConditionMet(int[] inputValues)
|
||||
{
|
||||
if (RequiredArgCount < 0 && TJAPlayer3.Databases.DBUnlockables.RequiredArgs.ContainsKey(Condition))
|
||||
RequiredArgCount = TJAPlayer3.Databases.DBUnlockables.RequiredArgs[Condition];
|
||||
|
||||
if (this.Values.Length < this.RequiredArgCount)
|
||||
return (false, CLangManager.LangInstance.GetString(90005) + this.Condition + " requires " + this.RequiredArgCount.ToString() + " values.");
|
||||
|
||||
switch (this.Condition)
|
||||
{
|
||||
case "ch":
|
||||
// Coins are strictly more or equal
|
||||
this.Type = "me";
|
||||
bool fulfiled = this.tValueRequirementMet(inputValues[0], this.Values[0]);
|
||||
return (fulfiled, CLangManager.LangInstance.GetString(90003 + ((fulfiled == false) ? 1 : 0)));
|
||||
case "cs":
|
||||
return (false, CLangManager.LangInstance.GetString(90001)); // Will be buyable later from the randomized shop
|
||||
}
|
||||
|
||||
return (false, CLangManager.LangInstance.GetString(90000));
|
||||
}
|
||||
|
||||
public string tConditionMessage()
|
||||
{
|
||||
if (RequiredArgCount < 0 && TJAPlayer3.Databases.DBUnlockables.RequiredArgs.ContainsKey(Condition))
|
||||
RequiredArgCount = TJAPlayer3.Databases.DBUnlockables.RequiredArgs[Condition];
|
||||
|
||||
if (this.Values.Length < this.RequiredArgCount)
|
||||
return (CLangManager.LangInstance.GetString(90005) + this.Condition + " requires " + this.RequiredArgCount.ToString() + " values.");
|
||||
|
||||
switch (this.Condition)
|
||||
{
|
||||
case "ch":
|
||||
return (CLangManager.LangInstance.GetString(90002) + this.Values[0]);
|
||||
case "cs":
|
||||
return (CLangManager.LangInstance.GetString(90001)); // Will be buyable later from the randomized shop
|
||||
}
|
||||
return (CLangManager.LangInstance.GetString(90000));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
public class CUnlockables
|
||||
{
|
||||
[JsonProperty("puchichara")]
|
||||
public Dictionary<int, CUnlockConditions> Puchichara = new Dictionary<int, CUnlockConditions>();
|
||||
}
|
||||
|
||||
public CUnlockables data = new CUnlockables();
|
||||
|
||||
#region [private]
|
||||
|
||||
private void tSaveFile()
|
||||
{
|
||||
ConfigManager.SaveConfig(data, @".\Databases\Unlockables.json");
|
||||
}
|
||||
|
||||
private void tLoadFile()
|
||||
{
|
||||
data = ConfigManager.GetConfig<CUnlockables>(@".\Databases\Unlockables.json");
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
@ -8,9 +8,13 @@ namespace TJAPlayer3
|
||||
public void tDatabases()
|
||||
{
|
||||
DBPuchichara = new DBPuchichara();
|
||||
DBUnlockables = new DBUnlockables();
|
||||
|
||||
DBPuchichara.tDBPuchichara();
|
||||
DBUnlockables.tDBUnlockables();
|
||||
}
|
||||
|
||||
public DBPuchichara DBPuchichara;
|
||||
public DBUnlockables DBUnlockables;
|
||||
}
|
||||
}
|
@ -263,6 +263,13 @@ namespace TJAPlayer3
|
||||
[1032] = "Character",
|
||||
[1033] = "Dan Title",
|
||||
[1034] = "Nameplate Title",
|
||||
|
||||
[90000] = "[ERROR] Invalid condition",
|
||||
[90001] = "Item only avaliable at the Shop.",
|
||||
[90002] = "Coin price : ",
|
||||
[90003] = "Item bought !",
|
||||
[90004] = "Not enough coins !",
|
||||
[90005] = "The following condition : ",
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -254,6 +254,13 @@ namespace TJAPlayer3
|
||||
[1032] = "Personnage",
|
||||
[1033] = "Titre Dan",
|
||||
[1034] = "Titre",
|
||||
|
||||
[90000] = "[ERREUR] Condition invalide",
|
||||
[90001] = "L'article n'est disponible que dans le Magasin.",
|
||||
[90002] = "Prix en pièces : ",
|
||||
[90003] = "Article acheté !",
|
||||
[90004] = "Nombre de pièces insuffisant !",
|
||||
[90005] = "La condition suivante : ",
|
||||
};
|
||||
}
|
||||
}
|
@ -318,7 +318,13 @@ namespace TJAPlayer3
|
||||
[1032] = "キャラクター",
|
||||
[1033] = "段位称号",
|
||||
[1034] = "名札称号",
|
||||
|
||||
};
|
||||
|
||||
[90000] = "[エラー] 無効な条件",
|
||||
[90001] = "上記の商品はコイン商店に限りです、部屋に購入ができません。",
|
||||
[90002] = "コインの値段 : ",
|
||||
[90003] = "商品購入済み !",
|
||||
[90004] = "コインが足りません !",
|
||||
[90005] = "下記の条件 : ",
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -239,6 +239,14 @@ namespace TJAPlayer3
|
||||
|
||||
tmpTex.t2DŠg‘å—¦<EFBFBD>l—¶<EFBFBD>ã’†‰›Šî<EFBFBD>€•`‰æ(TJAPlayer3.app.Device, 620 + 302 * i, 448);
|
||||
}
|
||||
|
||||
#region [Unlockable information zone]
|
||||
|
||||
if (i == 0 && this.ttkInfoSection != null)
|
||||
TJAPlayer3.stage選曲.act曲リスト.ResolveTitleTexture(this.ttkInfoSection)
|
||||
.t2D拡大率考慮上中央基準描画(TJAPlayer3.app.Device, 620, 560);
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
||||
@ -429,7 +437,7 @@ namespace TJAPlayer3
|
||||
|
||||
#region [Decide]
|
||||
|
||||
TJAPlayer3.Skin.sound決定音.t再生する();
|
||||
ESelectStatus ess = ESelectStatus.SELECTED;
|
||||
|
||||
// Return to main menu
|
||||
if (iCurrentMenu == -1 && iMainMenuCurrent == 0)
|
||||
@ -443,16 +451,24 @@ namespace TJAPlayer3
|
||||
else if (iCurrentMenu == -1)
|
||||
{
|
||||
iCurrentMenu = iMainMenuCurrent - 1;
|
||||
|
||||
if (iCurrentMenu == 0)
|
||||
this.tUpdateUnlockableTextPuchi();
|
||||
}
|
||||
|
||||
else if (iCurrentMenu == 0)
|
||||
{
|
||||
TJAPlayer3.NamePlateConfig.data.PuchiChara[iPlayer] = iPuchiCharaCurrent;
|
||||
ess = this.tSelectPuchi();
|
||||
|
||||
TJAPlayer3.NamePlateConfig.tApplyHeyaChanges();
|
||||
if (ess == ESelectStatus.SELECTED)
|
||||
{
|
||||
TJAPlayer3.NamePlateConfig.data.PuchiChara[iPlayer] = iPuchiCharaCurrent;
|
||||
|
||||
iCurrentMenu = -1;
|
||||
this.tResetOpts();
|
||||
TJAPlayer3.NamePlateConfig.tApplyHeyaChanges();
|
||||
|
||||
iCurrentMenu = -1;
|
||||
this.tResetOpts();
|
||||
}
|
||||
}
|
||||
|
||||
else if (iCurrentMenu == 1)
|
||||
@ -511,6 +527,13 @@ namespace TJAPlayer3
|
||||
this.tResetOpts();
|
||||
}
|
||||
|
||||
if (ess == ESelectStatus.SELECTED)
|
||||
TJAPlayer3.Skin.sound決定音.t再生する();
|
||||
else if (ess == ESelectStatus.FAILED)
|
||||
TJAPlayer3.Skin.soundError.t再生する();
|
||||
else
|
||||
TJAPlayer3.Skin.SoundBanapas.t再生する(); // To change with a more appropriate sfx sooner or later
|
||||
|
||||
#endregion
|
||||
}
|
||||
|
||||
@ -572,6 +595,7 @@ namespace TJAPlayer3
|
||||
private int iPuchiCharaCurrent;
|
||||
|
||||
private TitleTextureKey[] ttkPuchiCharaNames;
|
||||
private TitleTextureKey ttkInfoSection;
|
||||
|
||||
private int iCharacterCurrent;
|
||||
private int iDanTitleCurrent;
|
||||
@ -594,7 +618,10 @@ namespace TJAPlayer3
|
||||
if (iCurrentMenu == -1)
|
||||
iMainMenuCurrent = (this.ttkMainMenuOpt.Length + iMainMenuCurrent + off) % this.ttkMainMenuOpt.Length;
|
||||
else if (iCurrentMenu == 0)
|
||||
{
|
||||
iPuchiCharaCurrent = (iPuchiCharaCount + iPuchiCharaCurrent + off) % iPuchiCharaCount;
|
||||
tUpdateUnlockableTextPuchi();
|
||||
}
|
||||
else if (iCurrentMenu == 1)
|
||||
iCharacterCurrent = (iCharacterCount + iCharacterCurrent + off) % iCharacterCount;
|
||||
else if (iCurrentMenu == 2)
|
||||
@ -605,11 +632,63 @@ namespace TJAPlayer3
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#region [Puchi unlockables]
|
||||
private void tUpdateUnlockableTextPuchi()
|
||||
{
|
||||
#region [Check unlockable]
|
||||
|
||||
if (puchiUnlockables.ContainsKey(iPuchiCharaCurrent))
|
||||
{
|
||||
// To update then when bought unlockables will be implemented
|
||||
this.ttkInfoSection = new TitleTextureKey(puchiUnlockables[iPuchiCharaCurrent].tConditionMessage()
|
||||
, this.pfHeyaFont, Color.White, Color.Black, 1000);
|
||||
}
|
||||
else
|
||||
this.ttkInfoSection = null;
|
||||
|
||||
#endregion
|
||||
}
|
||||
|
||||
private ESelectStatus tSelectPuchi()
|
||||
{
|
||||
// Add "If unlocked" to select directly
|
||||
if (puchiUnlockables.ContainsKey(iPuchiCharaCurrent))
|
||||
{
|
||||
(bool, string) response = puchiUnlockables[iPuchiCharaCurrent].tConditionMet(new int[]{ TJAPlayer3.NamePlateConfig.data.Medals[TJAPlayer3.SaveFile] } );
|
||||
Color responseColor = (response.Item1) ? Color.Lime : Color.Red;
|
||||
|
||||
// Send coins here for the unlock, considering that only coin-paid puchicharas can be unlocked directly from the Heya menu
|
||||
|
||||
this.ttkInfoSection = new TitleTextureKey(response.Item2, this.pfHeyaFont, responseColor, Color.Black, 1000);
|
||||
|
||||
return (response.Item1) ? ESelectStatus.SUCCESS : ESelectStatus.FAILED;
|
||||
}
|
||||
|
||||
|
||||
return ESelectStatus.SELECTED;
|
||||
}
|
||||
|
||||
/*
|
||||
* FAILED : Selection/Purchase failed (failed condition)
|
||||
* SUCCESS : Purchase succeed (without selection)
|
||||
* SELECTED : Selection succeed
|
||||
*/
|
||||
private enum ESelectStatus
|
||||
{
|
||||
FAILED,
|
||||
SUCCESS,
|
||||
SELECTED
|
||||
};
|
||||
|
||||
#endregion
|
||||
|
||||
private TitleTextureKey[] ttkMainMenuOpt;
|
||||
private CPrivateFastFont pfHeyaFont;
|
||||
|
||||
private Dictionary<int, DBUnlockables.CUnlockConditions> puchiUnlockables = TJAPlayer3.Databases.DBUnlockables.data.Puchichara;
|
||||
|
||||
private TitleTextureKey[] ttkDanTitles;
|
||||
|
||||
private TitleTextureKey[] ttkTitles;
|
||||
|
@ -125,6 +125,7 @@
|
||||
<Compile Include="Common\Discord.cs" />
|
||||
<Compile Include="Common\Easing.cs" />
|
||||
<Compile Include="Common\NamePlateConfig.cs" />
|
||||
<Compile Include="Databases\DBUnlockables.cs" />
|
||||
<Compile Include="Databases\Databases.cs" />
|
||||
<Compile Include="Databases\DBPuchichara.cs" />
|
||||
<Compile Include="I18N\CLang_es.cs" />
|
||||
@ -369,6 +370,9 @@
|
||||
<PackageReference Include="SharpDX.DirectSound">
|
||||
<Version>4.2.0</Version>
|
||||
</PackageReference>
|
||||
<PackageReference Include="System.ValueTuple">
|
||||
<Version>4.5.0</Version>
|
||||
</PackageReference>
|
||||
</ItemGroup>
|
||||
<ItemGroup />
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
|
19
Test/Databases/Unlockables.json
Normal file
19
Test/Databases/Unlockables.json
Normal file
@ -0,0 +1,19 @@
|
||||
{
|
||||
"puchichara": {
|
||||
2: {
|
||||
"condition": "ch",
|
||||
"type": "me",
|
||||
"values": [
|
||||
200,
|
||||
],
|
||||
},
|
||||
4: {
|
||||
"condition": "cs",
|
||||
"type": "me",
|
||||
"values": [
|
||||
1400,
|
||||
],
|
||||
},
|
||||
},
|
||||
|
||||
}
|
@ -216,4 +216,13 @@
|
||||
1032 : Character
|
||||
1033 : Dan title
|
||||
1034 : Plate title
|
||||
|
||||
# Feature specific errors (9XXXX)
|
||||
|
||||
90000 : "Invalid condition" error message
|
||||
90001 : "You can buy it at the Shop" condition/failed condition message (cs)
|
||||
90002 : "Coin price : " condition message (ch)
|
||||
90003 : "Item bought !" succeed condition message (ch)
|
||||
90004 : "Not enough coins !" failed condition message (ch)
|
||||
90005 : "The following condition : " missing arguments error message
|
||||
```
|
BIN
Test/System.ValueTuple.dll
Normal file
BIN
Test/System.ValueTuple.dll
Normal file
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user