Skip to content

Commit

Permalink
Standardized FinolDigital.Cgs.Json and cgs.json
Browse files Browse the repository at this point in the history
  • Loading branch information
davidmfinol committed Jan 23, 2025
1 parent 34f4f10 commit 08e2b7f
Show file tree
Hide file tree
Showing 28 changed files with 2,011 additions and 80 deletions.
3 changes: 0 additions & 3 deletions Assets/Plugins/FinolDigital.Cgs.CardGameDef.dll

This file was deleted.

33 changes: 0 additions & 33 deletions Assets/Plugins/FinolDigital.Cgs.CardGameDef.dll.meta

This file was deleted.

6 changes: 3 additions & 3 deletions Assets/Resources/games.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@
"games": [
{
"name": "Arcmage",
"url": "https://www.cardgamesimulator.com/games/Arcmage/Arcmage.json"
"url": "https://www.cardgamesimulator.com/games/Arcmage/cgs.json"
},
{
"name": "Grand Archive TCG",
"url": "https://www.cardgamesimulator.com/games/grand_archive/grand_archive.json"
"url": "https://www.cardgamesimulator.com/games/grand_archive/cgs.json"
},
{
"name": "ZU Tiles",
"url": "https://www.cardgamesimulator.com/games/zu_tiles/zu_tiles.json"
"url": "https://www.cardgamesimulator.com/games/zu_tiles/cgs.json"
}
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"allowUnsafeCode": false,
"overrideReferences": false,
"precompiledReferences": [
"FinolDigital.Cgs.CardGameDef.dll",
"FinolDigital.Cgs.Json.dll",
"Newtonsoft.Json.dll"
],
"autoReferenced": false,
Expand Down
20 changes: 14 additions & 6 deletions Assets/Scripts/FinolDigital.Cgs.Json.Unity/UnityCardGame.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,11 @@ public class UnityCardGame : CardGame

public string GameDirectoryPath => Path.Combine(GamesDirectoryPath, UnityFileMethods.GetSafeFileName(Id));

public string GameFilePath => Path.Combine(GameDirectoryPath,
public string GameBackupFilePath => Path.Combine(GameDirectoryPath,
UnityFileMethods.GetSafeFileName(Name) + UnityFileMethods.JsonExtension);

public string GameFilePath => GameDirectoryPath + "/cgs.json";

public string CardsFilePath => GameDirectoryPath + "/AllCards.json";
public string DecksFilePath => GameDirectoryPath + "/AllDecks.json";
public string SetsFilePath => GameDirectoryPath + "/AllSets.json";
Expand Down Expand Up @@ -160,6 +162,7 @@ public UnityCardGame(MonoBehaviour coroutineRunner, string id = DefaultName, str
public void ClearDefinitionLists()
{
CardProperties.Clear();
DeckPlayCards.Clear();
DeckUrls.Clear();
Enums.Clear();
Extras.Clear();
Expand All @@ -173,16 +176,18 @@ public void ReadProperties()
{
// We need to read the *Game:Name*.json file, but reading it can cause *Game:Name/ID* to change, so account for that
var gameFilePath = GameFilePath;
if (!File.Exists(gameFilePath))
gameFilePath = GameBackupFilePath;
var gameDirectoryPath = GameDirectoryPath;
ClearDefinitionLists();
JsonConvert.PopulateObject(File.ReadAllText(GameFilePath), this);
JsonConvert.PopulateObject(File.ReadAllText(gameFilePath), this);
RefreshId();
if (!gameFilePath.Equals(GameFilePath) && File.Exists(gameFilePath))
{
var tempGameFilePath =
var newGameFilePath =
Path.Combine(gameDirectoryPath,
UnityFileMethods.GetSafeFileName(Name) + UnityFileMethods.JsonExtension);
File.Move(gameFilePath, tempGameFilePath);
File.Move(gameFilePath, newGameFilePath);
}

if (!gameDirectoryPath.Equals(GameDirectoryPath) && Directory.Exists(gameDirectoryPath))
Expand Down Expand Up @@ -224,7 +229,7 @@ public IEnumerator Download(bool isRedo = false)

// We should always first get the *Game:Name*.json file and read it before doing anything else
DownloadProgress = 0f / (7f + AllCardsUrlPageCount);
DownloadStatus = "Downloading: CardGameDef...";
DownloadStatus = "Downloading: Card Game Specification...";
if (AutoUpdateUrl != null && AutoUpdateUrl.IsAbsoluteUri)
yield return UnityFileMethods.SaveUrlToFile(AutoUpdateUrl.AbsoluteUri, GameFilePath);
ReadProperties();
Expand Down Expand Up @@ -435,7 +440,10 @@ public void Load(CardGameCoroutineDelegate updateCoroutine, CardGameCoroutineDel
var daysSinceUpdate = 0;
try
{
daysSinceUpdate = (int) DateTime.Today.Subtract(File.GetLastWriteTime(GameFilePath).Date).TotalDays;
var gameFilePath = GameFilePath;
if (!File.Exists(gameFilePath))
gameFilePath = GameBackupFilePath;
daysSinceUpdate = (int) DateTime.Today.Subtract(File.GetLastWriteTime(gameFilePath).Date).TotalDays;
}
catch
{
Expand Down
2 changes: 1 addition & 1 deletion Assets/Scripts/FinolDigital.Cgs.Json.Unity/UnityDeck.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
using System.Collections.Generic;
using System.IO;
using System.Linq;
using FinolDigital.Cgs.CardGameDef.Decks;
using FinolDigital.Cgs.Json.Decks;
using UnityExtensionMethods;
#if !UNITY_WEBGL
using Didstopia.PDFSharp;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"allCardsUrl": "https://www.cardgamesimulator.com/games/Dominoes/AllCards.json",
"allSetsUrl": "https://www.cardgamesimulator.com/games/Dominoes/AllSets.json",
"autoUpdateUrl": "https://www.cardgamesimulator.com/games/Dominoes/Dominoes.json",
"autoUpdateUrl": "https://www.cardgamesimulator.com/games/Dominoes/cgs.json",
"bannerImageUrl": "https://www.cardgamesimulator.com/games/Dominoes/Banner.png",
"cardBackImageUrl": "https://www.cardgamesimulator.com/games/Dominoes/CardBack.png",
"cardImageUrl": "https://www.cardgamesimulator.com/games/Dominoes/sets/{cardSet}/{cardId}.{cardImageFileType}",
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"allCardsUrl": "https://www.cardgamesimulator.com/games/Mahjong/AllCards.json",
"allSetsUrl": "https://www.cardgamesimulator.com/games/Mahjong/AllSets.json",
"autoUpdateUrl": "https://www.cardgamesimulator.com/games/Mahjong/Mahjong.json",
"autoUpdateUrl": "https://www.cardgamesimulator.com/games/Mahjong/cgs.json",
"bannerImageUrl": "https://www.cardgamesimulator.com/games/Mahjong/Banner.png",
"cardBackImageUrl": "https://www.cardgamesimulator.com/games/Mahjong/CardBack.png",
"cardImageUrl": "https://www.cardgamesimulator.com/games/Mahjong/sets/{cardSet}/{cardId}.{cardImageFileType}",
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"allCardsUrl": "https://www.cardgamesimulator.com/games/Standard/AllCards.json",
"allSetsUrl": "https://www.cardgamesimulator.com/games/Standard/AllSets.json",
"autoUpdateUrl": "https://www.cardgamesimulator.com/games/Standard/Standard.json",
"autoUpdateUrl": "https://www.cardgamesimulator.com/games/Standard/cgs.json",
"bannerImageUrl": "https://www.cardgamesimulator.com/games/Standard/Banner.png",
"cardBackFaceImageUrls": [
{
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion docs/games/Arcmage/Arcmage.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"allDecksUrlPostBodyContent": "\"status\":{\"guid\":\"7dedc883-5dd2-5f17-b2a4-eaf04f7ad464\"},\"pageSize\":50,\"pageNumber\":1",
"allDecksUrlTxtRoot": "https://cgs.games/api/proxy/aminduna.arcmage.org",
"allSetsUrl": "https://cgs.games/api/proxy/aminduna.arcmage.org/api/CardOptions",
"autoUpdateUrl": "https://www.cardgamesimulator.com/games/Arcmage/Arcmage.json",
"autoUpdateUrl": "https://www.cardgamesimulator.com/games/Arcmage/cgs.json",
"bannerImageUrl": "https://www.cardgamesimulator.com/games/Arcmage/Banner.png",
"cardBackImageUrl": "https://www.cardgamesimulator.com/games/Arcmage/CardBack.png",
"cardDataIdentifier": "items",
Expand Down
147 changes: 147 additions & 0 deletions docs/games/Arcmage/cgs.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,147 @@
{
"allCardsUrl": "https://cgs.games/api/proxy/aminduna.arcmage.org/api/CardSearch",
"allCardsUrlPageCountIdentifier": "totalItems",
"allCardsUrlPageCountDivisor": 50,
"allCardsUrlPageIdentifier": ",\"pageNumber\":",
"allCardsUrlPostBodyContent": "\"status\":{\"guid\":\"7dedc883-5dd2-5f17-b2a4-eaf04f7ad464\"},\"pageSize\":50",
"allDecksUrl": "https://cgs.games/api/proxy/aminduna.arcmage.org/api/DeckSearch",
"allDecksUrlDataIdentifier": "items",
"allDecksUrlPostBodyContent": "\"status\":{\"guid\":\"7dedc883-5dd2-5f17-b2a4-eaf04f7ad464\"},\"pageSize\":50,\"pageNumber\":1",
"allDecksUrlTxtRoot": "https://cgs.games/api/proxy/aminduna.arcmage.org",
"allSetsUrl": "https://cgs.games/api/proxy/aminduna.arcmage.org/api/CardOptions",
"autoUpdateUrl": "https://www.cardgamesimulator.com/games/Arcmage/cgs.json",
"bannerImageUrl": "https://www.cardgamesimulator.com/games/Arcmage/Banner.png",
"cardBackImageUrl": "https://www.cardgamesimulator.com/games/Arcmage/CardBack.png",
"cardDataIdentifier": "items",
"cardIdIdentifier": "guid",
"cardImageFileType": "jpg",
"cardImageUrl": "https://cgs.games/api/proxy/aminduna.arcmage.org{jpeg}",
"cardSetIdentifier": "serie",
"cardSetIsObject": true,
"cardPrimaryProperty": "ruleText",
"cardProperties": [
{
"name": "faction",
"display": "Faction",
"type": "objectEnum"
},
{
"name": "cost",
"display": "Cost",
"displayEmpty": "NONE or N/A",
"type": "string"
},
{
"name": "type",
"display": "Type",
"type": "objectEnum"
},
{
"name": "subType",
"display": "Sub-Type",
"displayEmpty": "NONE or N/A",
"type": "string"
},
{
"name": "ruleText",
"display": "Rules Text",
"type": "string"
},
{
"name": "flavorText",
"display": "Flavor Text",
"type": "string"
},
{
"name": "loyalty",
"display": "Loyalty",
"displayEmpty": "NONE or N/A",
"type": "integer"
},
{
"name": "attack",
"display": "Attack",
"displayEmpty": "N / A",
"type": "string"
},
{
"name": "defense",
"display": "Defense",
"displayEmpty": "N / A",
"type": "string"
},
{
"name": "artist",
"display": "Artist",
"displayEmpty": "NONE or N/A",
"type": "string"
},
{
"name": "status",
"display": "Release Status",
"type": "objectEnum"
},
{
"name": "info",
"type": "string"
},
{
"name": "jpeg",
"type": "string"
}
],
"cardSize": {
"x": 2.559,
"y": 3.622
},
"cgsGamesLink": "https://cgs.games/link/arcmage",
"copyright": "Arcmage.org",
"deckMaxCount": 45,
"deckSharePreference": "individual",
"enums": [
{
"property": "faction",
"values": {
"1": "None",
"2": "Gaian",
"3": "Dark Legion",
"4": "Red Banner",
"5": "House of Nobles",
"6": "The Empire"
}
},
{
"property": "type",
"values": {
"1": "None",
"2": "Creature",
"3": "Event",
"4": "Equipment",
"5": "Magic",
"6": "Enchantment",
"7": "City"
}
},
{
"property": "status",
"values": {
"1": "Draft",
"2": "Final",
"3": "Release Candidate"
}
}
],
"extras": [
{
"group": "Cities",
"property": "type",
"value": "City"
}
],
"gamePlayDeckName": "Deck",
"gameStartHandCount": 7,
"name": "Arcmage",
"rulesUrl": "https://arcmage.org/rules/",
"setCodeIdentifier": "id",
"setDataIdentifier": "series"
}
2 changes: 1 addition & 1 deletion docs/games/Dominoes/Dominoes.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"allCardsUrl": "https://www.cardgamesimulator.com/games/Dominoes/AllCards.json",
"allSetsUrl": "https://www.cardgamesimulator.com/games/Dominoes/AllSets.json",
"autoUpdateUrl": "https://www.cardgamesimulator.com/games/Dominoes/Dominoes.json",
"autoUpdateUrl": "https://www.cardgamesimulator.com/games/Dominoes/cgs.json",
"bannerImageUrl": "https://www.cardgamesimulator.com/games/Dominoes/Banner.png",
"cardBackImageUrl": "https://www.cardgamesimulator.com/games/Dominoes/CardBack.png",
"cardImageUrl": "https://www.cardgamesimulator.com/games/Dominoes/sets/{cardSet}/{cardId}.{cardImageFileType}",
Expand Down
Loading

0 comments on commit 08e2b7f

Please sign in to comment.