diff --git a/.gitattributes b/.gitattributes
new file mode 100644
index 0000000..77bc1fc
--- /dev/null
+++ b/.gitattributes
@@ -0,0 +1,4 @@
+* text=auto eol=lf
+*.cdb binary
+*.zip binary
+*.dll binary
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..cd54f18
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,6 @@
+# build output
+bin/
+obj/
+/out/
+# the engine release build/fetch-engine.sh fetches
+/.engine/
diff --git a/Directory.Build.props b/Directory.Build.props
new file mode 100644
index 0000000..f39ffe9
--- /dev/null
+++ b/Directory.Build.props
@@ -0,0 +1,17 @@
+
+
+
+ $(MSBuildThisFileDirectory)
+ $(RepoRoot).engine/
+ $([System.IO.File]::ReadAllText('$(RepoRoot)engine.json'))
+ $([System.Text.RegularExpressions.Regex]::Match($(EnginePin), '"version"\s*:\s*"([^"]+)"').Groups[1].Value)
+ local
+ true
+ disable
+ disable
+ true
+ en
+ false
+
+
diff --git a/engine.json b/engine.json
new file mode 100644
index 0000000..dafc857
--- /dev/null
+++ b/engine.json
@@ -0,0 +1,7 @@
+{
+ "version": "v1.4.1",
+ "exports": 856,
+ "protocol": 9,
+ "capabilities": 10239,
+ "binding": "v1.4.1"
+}
diff --git a/src/YGOLegacy.Bots/Bot/ArenaReport.cs b/src/YGOLegacy.Bots/Bot/ArenaReport.cs
index 174f2ab..f300893 100644
--- a/src/YGOLegacy.Bots/Bot/ArenaReport.cs
+++ b/src/YGOLegacy.Bots/Bot/ArenaReport.cs
@@ -9,10 +9,10 @@ namespace YGOLegacy.Bot
// ------------------------------------------------------------------------
// The Bot Arena report model + the pure helpers that build it. This file is
// deliberately Unity-free (no UnityEngine, no UniTask, no MDPro3): it is
- // compiled BOTH by the game (BotArena.cs, the in-editor arena of TICKET-030)
- // and by Tools/BotArena (the standalone parallel arena of TICKET-035), so
+ // used BOTH by the game (BotArena.cs, the in-editor arena of TICKET-030)
+ // and by src/BotArena (the standalone parallel arena of TICKET-035), so
// the two produce byte-compatible JSON. Keep it that way — anything that
- // needs Unity belongs in BotArena.cs.
+ // needs Unity belongs in the game's BotArena.cs.
// ------------------------------------------------------------------------
///
diff --git a/src/YGOLegacy.Bots/Bot/DuelStateBus.cs b/src/YGOLegacy.Bots/Bot/DuelStateBus.cs
index 18d314e..c5f9b29 100644
--- a/src/YGOLegacy.Bots/Bot/DuelStateBus.cs
+++ b/src/YGOLegacy.Bots/Bot/DuelStateBus.cs
@@ -47,8 +47,8 @@ namespace YGOLegacy.Bot
/// seat was told, so a brain can see the human's hand without a new parser
/// and without any server change.
///
- /// Nothing here touches UnityEngine, so it compiles into
- /// Tools/BotArena as well as the game.
+ /// Nothing here touches UnityEngine, so the game and BotArena run the
+ /// same code.
///
/// Cost when nobody listens: is false, so both taps
/// are one static bool read per packet and allocate nothing. The bus only
@@ -259,7 +259,7 @@ namespace YGOLegacy.Bot
internal static void Warn(string message)
{
- try { UnityEngine.Debug.LogWarning(LogPrefix + message); } catch (Exception) { }
+ try { YGOLegacy.Bots.BotHost.Log.Warning(LogPrefix + message); } catch (Exception) { }
}
// ==================================================================
diff --git a/src/YGOLegacy.Bots/Bot/LocalDuelHost.cs b/src/YGOLegacy.Bots/Bot/LocalDuelHost.cs
index de014d6..75287a6 100644
--- a/src/YGOLegacy.Bots/Bot/LocalDuelHost.cs
+++ b/src/YGOLegacy.Bots/Bot/LocalDuelHost.cs
@@ -20,8 +20,8 @@ namespace YGOLegacy.Bot
// seat(s) that may see it (blanking what they may not), and feed prompt
// answers back with set_responseb.
//
- // Deliberately Unity-free (Assembly-CSharp compiles it, Tools/BotArena links
- // it) and deliberately transport-free: a seat is an ILoopbackSeat, so the
+ // Deliberately Unity-free (the game and BotArena run this library) and
+ // deliberately transport-free: a seat is an ILoopbackSeat, so the
// standalone arena can plug two WindBot GameClients in with no socket at all
// (LoopbackBotSeat). Nothing in the game uses this yet.
//
diff --git a/src/YGOLegacy.Bots/Bot/Lookahead.cs b/src/YGOLegacy.Bots/Bot/Lookahead.cs
index 1ffdb4a..3dd5baf 100644
--- a/src/YGOLegacy.Bots/Bot/Lookahead.cs
+++ b/src/YGOLegacy.Bots/Bot/Lookahead.cs
@@ -15,7 +15,7 @@ namespace YGOLegacy.Bot
// currently in progress. NOTHING implements it inside the
// game: ocgcore cannot clone a live duel, so the only
// implementation is the arena's perfect-information
- // ReplayOracle (Tools/BotArena/ReplayOracle.cs).
+ // ReplayOracle (src/BotArena/ReplayOracle.cs).
//
// With no oracle installed — every in-game duel today — SmartExecutor's
// planner declines and the executor walk runs exactly once, unchanged.
diff --git a/src/YGOLegacy.Bots/Bot/SmartExecutor.cs b/src/YGOLegacy.Bots/Bot/SmartExecutor.cs
index efe8e72..37f1461 100644
--- a/src/YGOLegacy.Bots/Bot/SmartExecutor.cs
+++ b/src/YGOLegacy.Bots/Bot/SmartExecutor.cs
@@ -35,7 +35,7 @@ namespace YGOLegacy.Bot
/// broken file -> empty rules -> DefaultExecutor-grade play, never a crash.
///
/// Threading: everything here runs on the WindBot thread. No UnityEngine
- /// objects are touched; logging is UnityEngine.Debug.Log only, prefixed
+ /// objects are touched; logging is BotHost.Log only, prefixed
/// [YGOL bot], and gated by (or knob
/// verbose: 1) except for the one line at construction.
///
@@ -279,7 +279,7 @@ namespace YGOLegacy.Bot
journalDuel = JournalDuel;
if (journalFile != null) JournalOpen();
- UnityEngine.Debug.Log(LogPrefix + "SmartExecutor for deck '" + (DeckPath ?? "?") + "'"
+ YGOLegacy.Bots.BotHost.Log.Info(LogPrefix + "SmartExecutor for deck '" + (DeckPath ?? "?") + "'"
+ (character != null ? " as character '" + character.id + "'" : " (no owning character)")
+ " difficulty=" + Difficulty + " aggression=" + Aggression + " tradeTolerance=" + TradeTolerance
+ " seed=" + Seed + " insight=" + YGOLegacy.Bot.Insight.LevelName(Insight.Level) + " rules=" + (Rules.IsEmpty ? "none" : Rules.source + " (" + Rules.combos.Count + " combos, " + Rules.effects.Count + " effect models)")
@@ -2325,7 +2325,7 @@ namespace YGOLegacy.Bot
private void Log(string message)
{
if (!Chatty) return;
- UnityEngine.Debug.Log(LogPrefix + (CharacterId ?? "smart") + " T" + Duel.Turn + " " + Duel.Phase + ": " + message);
+ YGOLegacy.Bots.BotHost.Log.Info(LogPrefix + (CharacterId ?? "smart") + " T" + Duel.Turn + " " + Duel.Phase + ": " + message);
}
private void LogRanked(string head, List ranked)
@@ -2443,7 +2443,7 @@ namespace YGOLegacy.Bot
}
catch (Exception e)
{
- UnityEngine.Debug.LogWarning(LogPrefix + "journal: cannot create " + journalFile + ": " + e.Message);
+ YGOLegacy.Bots.BotHost.Log.Warning(LogPrefix + "journal: cannot create " + journalFile + ": " + e.Message);
}
GameBehavior.YGOL_DuelResult += OnJournalDuelResult;
// The fields are not initialised until the duel starts: the start
@@ -2497,7 +2497,7 @@ namespace YGOLegacy.Bot
line["offered"] = new List(journalOffered);
JournalWrite(line);
}
- catch (Exception e) { UnityEngine.Debug.LogWarning(LogPrefix + "journal duelEnd: " + e.Message); }
+ catch (Exception e) { YGOLegacy.Bots.BotHost.Log.Warning(LogPrefix + "journal duelEnd: " + e.Message); }
}
private Dictionary JournalLine(string kind)
@@ -2525,11 +2525,11 @@ namespace YGOLegacy.Bot
{
string text;
try { text = JsonConvert.SerializeObject(line, Formatting.None); }
- catch (Exception e) { UnityEngine.Debug.LogWarning(LogPrefix + "journal serialize: " + e.Message); return; }
+ catch (Exception e) { YGOLegacy.Bots.BotHost.Log.Warning(LogPrefix + "journal serialize: " + e.Message); return; }
lock (journalLock)
{
try { File.AppendAllText(journalFile, text + "\n"); }
- catch (Exception e) { UnityEngine.Debug.LogWarning(LogPrefix + "journal write: " + e.Message); }
+ catch (Exception e) { YGOLegacy.Bots.BotHost.Log.Warning(LogPrefix + "journal write: " + e.Message); }
}
}
diff --git a/src/YGOLegacy.Bots/Characters/Character.cs b/src/YGOLegacy.Bots/Characters/Character.cs
index 3584026..f044921 100644
--- a/src/YGOLegacy.Bots/Characters/Character.cs
+++ b/src/YGOLegacy.Bots/Characters/Character.cs
@@ -203,7 +203,7 @@ namespace YGOLegacy.Characters
// Empty = master only.
public string[] rulesets = System.Array.Empty();
- // Equals Ruleset.MasterId; BotArena links this file without Ruleset.cs.
+ // Equals the game's Ruleset.MasterId; rulesets stay in the game.
public const string DefaultRuleset = "master";
public bool Plays(string rulesetId)
diff --git a/src/YGOLegacy.Bots/Characters/CharacterRegistry.cs b/src/YGOLegacy.Bots/Characters/CharacterRegistry.cs
index 594887e..ecde5f5 100644
--- a/src/YGOLegacy.Bots/Characters/CharacterRegistry.cs
+++ b/src/YGOLegacy.Bots/Characters/CharacterRegistry.cs
@@ -2,10 +2,7 @@ using System;
using System.Collections.Generic;
using System.IO;
using Newtonsoft.Json;
-using UnityEngine;
-#if !YGOL_STANDALONE
-using Cysharp.Threading.Tasks;
-#endif
+using YGOLegacy.Bots;
namespace YGOLegacy.Characters
{
@@ -16,15 +13,12 @@ namespace YGOLegacy.Characters
/// [YGOL characters] <path>: <error> and skipped — a
/// broken character never breaks boot.
///
- /// The scan runs on the thread pool; the results are published on the
- /// main thread. Before Init completes (or if it was never called) the
- /// registry is simply empty, and BotRoster falls back to its built-in
- /// Dovphin, so callers need not await Loaded unless they need everyone.
- ///
- /// Outside Unity (Tools/BotArena, compiled with YGOL_STANDALONE) the
- /// UniTask surface is compiled out and — the
- /// same scan + publish, synchronous — is the entry point. Both paths share
- /// Scan/Publish, so the two never drift.
+ /// Two ways in, sharing Scan/Publish so they never drift: the game runs
+ /// on the thread pool and on the
+ /// main thread (its own UniTask Init/Loaded); a host without a player loop
+ /// (BotArena, tests) calls , the same two,
+ /// synchronous. Before the first Publish the registry is simply empty, and
+ /// BotRoster falls back to its built-in Dovphin.
///
public static class CharacterRegistry
{
@@ -36,12 +30,6 @@ namespace YGOLegacy.Characters
new(StringComparer.OrdinalIgnoreCase);
private static readonly Dictionary byDeck =
new(StringComparer.OrdinalIgnoreCase);
-#if !YGOL_STANDALONE
- private static UniTaskCompletionSource loadedSource;
-
- /// Completes when the first Init() has published its results.
- public static UniTask Loaded => (loadedSource ??= new UniTaskCompletionSource()).Task;
-#endif
public static bool IsLoaded { get; private set; }
public static IReadOnlyList All() => all;
@@ -95,36 +83,10 @@ namespace YGOLegacy.Characters
return key.Length > 0 && byDeck.TryGetValue(key, out var c) ? c : null;
}
-#if !YGOL_STANDALONE
- ///
- /// Scan the characters folder off the main thread and publish. Safe to
- /// call again (a rescan replaces the tables); the first call is what
- /// Program.Initialize awaits via Loaded.
- ///
- public static async UniTask Init()
- {
- loadedSource ??= new UniTaskCompletionSource();
- List found;
- List problems;
- try
- {
- (found, problems) = await UniTask.RunOnThreadPool(() => Scan(Root));
- }
- catch (Exception e)
- {
- found = new List();
- problems = new List { Root + ": " + e.Message };
- }
-
- await UniTask.SwitchToMainThread();
- Publish(found, problems);
- loadedSource.TrySetResult();
- }
-#endif
///
/// Synchronous scan + publish on the calling thread, for hosts without
- /// a player loop (Tools/BotArena). `charactersRoot` defaults to
+ /// a player loop (BotArena, tests). `charactersRoot` defaults to
/// relative to the current directory; pass an
/// absolute path to read another game root. Safe to call again.
///
@@ -178,24 +140,28 @@ namespace YGOLegacy.Characters
var root = string.IsNullOrEmpty(charactersRoot) ? Root : charactersRoot;
LoadedRoot = root;
lock (groupKnobs) groupKnobs.Clear();
- List found;
- List problems;
- try
+ Publish(Scan(root));
+ }
+
+ /// What one scan of a characters folder found, for .
+ public sealed class ScanResult
+ {
+ public readonly List found;
+ public readonly List problems;
+
+ public ScanResult(List found, List problems)
{
- (found, problems) = Scan(root);
+ this.found = found;
+ this.problems = problems;
}
- catch (Exception e)
- {
- found = new List();
- problems = new List { root + ": " + e.Message };
- }
- Publish(found, problems);
}
/// Replace the tables with a scan's results and log its problems.
/// Main thread in Unity (readers are main-thread callers).
- private static void Publish(List found, List problems)
+ public static void Publish(ScanResult scan)
{
+ var found = scan.found;
+ var problems = scan.problems;
all.Clear();
byId.Clear();
byDeck.Clear();
@@ -224,13 +190,27 @@ namespace YGOLegacy.Characters
}
foreach (var problem in problems)
- Debug.LogError("[YGOL characters] " + problem);
+ BotHost.Log.Error("[YGOL characters] " + problem);
IsLoaded = true;
}
- /// Worker-thread part: pure file IO + JSON, no Unity API.
- private static (List, List) Scan(string root)
+ /// Worker-thread part: pure file IO + JSON, no Unity API. Never throws:
+ /// a folder that cannot be read is one problem line.
+ public static ScanResult Scan(string root)
+ {
+ try
+ {
+ var (found, problems) = ScanFolder(root);
+ return new ScanResult(found, problems);
+ }
+ catch (Exception e)
+ {
+ return new ScanResult(new List(), new List { root + ": " + e.Message });
+ }
+ }
+
+ private static (List, List) ScanFolder(string root)
{
var found = new List();
var problems = new List();
diff --git a/src/YGOLegacy.Bots/Host/BotHost.cs b/src/YGOLegacy.Bots/Host/BotHost.cs
new file mode 100644
index 0000000..5c02e34
--- /dev/null
+++ b/src/YGOLegacy.Bots/Host/BotHost.cs
@@ -0,0 +1,120 @@
+using System;
+using System.Collections.Generic;
+using System.Data;
+
+namespace YGOLegacy.Bots
+{
+ ///
+ /// What the bots need from the program that runs them: the game (solo duels, the in-editor arena) or the
+ /// headless BotArena. The host sets these once at start-up, before the first bot is built or the character
+ /// registry is loaded. Every path the bots read is relative to the current directory, which is the game root.
+ ///
+ public static class BotHost
+ {
+ /// Where the bots' log lines go. Default: the console.
+ public static IBotLog Log { get; set; } = new ConsoleBotLog();
+
+ /// Opens the card databases (cards.cdb and the expansions' .cdb). No default: the host must set it.
+ public static ICardDatabase Cards { get; set; }
+
+ /// The active locale and the .cdb files the host extracted from Expansions/*.ypk. Default: en-US, none.
+ public static IGameFiles Files { get; set; } = new DefaultGameFiles();
+
+ /// The deck size caps of a ruleset. Default: 60 / 99 / 15 for every ruleset.
+ public static IDeckLimits DeckLimits { get; set; } = new DefaultDeckLimits();
+
+ /// The active locale's bot.conf. Default: empty (BotRoster then uses its built-in Dovphin command).
+ public static IBotConf BotConf { get; set; } = new EmptyBotConf();
+
+ internal static ICardDatabase RequireCards()
+ => Cards ?? throw new InvalidOperationException("YGOLegacy.Bots: BotHost.Cards is not set; the host must set it before the card databases load");
+ }
+
+ /// The bots' log. The game routes it to UnityEngine.Debug; the arena to the worker's log.
+ public interface IBotLog
+ {
+ void Info(string message);
+ void Warning(string message);
+ void Error(string message);
+ }
+
+ /// The card databases are SQLite files. The game opens them with Mono.Data.Sqlite, the arena with
+ /// Microsoft.Data.Sqlite (read-only).
+ public interface ICardDatabase
+ {
+ /// A connection to the .cdb at `path`, not yet opened.
+ IDbConnection Connect(string path);
+ }
+
+ public interface IGameFiles
+ {
+ /// The active locale: Data/locales/<Locale>/ holds cards.cdb and bot.conf.
+ string Locale { get; }
+
+ /// The .cdb files inside Expansions/*.ypk, extracted to real files (SQLite needs a file), in load order.
+ IReadOnlyList ExpansionCardDatabases();
+ }
+
+ /// The deck size caps WindBot checks a bot's deck file against.
+ public interface IDeckLimits
+ {
+ /// `rulesetId` is the deck file's `#ruleset` line, or null when it has none.
+ DeckCaps For(string rulesetId);
+ }
+
+ public readonly struct DeckCaps
+ {
+ public readonly int MainMax;
+ public readonly int ExtraMax;
+ public readonly int SideMax;
+
+ public DeckCaps(int mainMax, int extraMax, int sideMax)
+ {
+ MainMax = mainMax;
+ ExtraMax = extraMax;
+ SideMax = sideMax;
+ }
+ }
+
+ /// The bot list in Data/locales/<locale>/bot.conf.
+ public interface IBotConf
+ {
+ IReadOnlyList Entries();
+
+ /// Read bot.conf again (the locale changed).
+ void Reload();
+ }
+
+ /// One `!name` block of bot.conf: the name, the WindBot command line, the description and the flags.
+ public class BotConfEntry
+ {
+ public string name;
+ public string command;
+ public string desc;
+ public string[] flags;
+ }
+
+ internal sealed class ConsoleBotLog : IBotLog
+ {
+ public void Info(string message) => Console.Error.WriteLine(message);
+ public void Warning(string message) => Console.Error.WriteLine("[warn] " + message);
+ public void Error(string message) => Console.Error.WriteLine("[error] " + message);
+ }
+
+ internal sealed class DefaultGameFiles : IGameFiles
+ {
+ public string Locale => "en-US";
+ public IReadOnlyList ExpansionCardDatabases() => Array.Empty();
+ }
+
+ internal sealed class DefaultDeckLimits : IDeckLimits
+ {
+ public DeckCaps For(string rulesetId) => new DeckCaps(60, 99, 15);
+ }
+
+ internal sealed class EmptyBotConf : IBotConf
+ {
+ public IReadOnlyList Entries() => Array.Empty();
+ public void Reload() { }
+ }
+}
diff --git a/src/YGOLegacy.Bots/Properties/AssemblyInfo.cs b/src/YGOLegacy.Bots/Properties/AssemblyInfo.cs
new file mode 100644
index 0000000..9a02f58
--- /dev/null
+++ b/src/YGOLegacy.Bots/Properties/AssemblyInfo.cs
@@ -0,0 +1,8 @@
+using System.Runtime.CompilerServices;
+
+// The code was one assembly with the game (Assembly-CSharp) and the arena, which call some of WindBot's internal
+// members (WindBot.Program.YGOL_Main, Program.Rand, ...). Kept internal; these assemblies may use them.
+[assembly: InternalsVisibleTo("Assembly-CSharp")]
+[assembly: InternalsVisibleTo("Assembly-CSharp-Editor")]
+[assembly: InternalsVisibleTo("BotArena")]
+[assembly: InternalsVisibleTo("YGOLegacy.Bots.Tests")]
diff --git a/src/YGOLegacy.Bots/Services/BotRoster.cs b/src/YGOLegacy.Bots/Services/BotRoster.cs
index f335101..30c5242 100644
--- a/src/YGOLegacy.Bots/Services/BotRoster.cs
+++ b/src/YGOLegacy.Bots/Services/BotRoster.cs
@@ -1,8 +1,7 @@
using System.Collections.Generic;
using System.Text.RegularExpressions;
-using MDPro3.Utility;
+using YGOLegacy.Bots;
using YGOLegacy.Characters;
-using YGOLegacy.Core;
namespace YGOLegacy.Services
{
@@ -56,21 +55,10 @@ namespace YGOLegacy.Services
private const string UseYourDeckFlag = "SELECT_DECKFILE";
private const string DovphinFallbackCommand = "Name=Dovphin Deck=Lucky";
-#if !YGOL_STANDALONE
- public static void Reload() => YGOLegacy.Core.Bot.SoloLoader.Reload();
+ // The host reads the locale's bot.conf (the game: SoloLoader; BotArena: Setup.ReadBots).
+ public static void Reload() => BotHost.BotConf.Reload();
- private static IReadOnlyList Conf()
- {
- if (!YGOLegacy.Core.Bot.SoloLoader.IsReady)
- YGOLegacy.Core.Bot.SoloLoader.Initialize();
- return YGOLegacy.Core.Bot.SoloLoader.Catalog;
- }
-#else
- // Tools/BotArena parses the locale's bot.conf into this shim (Setup.ReadBots).
- public static void Reload() { }
-
- private static IReadOnlyList Conf() => MDPro3.Servant.SoloSelector.bots;
-#endif
+ private static IReadOnlyList Conf() => BotHost.BotConf.Entries();
/// The Name= token in a bot.conf command line, quoted or bare.
private static readonly Regex NameToken =
diff --git a/src/YGOLegacy.Bots/WindBot/Game/Deck.cs b/src/YGOLegacy.Bots/WindBot/Game/Deck.cs
index e2e4b41..da56116 100644
--- a/src/YGOLegacy.Bots/WindBot/Game/Deck.cs
+++ b/src/YGOLegacy.Bots/WindBot/Game/Deck.cs
@@ -38,6 +38,12 @@ namespace WindBot.Game
Cards.Add(card);
}
+ // [YGOL] TICKET-263: the deck file's "#ruleset " line (the game's DeckLimits.RulesetTag).
+ private const string RulesetTag = "#ruleset";
+
+ private static string RulesetOf(string line)
+ => line != null && line.StartsWith(RulesetTag, StringComparison.Ordinal) ? line.Substring(RulesetTag.Length).Trim() : null;
+
public static Deck Load(string name)
{
StreamReader reader = null;
@@ -56,7 +62,7 @@ namespace WindBot.Game
continue;
line = line.Trim();
- ruleset = YGOLegacy.Services.DeckLimits.RulesetOf(line) ?? ruleset; // [YGOL] TICKET-263
+ ruleset = RulesetOf(line) ?? ruleset; // [YGOL] TICKET-263
if (line.StartsWith("#"))
continue;
if (line.Equals("!side"))
@@ -76,10 +82,10 @@ namespace WindBot.Game
// [YGOL] TICKET-012/263: bot-deck file gate follows the deck's
// Ruleset, so bots load the same decks the editor saves.
- var limits = YGOLegacy.Services.DeckLimits.For(ruleset);
+ var limits = YGOLegacy.Bots.BotHost.DeckLimits.For(ruleset);
if (deck.Cards.Count > limits.MainMax)
return null;
- if (deck.ExtraCards.Count > limits.ExtraLimit())
+ if (deck.ExtraCards.Count > limits.ExtraMax)
return null;
if (deck.SideCards.Count > limits.SideMax)
return null;
diff --git a/src/YGOLegacy.Bots/WindBot/Logger.cs b/src/YGOLegacy.Bots/WindBot/Logger.cs
index 84af798..b587385 100644
--- a/src/YGOLegacy.Bots/WindBot/Logger.cs
+++ b/src/YGOLegacy.Bots/WindBot/Logger.cs
@@ -7,7 +7,7 @@ namespace WindBot
public static void WriteLine(string message)
{
Console.WriteLine("[" + DateTime.Now.ToString("yy-MM-dd HH:mm:ss") + "] " + message);
- UnityEngine.Debug.Log("[WindBot] " + message); // [YGOL] Console.WriteLine is invisible in Unity
+ YGOLegacy.Bots.BotHost.Log.Info("[WindBot] " + message); // [YGOL] Console.WriteLine is invisible in Unity; the host routes the log
}
public static void DebugWriteLine(string message)
{
@@ -21,7 +21,7 @@ namespace WindBot
Console.ForegroundColor = ConsoleColor.White;
Console.Error.WriteLine("[" + DateTime.Now.ToString("yy-MM-dd HH:mm:ss") + "] " + message);
Console.ResetColor();
- UnityEngine.Debug.LogWarning("[WindBot] " + message); // [YGOL]
+ YGOLegacy.Bots.BotHost.Log.Warning("[WindBot] " + message); // [YGOL]
}
}
}
\ No newline at end of file
diff --git a/src/YGOLegacy.Bots/WindBot/Program.cs b/src/YGOLegacy.Bots/WindBot/Program.cs
index 3a22b0c..4f1ccf2 100644
--- a/src/YGOLegacy.Bots/WindBot/Program.cs
+++ b/src/YGOLegacy.Bots/WindBot/Program.cs
@@ -6,8 +6,7 @@ using WindBot.Game;
using WindBot.Game.AI;
using YGOSharp.OCGWrapper;
using System.Collections.Specialized;
-using MDPro3.IO;
-using YGOLegacy.Core;
+using YGOLegacy.Bots;
namespace WindBot
{
@@ -84,7 +83,7 @@ namespace WindBot
//if (!File.Exists(absolutePath))
// // In case windbot is placed in a folder under ygopro2 folder
// absolutePath = Path.GetFullPath("../cdb/" + databasePath);
- absolutePath = Path.GetFullPath("Data/locales/" + MDPro3.Utility.Language.GetConfig() + "/" + databasePath);
+ absolutePath = Path.GetFullPath("Data/locales/" + BotHost.Files.Locale + "/" + databasePath); // [YGOL]
if (!File.Exists(absolutePath))
{
Logger.WriteErrorLine("Can't find cards database file.");
@@ -94,10 +93,10 @@ namespace WindBot
System.Environment.Exit(1);
}
var paths = new System.Collections.Generic.List { absolutePath };
- var zipCdbs = ResourceManager.GetAllCdbInZipPaths();
+ var zipCdbs = BotHost.Files.ExpansionCardDatabases(); // [YGOL] the .cdb inside Expansions/*.ypk
if (zipCdbs != null)
paths.AddRange(zipCdbs);
- foreach (var cdb in Directory.GetFiles(GamePaths.PATH_EXPANSIONS, "*.cdb"))
+ foreach (var cdb in Directory.GetFiles("Expansions/", "*.cdb"))
paths.Add(cdb);
NamedCardsManager.InitForMulti(paths);
}
diff --git a/src/YGOLegacy.Bots/YGOLegacy.Bots.csproj b/src/YGOLegacy.Bots/YGOLegacy.Bots.csproj
new file mode 100644
index 0000000..d2fbf9c
--- /dev/null
+++ b/src/YGOLegacy.Bots/YGOLegacy.Bots.csproj
@@ -0,0 +1,56 @@
+
+
+
+
+ netstandard2.1
+ 9
+ true
+ YGOLegacy.Bots
+ YGOLegacy.Bots
+ portable
+ 1.0.0.0
+ 1.0.0.0
+ $(BotsVersion)
+
+ $(NoWarn);CS0108;CS0114;CS0162;CS0164;CS0168;CS0169;CS0219;CS0414;CS0618;CS0649;CS0659;CS0661;CS1522;CS1570;CS1572;CS1573;CS1587;CS1591;CS8981
+
+
+
+
+
+
+
+
+
+
+ $(EngineDir)YGOLegacy.Engine.dll
+ false
+
+
+
+
+
+ $(IntermediateOutputPath)BotsBuild.cs
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/YGOLegacy.Bots/YGOSharp/YGOSharp.OCGWrapper/CardsManager.cs b/src/YGOLegacy.Bots/YGOSharp/YGOSharp.OCGWrapper/CardsManager.cs
index 0fef6f7..d309f39 100644
--- a/src/YGOLegacy.Bots/YGOSharp/YGOSharp.OCGWrapper/CardsManager.cs
+++ b/src/YGOLegacy.Bots/YGOSharp/YGOSharp.OCGWrapper/CardsManager.cs
@@ -1,6 +1,6 @@
using System.Collections.Generic;
using System.Data;
-using Mono.Data.Sqlite;
+using YGOLegacy.Bots; // [YGOL] the host opens the SQLite file (Mono.Data.Sqlite in Unity)
namespace YGOSharp.OCGWrapper
{
@@ -12,12 +12,13 @@ namespace YGOSharp.OCGWrapper
{
_cards = new Dictionary();
- using (SqliteConnection connection = new SqliteConnection("Data Source=" + databaseFullPath))
+ using (IDbConnection connection = BotHost.RequireCards().Connect(databaseFullPath))
{
connection.Open();
- using (IDbCommand command = new SqliteCommand("SELECT id, ot, alias, setcode, type, level, race, attribute, atk, def FROM datas", connection))
+ using (IDbCommand command = connection.CreateCommand())
{
+ command.CommandText = "SELECT id, ot, alias, setcode, type, level, race, attribute, atk, def FROM datas";
using (IDataReader reader = command.ExecuteReader())
{
while (reader.Read())
diff --git a/src/YGOLegacy.Bots/YGOSharp/YGOSharp.OCGWrapper/NamedCardsManager.cs b/src/YGOLegacy.Bots/YGOSharp/YGOSharp.OCGWrapper/NamedCardsManager.cs
index 2af5f35..67a69fa 100644
--- a/src/YGOLegacy.Bots/YGOSharp/YGOSharp.OCGWrapper/NamedCardsManager.cs
+++ b/src/YGOLegacy.Bots/YGOSharp/YGOSharp.OCGWrapper/NamedCardsManager.cs
@@ -1,6 +1,6 @@
using System.Collections.Generic;
using System.Data;
-using Mono.Data.Sqlite;
+using YGOLegacy.Bots; // [YGOL] the host opens the SQLite file (Mono.Data.Sqlite in Unity)
using System;
using System.IO;
@@ -21,15 +21,13 @@ namespace YGOSharp.OCGWrapper
_cards = new Dictionary();
- using (SqliteConnection connection = new SqliteConnection("Data Source=" + databaseFullPath))
+ using (IDbConnection connection = BotHost.RequireCards().Connect(databaseFullPath))
{
connection.Open();
- using (IDbCommand command = new SqliteCommand(
- "SELECT datas.id, ot, alias, setcode, type, level, race, attribute, atk, def, texts.name, texts.desc"
- + " FROM datas INNER JOIN texts ON datas.id = texts.id",
- connection))
+ using (IDbCommand command = connection.CreateCommand())
{
+ command.CommandText = "SELECT datas.id, ot, alias, setcode, type, level, race, attribute, atk, def, texts.name, texts.desc" + " FROM datas INNER JOIN texts ON datas.id = texts.id";
using (IDataReader reader = command.ExecuteReader())
{
while (reader.Read())
@@ -57,15 +55,13 @@ namespace YGOSharp.OCGWrapper
if (!File.Exists(databaseFullPath))
continue;
- using (SqliteConnection connection = new SqliteConnection("Data Source=" + databaseFullPath))
+ using (IDbConnection connection = BotHost.RequireCards().Connect(databaseFullPath))
{
connection.Open();
- using (IDbCommand command = new SqliteCommand(
- "SELECT datas.id, ot, alias, setcode, type, level, race, attribute, atk, def, texts.name, texts.desc"
- + " FROM datas INNER JOIN texts ON datas.id = texts.id",
- connection))
+ using (IDbCommand command = connection.CreateCommand())
{
+ command.CommandText = "SELECT datas.id, ot, alias, setcode, type, level, race, attribute, atk, def, texts.name, texts.desc" + " FROM datas INNER JOIN texts ON datas.id = texts.id";
using (IDataReader reader = command.ExecuteReader())
{
while (reader.Read())