public void Run() { GameDataLists gameDataLists = new GameDataLists(); gameDataLists.Load(@"..\..\..\datasource\export\exd-all\"); bool result = true; result = result && ValidateCardIds(gameDataLists); result = result && ValidateNpcIds(gameDataLists); result = result && gameDataLists.Link(); if (result) { var mapRuleByCodeName = BuildRuleNameMap(); var mapCardTypeByCodeName = BuildCardTypes(); result = result && ExportRuleNames(gameDataLists.rules, mapRuleByCodeName); result = result && ExportCardTypes(gameDataLists.cardTypes, mapCardTypeByCodeName); result = result && UpdateCards(gameDataLists, mapCardTypeByCodeName); result = result && UpdateNpcs(gameDataLists, mapRuleByCodeName); result = result && UpdateTournaments(gameDataLists, mapRuleByCodeName); } if (result) { LocalizationDB.Get().Save(); TriadCardDB.Get().Save(); TriadNpcDB.Get().Save(); TriadTournamentDB.Get().Save(); } Logger.WriteLine(result ? "Done." : "Aborted"); }
private bool UpdateTournaments(GameDataLists gameDataLists, Dictionary <string, TriadGameModifier> mapRuleNames) { Logger.WriteLine("Updating tournament list..."); // TODO: not sure how to find it in .csv data, // hardcode entries + rules for now // alert new new unique entry appears var uniqueTournamentNames = new List <string>(); var uniqueTournamentLocNames = new List <LocString>(); foreach (var tourData in gameDataLists.tournamentNames) { var codeName = tourData.Name.GetCodeName(); if (!string.IsNullOrEmpty(codeName)) { if (!uniqueTournamentNames.Contains(codeName)) { uniqueTournamentNames.Add(codeName); uniqueTournamentLocNames.Add(tourData.Name); } } } string[] hardcodedNames = { "the Manderville Tournament of Champions", "the Spinner's Pull", "the Durai Memorial", "the Rowena Cup Classic" }; string[] hardcodedRules = { "All Open", "Plus", "Three Open", "Swap", "Order", "Same", "Roulette", "Roulette", }; if (uniqueTournamentNames.Count != hardcodedNames.Length) { Logger.WriteLine("FAILED tournament update, hardcoded list diff! [{0}]", string.Join(", ", uniqueTournamentNames)); return(false); } TriadTournamentDB tournamentDB = TriadTournamentDB.Get(); for (int idx = 0; idx < uniqueTournamentNames.Count; idx++) { if (uniqueTournamentNames[idx] != hardcodedNames[idx]) { Logger.WriteLine("FAILED tournament update, id:{0} mismatch!", idx); return(false); } TriadTournament tourOb = (idx < tournamentDB.tournaments.Count) ? tournamentDB.tournaments[idx] : null; if (tourOb == null) { while (tournamentDB.tournaments.Count <= idx) { tournamentDB.tournaments.Add(new TriadTournament(idx, new List <TriadGameModifier>())); } tourOb = tournamentDB.tournaments[idx]; } tourOb.Name.Text = uniqueTournamentLocNames[idx].Text; tourOb.Rules.Clear(); int ruleStartIdx = idx * 2; for (int ruleIdx = 0; ruleIdx < 2; ruleIdx++) { tourOb.Rules.Add(mapRuleNames[hardcodedRules[ruleIdx + ruleStartIdx]]); } } return(true); }