From ff8eb61bc22229eb3314a7c59b9b246a0cd16ce1 Mon Sep 17 00:00:00 2001 From: Angel Mankel Date: Mon, 19 Oct 2026 18:19:14 -0700 Subject: [PATCH] test: the library through BotHost and 100 Linux arena duels on a fixture game root tests/fixture/game is built by make-fixture.py from the Unity repo's Data/ at dev 19c6158 (AI_OldSchool, its 17 cards and scripts, bot.conf) plus a character that owns the deck. The arena tests run the published Linux exe: 100 Smart-vs-Smart duels with 0 errors, and --seed 7 giving the same report at --parallel 4 and 2. Co-Authored-By: Claude Opus 5.5 --- tests/YGOLegacy.Bots.Tests/ArenaTests.cs | 114 + tests/YGOLegacy.Bots.Tests/Fixture.cs | 78 + tests/YGOLegacy.Bots.Tests/HostTests.cs | 125 + .../YGOLegacy.Bots.Tests.csproj | 24 + tests/fixture/README.md | 17 + .../fixture-oldschool/character.json | 9 + .../game/Data/Windbot/Decks/AI_OldSchool.ydk | 44 + .../fixture/game/Data/locales/en-US/bot.conf | 280 ++ .../fixture/game/Data/locales/en-US/cards.cdb | Bin 0 -> 12288 bytes tests/fixture/game/Data/script.zip | Bin 0 -> 59783 bytes .../game/Expansions/script/procedure.lua | 3522 +++++++++++++++++ tests/fixture/make-fixture.py | 106 + 12 files changed, 4319 insertions(+) create mode 100644 tests/YGOLegacy.Bots.Tests/ArenaTests.cs create mode 100644 tests/YGOLegacy.Bots.Tests/Fixture.cs create mode 100644 tests/YGOLegacy.Bots.Tests/HostTests.cs create mode 100644 tests/YGOLegacy.Bots.Tests/YGOLegacy.Bots.Tests.csproj create mode 100644 tests/fixture/README.md create mode 100644 tests/fixture/game/Data/Characters/fixture-oldschool/character.json create mode 100644 tests/fixture/game/Data/Windbot/Decks/AI_OldSchool.ydk create mode 100644 tests/fixture/game/Data/locales/en-US/bot.conf create mode 100644 tests/fixture/game/Data/locales/en-US/cards.cdb create mode 100644 tests/fixture/game/Data/script.zip create mode 100644 tests/fixture/game/Expansions/script/procedure.lua create mode 100644 tests/fixture/make-fixture.py diff --git a/tests/YGOLegacy.Bots.Tests/ArenaTests.cs b/tests/YGOLegacy.Bots.Tests/ArenaTests.cs new file mode 100644 index 0000000..5d66981 --- /dev/null +++ b/tests/YGOLegacy.Bots.Tests/ArenaTests.cs @@ -0,0 +1,114 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.IO; +using System.Linq; +using Newtonsoft.Json.Linq; +using NUnit.Framework; + +namespace YGOLegacy.Bots.Tests +{ + /// The published Linux arena, end to end: `--host local` on the pinned engine, on tests/fixture/game. + [TestFixture, NonParallelizable] + public class ArenaTests + { + private const int Duels = 100; + private const int Seed = 7; + + // What differs between two runs of the same duels: clocks, the worker count and where the report went. + private static readonly HashSet Clocks = new() + { + "startedAt", "totalSeconds", "wallClockSeconds", "durationSeconds", "coreMs", "summary", "reportPath", + "workers", "outPath", + }; + + private static string Exe + { + get + { + var exe = Environment.GetEnvironmentVariable("BOTARENA_EXE"); + if (string.IsNullOrEmpty(exe)) Assert.Ignore("BOTARENA_EXE is not set (the Docker test stage sets it)"); + return exe; + } + } + + private static (int code, string stdout, string stderr) Run(string root, params string[] args) + { + var psi = new ProcessStartInfo(Exe) + { + RedirectStandardOutput = true, + RedirectStandardError = true, + UseShellExecute = false, + }; + psi.ArgumentList.Add("--root"); + psi.ArgumentList.Add(root); + foreach (var a in args) psi.ArgumentList.Add(a); + using var p = Process.Start(psi); + var stderr = p.StandardError.ReadToEndAsync(); + var stdout = p.StandardOutput.ReadToEnd(); + if (!p.WaitForExit(600_000)) { p.Kill(true); Assert.Fail("the arena did not finish in 10 minutes"); } + TestContext.Progress.WriteLine(stdout.Trim()); + return (p.ExitCode, stdout, stderr.Result); + } + + private static JObject Duel(string root, int n, int parallel, int seed, string outFile) + { + var (code, stdout, stderr) = Run(root, "--deckA", "AI_OldSchool", "--deckB", "AI_OldSchool", + "--n", n.ToString(), "--parallel", parallel.ToString(), "--seed", seed.ToString(), "--host", "local", + "--out", outFile); + Assert.That(code, Is.EqualTo(0), "exit code; stderr:\n" + stderr); + return JObject.Parse(File.ReadAllText(outFile)); + } + + private static JToken WithoutClocks(JToken token) + { + var copy = token.DeepClone(); + foreach (var p in copy.SelectTokens("$..*").OfType().Select(v => v.Parent).OfType().ToList()) + if (Clocks.Contains(p.Name)) p.Remove(); + return copy; + } + + [Test] + public void HundredDuelsOfABotDeckAgainstItselfHaveNoErrors() + { + var root = Fixture.CopyRoot(); + var report = Duel(root, Duels, 4, Seed, Path.Combine(root, "run-1.json")); + TestContext.Progress.WriteLine("winsA " + report["winsA"] + ", winsB " + report["winsB"] + ", draws " + report["draws"] + + ", errors " + report["errors"] + ", average turns " + report["averageTurns"]); + Assert.That((string)report["status"], Is.EqualTo("done")); + Assert.That((int)report["completed"], Is.EqualTo(Duels)); + Assert.That((int)report["errors"], Is.EqualTo(0), string.Join("\n", report["duels"].Where(d => d["error"]?.Type == JTokenType.String).Select(d => d["index"] + ": " + d["error"]))); + Assert.That((int)report["winsA"] + (int)report["winsB"] + (int)report["draws"], Is.EqualTo(Duels)); + Assert.That((string)report["nameA"], Is.EqualTo("Old School A"), "the deck's owning character names the seat"); + Assert.That((string)report["commandA"], Does.Contain("Deck=Smart"), "and its brain plays it"); + Assert.That(Directory.GetFiles(Path.Combine(root, "Data", "BotArena"), "*.json"), Has.Length.EqualTo(1), "the canonical report"); + } + + [Test] + public void TheSameSeedGivesTheSameReport() + { + var root = Fixture.CopyRoot(); + var first = Duel(root, Duels, 4, Seed, Path.Combine(root, "seed-1.json")); + var second = Duel(root, Duels, 2, Seed, Path.Combine(root, "seed-2.json")); + Assert.That((int)first["completed"], Is.EqualTo(Duels)); + var a = WithoutClocks(first); + var b = WithoutClocks(second); + Assert.That(JToken.DeepEquals(a, b), Is.True, "reports differ:\n" + a + "\n----\n" + b); + var other = WithoutClocks(Duel(root, Duels, 4, Seed + 1, Path.Combine(root, "seed-3.json"))); + Assert.That(JToken.DeepEquals(a["duels"], other["duels"]), Is.False, "another seed plays other duels"); + } + + [Test] + public void HelpAndBadArguments() + { + var root = Fixture.CopyRoot(); + Assert.That(Run(root, "--help").code, Is.EqualTo(0)); + Assert.That(Run(root, "--deckA", "AI_OldSchool").code, Is.EqualTo(2), "--deckB missing"); + Assert.That(Run(root, "--deckA", "AI_OldSchool", "--deckB", "AI_OldSchool", "--host", "wasm").code, Is.EqualTo(2)); + Assert.That(Run(root, "--deckA", "AI_OldSchool", "--deckB", "AI_OldSchool", "--host", "server").code, Is.EqualTo(2), "server is Windows only"); + var (code, stdout, _) = Run(root, "--deckA", "No Such Deck", "--deckB", "AI_OldSchool", "--n", "1"); + Assert.That(code, Is.EqualTo(1), "nothing played"); + Assert.That(stdout, Does.Contain("bad deck A")); + } + } +} diff --git a/tests/YGOLegacy.Bots.Tests/Fixture.cs b/tests/YGOLegacy.Bots.Tests/Fixture.cs new file mode 100644 index 0000000..2c98468 --- /dev/null +++ b/tests/YGOLegacy.Bots.Tests/Fixture.cs @@ -0,0 +1,78 @@ +using System; +using System.Collections.Generic; +using System.Data; +using System.IO; +using NUnit.Framework; +using YGOLegacy.Bots; + +namespace YGOLegacy.Bots.Tests +{ + /// tests/fixture/game, copied to a fresh folder per use: the arena writes Data/BotArena/ under its root. + internal static class Fixture + { + public static string Source + { + get + { + var dir = new DirectoryInfo(TestContext.CurrentContext.TestDirectory); + while (dir != null && !File.Exists(Path.Combine(dir.FullName, "engine.json"))) + dir = dir.Parent; + if (dir == null) throw new DirectoryNotFoundException("repo root (engine.json) not found above " + TestContext.CurrentContext.TestDirectory); + return Path.Combine(dir.FullName, "tests", "fixture", "game"); + } + } + + public static string CopyRoot() + { + var root = Path.Combine(Path.GetTempPath(), "ygol-bots-tests", Guid.NewGuid().ToString("N")); + Copy(Source, root); + return root; + } + + private static void Copy(string from, string to) + { + Directory.CreateDirectory(to); + foreach (var file in Directory.GetFiles(from)) + File.Copy(file, Path.Combine(to, Path.GetFileName(file))); + foreach (var dir in Directory.GetDirectories(from)) + Copy(dir, Path.Combine(to, Path.GetFileName(dir))); + } + } + + /// A host as the game would write one, in memory. + internal sealed class TestHost : IBotLog, ICardDatabase, IGameFiles, IDeckLimits, IBotConf + { + public readonly List Lines = new(); + public DeckCaps Caps = new(60, 99, 15); + public readonly List RulesetsAsked = new(); + public readonly List Bots = new(); + + public void Install() + { + BotHost.Log = this; + BotHost.Cards = this; + BotHost.Files = this; + BotHost.DeckLimits = this; + BotHost.BotConf = this; + } + + public void Info(string message) { lock (Lines) Lines.Add(message); } + public void Warning(string message) { lock (Lines) Lines.Add("[warn] " + message); } + public void Error(string message) { lock (Lines) Lines.Add("[error] " + message); } + + public IDbConnection Connect(string path) + => new Microsoft.Data.Sqlite.SqliteConnection("Data Source=" + path + ";Mode=ReadOnly"); + + public string Locale => "en-US"; + public IReadOnlyList ExpansionCardDatabases() => Array.Empty(); + + public DeckCaps For(string rulesetId) + { + RulesetsAsked.Add(rulesetId); + return Caps; + } + + public IReadOnlyList Entries() => Bots; + public void Reload() { } + } +} diff --git a/tests/YGOLegacy.Bots.Tests/HostTests.cs b/tests/YGOLegacy.Bots.Tests/HostTests.cs new file mode 100644 index 0000000..70fcc6b --- /dev/null +++ b/tests/YGOLegacy.Bots.Tests/HostTests.cs @@ -0,0 +1,125 @@ +using System.IO; +using NUnit.Framework; +using YGOLegacy.Characters; +using YGOLegacy.Services; + +namespace YGOLegacy.Bots.Tests +{ + /// The library reaches the game only through BotHost. These run in one process and share WindBot's statics, + /// so they run one at a time, from a copy of the fixture as the current directory (the game root). + [TestFixture, NonParallelizable] + public class HostTests + { + private string root; + private string cwd; + private TestHost host; + + [OneTimeSetUp] + public void Load() + { + cwd = Directory.GetCurrentDirectory(); + root = Fixture.CopyRoot(); + Directory.SetCurrentDirectory(root); + host = new TestHost(); + host.Install(); + WindBot.Program.InitDatas("cards.cdb"); + } + + [OneTimeTearDown] + public void Restore() => Directory.SetCurrentDirectory(cwd); + + [Test] + public void TheCardDatabaseLoadsThroughTheHost() + { + var card = YGOSharp.OCGWrapper.NamedCard.Get(11091375); + Assert.That(card, Is.Not.Null); + Assert.That(card.Name, Is.EqualTo("Luster Dragon")); + } + + [Test] + public void ADeckLoadsUnderTheHostsCaps() + { + host.Caps = new DeckCaps(60, 99, 15); + var deck = WindBot.Game.Deck.Load("AI_OldSchool"); + Assert.That(deck, Is.Not.Null); + Assert.That(deck.Cards.Count, Is.EqualTo(40)); + Assert.That(host.RulesetsAsked[^1], Is.Null, "the deck file has no #ruleset line"); + } + + [Test] + public void ADeckOverTheHostsMainCapIsRefused() + { + host.Caps = new DeckCaps(39, 99, 15); + try { Assert.That(WindBot.Game.Deck.Load("AI_OldSchool"), Is.Null); } + finally { host.Caps = new DeckCaps(60, 99, 15); } + } + + [Test] + public void TheRulesetLineIsPassedToTheHost() + { + var file = Path.Combine("Data", "Windbot", "Decks", "AI_Ruleset.ydk"); + File.WriteAllText(file, "#ruleset goat\n" + File.ReadAllText(Path.Combine("Data", "Windbot", "Decks", "AI_OldSchool.ydk"))); + Assert.That(WindBot.Game.Deck.Load("AI_Ruleset"), Is.Not.Null); + Assert.That(host.RulesetsAsked[^1], Is.EqualTo("goat")); + } + + [Test] + public void TheDeckDecidesTheBrain() + { + CharacterRegistry.LoadFromDisk(); + var bot = BotRoster.ForDeck("AI_OldSchool"); + Assert.That(bot.characterId, Is.EqualTo("fixture-oldschool")); + Assert.That(bot.windBotCommand, Is.EqualTo("Name=\"Old School\" Deck=Smart")); + } + + [Test] + public void ADeckNoCharacterOwnsGetsBotConfsDovphin() + { + CharacterRegistry.LoadFromDisk(); + host.Bots.Clear(); + host.Bots.Add(new BotConfEntry { name = "Dovphin", command = "Name=Dovphin Deck=Lucky Dialog=Ghoul.EN", desc = "", flags = new[] { "SELECT_DECKFILE" } }); + Assert.That(BotRoster.ForDeck("Nobody/Owns This").windBotCommand, Is.EqualTo("Name=Dovphin Deck=Lucky Dialog=Ghoul.EN")); + host.Bots.Clear(); + Assert.That(BotRoster.ForDeck("Nobody/Owns This").windBotCommand, Is.EqualTo("Name=Dovphin Deck=Lucky"), "no bot.conf: the built-in command"); + } + + [Test] + public void ABrokenCharacterIsLoggedThroughTheHost() + { + var dir = Path.Combine("Data", "Characters", "broken"); + Directory.CreateDirectory(dir); + File.WriteAllText(Path.Combine(dir, "character.json"), "{ not json"); + try + { + CharacterRegistry.LoadFromDisk(); + Assert.That(host.Lines, Has.Some.StartsWith("[error] [YGOL characters] Data/Characters/broken/character.json")); + Assert.That(CharacterRegistry.ById("fixture-oldschool"), Is.Not.Null, "a broken character never breaks the rest"); + } + finally { Directory.Delete(dir, true); } + } + + [Test] + public void TheGameCanScanOffThreadAndPublishLater() + { + var scan = CharacterRegistry.Scan(CharacterRegistry.Root); + Assert.That(scan.found, Has.Some.Matches(c => c.id == "fixture-oldschool")); + CharacterRegistry.Publish(scan); + Assert.That(CharacterRegistry.IsLoaded, Is.True); + Assert.That(CharacterRegistry.ForDeck("AI_OldSchool")?.id, Is.EqualTo("fixture-oldschool")); + } + } +} + +namespace YGOLegacy.Bots.Tests +{ + public class BuildTests + { + [Test] + public void TheLibraryNamesTheEngineReleaseItWasBuiltOn() + { + Assert.That(BotsBuild.Engine, Is.EqualTo(YGOLegacy.Engine.EngineBinding.Version), "engine.json's version is the binding it compiled against"); + var want = System.Environment.GetEnvironmentVariable("BOTS_VERSION"); + if (!string.IsNullOrEmpty(want)) Assert.That(BotsBuild.Version, Is.EqualTo(want)); + } + } +} diff --git a/tests/YGOLegacy.Bots.Tests/YGOLegacy.Bots.Tests.csproj b/tests/YGOLegacy.Bots.Tests/YGOLegacy.Bots.Tests.csproj new file mode 100644 index 0000000..7c3d443 --- /dev/null +++ b/tests/YGOLegacy.Bots.Tests/YGOLegacy.Bots.Tests.csproj @@ -0,0 +1,24 @@ + + + + + net8.0 + latest + false + $(NoWarn);CS0618 + + + + + + + + + + + $(EngineDir)YGOLegacy.Engine.dll + + + + diff --git a/tests/fixture/README.md b/tests/fixture/README.md new file mode 100644 index 0000000..aee4270 --- /dev/null +++ b/tests/fixture/README.md @@ -0,0 +1,17 @@ +# tests/fixture + +`game/` is the smallest game root the tests duel on: one deck (`Data/Windbot/Decks/AI_OldSchool.ydk`), its 17 +cards in `Data/locales/en-US/cards.cdb`, their scripts and the system scripts in `Data/script.zip`, the loose +`Expansions/script/procedure.lua` override, the en-US `bot.conf`, and one character that owns the deck +(`Data/Characters/fixture-oldschool`, Smart brain). + +Built by `make-fixture.py` from: + +- the Unity repo's `Data/locales/en-US/{cards.cdb,bot.conf}`, `Data/script.zip` and + `Data/Windbot/Decks/AI_OldSchool.ydk` at `dev` `19c6158197a0a8f0817dd0924bb9a6a987c2bfc5`; +- `Expansions/script/procedure.lua` of the local v2 game copy (`/mnt/nvme/yugioh-legacy-v2-local/game`, never the + live share). + +```bash +python3 -I tests/fixture/make-fixture.py tests/fixture/game +``` diff --git a/tests/fixture/game/Data/Characters/fixture-oldschool/character.json b/tests/fixture/game/Data/Characters/fixture-oldschool/character.json new file mode 100644 index 0000000..f2aa104 --- /dev/null +++ b/tests/fixture/game/Data/Characters/fixture-oldschool/character.json @@ -0,0 +1,9 @@ +{ + "_comment": "Test fixture: owns AI_OldSchool so its seats play the Smart brain.", + "id": "fixture-oldschool", + "name": "Old School", + "decks": [ + { "path": "AI_OldSchool", "brain": { "executor": "Smart", "difficulty": "hard", "knobs": { "aggression": 0.5 } } } + ], + "brain": { "executor": "Lucky", "difficulty": "normal", "knobs": {} } +} diff --git a/tests/fixture/game/Data/Windbot/Decks/AI_OldSchool.ydk b/tests/fixture/game/Data/Windbot/Decks/AI_OldSchool.ydk new file mode 100644 index 0000000..91a5ea8 --- /dev/null +++ b/tests/fixture/game/Data/Windbot/Decks/AI_OldSchool.ydk @@ -0,0 +1,44 @@ +#created by ... +#main +6631034 +6631034 +6631034 +43096270 +43096270 +43096270 +69247929 +69247929 +69247929 +77542832 +77542832 +77542832 +11091375 +11091375 +11091375 +35052053 +35052053 +35052053 +49881766 +83104731 +83104731 +30190809 +30190809 +26412047 +26412047 +26412047 +43422537 +43422537 +43422537 +53129443 +66788016 +66788016 +66788016 +72302403 +72302403 +44095762 +44095762 +44095762 +70342110 +70342110 +#extra +!side diff --git a/tests/fixture/game/Data/locales/en-US/bot.conf b/tests/fixture/game/Data/locales/en-US/bot.conf new file mode 100644 index 0000000..f573567 --- /dev/null +++ b/tests/fixture/game/Data/locales/en-US/bot.conf @@ -0,0 +1,280 @@ +#bots list +# !name +# command +# description +# flags (avail flags: SUPPORT_MASTER_RULE_3, SUPPORT_NEW_MASTER_RULE, SUPPORT_MASTER_RULE_2020, SELECT_DECKFILE) + +!Random Draft - Very Easy +Random=AI_LV1 +for Beginners +SUPPORT_MASTER_RULE_2020 + +!Random Draft - Easy +Random=AI_LV2 +for Free Players +SUPPORT_MASTER_RULE_2020 + +!Random Draft - Normal +Random=AI_LV3 +for Challengers +SUPPORT_MASTER_RULE_2020 + +!Random Draft - Classic +Random=AI_LV4 +for hardcore Players +SUPPORT_MASTER_RULE_2020 + +!Random Draft - Wild +Random=AI_WILD +CHECK THIS OUT! +SUPPORT_MASTER_RULE_2020 + +!Random Draft - Anti-Meta +Random=AI_ANTI_META +for Champions +SUPPORT_MASTER_RULE_2020 + +!Dovphin - Use your Deck +Name=Dovphin Deck=Lucky Dialog=Ghoul.EN +Select your Deck to let the Bot use it. The bot won't play it well. +SELECT_DECKFILE SUPPORT_MASTER_RULE_3 SUPPORT_NEW_MASTER_RULE SUPPORT_MASTER_RULE_2020 + +!Mokey Mokey +Name='Mokey Mokey' Deck='MokeyMokey' Dialog=Mokey.EN +Tiny fluffball, huge heart—feel the Mokey power! +AI_LV1 SUPPORT_MASTER_RULE_3 SUPPORT_NEW_MASTER_RULE SUPPORT_MASTER_RULE_2020 + +!Mokey Mokey King +Name='Mokey Mokey King' Deck='MokeyMokeyKing' Dialog=Mokey.EN +Bow before the fluffball king! +AI_LV1 SUPPORT_MASTER_RULE_3 SUPPORT_NEW_MASTER_RULE SUPPORT_MASTER_RULE_2020 + +!Swordsman-Dragunity +Name='Stardust Dragon/Assault Mode' Deck=Dragunity Dialog=Swordsman.EN +Soar with Dragunity lances and Stardust Assault! +AI_LV2 SUPPORT_MASTER_RULE_3 SUPPORT_NEW_MASTER_RULE SUPPORT_MASTER_RULE_2020 + +!Swordsman-LV8 +Name='Red Dragon Archfiend' Deck='Level VIII' Dialog=Swordsman.EN +Level-up your blade—Synchro into Level 8 supremacy! +AI_LV2 SUPPORT_MASTER_RULE_3 SUPPORT_NEW_MASTER_RULE SUPPORT_MASTER_RULE_2020 + +!Swordsman-RANK5 +Name='Constellar Pleiades' Deck='Rank V' Dialog=Swordsman.EN +Forge mighty Rank 5 Xyz blades! +AI_LV2 SUPPORT_MASTER_RULE_3 SUPPORT_MASTER_RULE_2020 + +!Swordsman-Zexal Weapons +Name='Number S39: Utopia the Lightning' Deck='Zexal Weapons' Dialog=Swordsman.EN +Unleash Utopia’s arsenal—ZW Lightning strikes! +AI_LV2 SUPPORT_MASTER_RULE_3 SUPPORT_MASTER_RULE_2020 + +!Rainbow +Name='Rabidragon' Deck='Rainbow' Dialog=Cirno.EN +A dazzling spectrum of Normal monsters! +AI_LV2 SUPPORT_MASTER_RULE_3 SUPPORT_MASTER_RULE_2020 + +!Toadally Awesome +Name='Toadally Awesome' Deck='Toadally Awesome' Dialog=Cirno.EN +Croak and conquer—the pond belongs to you! +AI_LV3 SUPPORT_MASTER_RULE_3 SUPPORT_MASTER_RULE_2020 + +!Blue-Eyes +Name='Blue-Eyes White Dragon' Deck='Blue-Eyes' Dialog=Universal.EN +Unleash the white lightning of legend! +AI_LV3 SUPPORT_MASTER_RULE_3 SUPPORT_MASTER_RULE_2020 + +!Invoked Zoodiac Kaiju +Name='Invoked Mechaba' Deck='Zoodiac' Dialog=Universal.EN +Fuse, barrage and kaiju-slam your way to victory! +AI_LV4 SUPPORT_MASTER_RULE_3 SUPPORT_MASTER_RULE_2020 + +!Yosenju +Name='Yosenju Misak' Deck='Yosenju' Dialog=Universal_2.EN +Swift strikes from wandering wind-beasts! +AI_ANTI_META SUPPORT_MASTER_RULE_3 SUPPORT_NEW_MASTER_RULE SUPPORT_MASTER_RULE_2020 + +!Qliphort +Name='Apoqliphort Towers' Deck='Qliphort' Dialog=Universal_2.EN +Summon the towering Qliphort colossus! +AI_ANTI_META SUPPORT_MASTER_RULE_3 SUPPORT_NEW_MASTER_RULE SUPPORT_MASTER_RULE_2020 + +!Trickstar +Name='Trickstar Holly Angel' Deck='Trickstar' Dialog=Universal_2.EN +Sweet smiles, cruel burn—Trickstar tempo! +AI_LV4 SUPPORT_NEW_MASTER_RULE SUPPORT_MASTER_RULE_2020 + +!Altergeist +Name='Altergeist Multifaker' Deck='Altergeist' Dialog=Universal_2.EN +Warp reality with Altergeist traps! +AI_LV4 SUPPORT_NEW_MASTER_RULE SUPPORT_MASTER_RULE_2020 + +!Labrynth +Name='Lady Labrynth of the Silver Castle' Deck='Labrynth' Dialog=Universal_2.EN +Enter the Labrynth and unleash fiendish furniture! +AI_LV4 SUPPORT_NEW_MASTER_RULE SUPPORT_MASTER_RULE_2020 + +!Yubel +Name='Spirit of Yubel' Deck='Yubel' Dialog=Universal_3.EN +A Fiend Link build that pairs Unchained—later adding Fiendsmith—with Yubel pieces to pop your own cards for value, loop floaters, and churn Link material for steady disruption and pressure. +AI_LV4 SUPPORT_MASTER_RULE_2020 + +!OCG Maliss +Name='OCG Maliss' Deck=MalissOCG Dialog=Universal_3.EN +Full-power Maliss deck (OCG). +AI_LV4 SUPPORT_MASTER_RULE_2020 + +!MD Maliss +Name='MD Maliss' Deck=Maliss Dialog=Universal_3.EN +Full-power Maliss deck (MD). +AI_LV4 SUPPORT_MASTER_RULE_2020 + +!Sky Striker Ace +Name='Sky Striker Ace - Raye' Deck='SkyStriker' Dialog=Universal_3.EN +Sky-strike with surgical spell supremacy! +AI_LV3 SUPPORT_NEW_MASTER_RULE SUPPORT_MASTER_RULE_2020 + +!Orcust +Name='Galatea, the Orcust Automaton' Deck='Orcust' Dialog=Universal_3.EN +Let the Orcust orchestra resound! +AI_LV3 SUPPORT_NEW_MASTER_RULE SUPPORT_MASTER_RULE_2020 + +!Salamangreat +Name='Salamangreat Heatleo' Deck='Salamangreat' Dialog=Universal_3.EN +Reincarnate and roar with Salamangreat flames! +AI_LV3 SUPPORT_NEW_MASTER_RULE SUPPORT_MASTER_RULE_2020 + +!Ryzeal +Name='Ryzeal' Deck='Ryzeal' Dialog=Universal_3.EN +Face the swirling chaos of Ryzeal! +AI_LV4 SUPPORT_MASTER_RULE_3 SUPPORT_MASTER_RULE_2020 + +!Familiar-Possesed +Name='Eria the Water Charmer' Deck='FamiliarPossessed' Dialog=VI-1911.EN +Summon elemental familiars for overwhelming force! +AI_ANTI_META SUPPORT_MASTER_RULE_3 SUPPORT_NEW_MASTER_RULE SUPPORT_MASTER_RULE_2020 + +!Time Thief +Name='Time Thief Redoer' Deck='TimeThief' Dialog=VI-1911.EN +Steal turns and fates with Time-Thief tricks! +AI_LV2 SUPPORT_MASTER_RULE_3 SUPPORT_NEW_MASTER_RULE SUPPORT_MASTER_RULE_2020 + +!Burn Burn +Name='Lava Golem' Deck='Burn' Dialog=Universal_4.EN +Scorch foes with relentless burn! +AI_LV1 SUPPORT_MASTER_RULE_3 SUPPORT_NEW_MASTER_RULE SUPPORT_MASTER_RULE_2020 + +!Des Frogs +Name='D.3.S. Frog' Deck='Frog' Dialog=Universal_4.EN +Leap to battle with poisonous frogs! +AI_LV1 SUPPORT_MASTER_RULE_3 SUPPORT_NEW_MASTER_RULE SUPPORT_MASTER_RULE_2020 + +!Horus' Servant +Name='Horus the Black Flame Dragon LV8' Deck='Horus' Dialog=Universal_4.EN +Command dragons with Horus’ searing gaze! +AI_LV1 SUPPORT_MASTER_RULE_3 SUPPORT_NEW_MASTER_RULE SUPPORT_MASTER_RULE_2020 + +!Bitron-Windy +Name='Bitron' Deck='PureWinds' Dialog=Universal_5.EN +Whirl cyber winds at your command! +AI_LV2 SUPPORT_MASTER_RULE_3 SUPPORT_NEW_MASTER_RULE SUPPORT_MASTER_RULE_2020 + +!TestBot1732-Cyberse +Name='Firewall Dragon' Deck='ST1732' Dialog=Universal_5.EN +Prototype cyber arsenal ready for battle! +AI_LV1 SUPPORT_NEW_MASTER_RULE SUPPORT_MASTER_RULE_2020 + +!El Shaddoll +Name='El Shaddoll Construct' Deck='LightswornShaddoldinosour' Dialog=Universal_6.EN +Blend Lightsworn, shadows and dinos for a primal blast! +AI_LV3 SUPPORT_MASTER_RULE_3 SUPPORT_NEW_MASTER_RULE SUPPORT_MASTER_RULE_2020 + +!Dark Magician +Name='Dark Magician' Deck='DarkMagician' Dialog=Universal_6.EN +Channel the arcane might of the ultimate wizard! +AI_LV3 SUPPORT_MASTER_RULE_3 SUPPORT_NEW_MASTER_RULE SUPPORT_MASTER_RULE_2020 + +!Chaos-MAX +Name='Blue-Eyes Chaos MAX Dragon' Deck='BlueEyesMaxDragon' Dialog=Universal_6.EN +Summon the relentless Blue-Eyes Chaos MAX! +AI_LV3 SUPPORT_MASTER_RULE_3 SUPPORT_NEW_MASTER_RULE SUPPORT_MASTER_RULE_2020 + +!The Ghost +Name='Phantasm Spiral Dragon' Deck='Phantasm' Dialog=Universal_6.EN +Spectral phantasms haunt every step! +AI_ANTI_META SUPPORT_MASTER_RULE_3 SUPPORT_NEW_MASTER_RULE SUPPORT_MASTER_RULE_2020 + +!Burning Fighter +Name='Michion, the Time Lord' Deck='ChainBurn' Dialog=Universal_6.EN +Timeless justice through chain burn! +AI_ANTI_META SUPPORT_MASTER_RULE_3 SUPPORT_NEW_MASTER_RULE SUPPORT_MASTER_RULE_2020 + +!Meta Beater +Name='Gren Maju Da Eiza' Deck='GrenMajuThunderBoarder' Dialog=Universal_6.EN +Feed banished power into Gren Maju’s thunder! +AI_ANTI_META SUPPORT_MASTER_RULE_3 SUPPORT_NEW_MASTER_RULE SUPPORT_MASTER_RULE_2020 + +!Joey Wheeler - Red-Eyes Dark Dragoon +Name='Red-Eyes Dark Dragoon' Deck='Dragun' Dialog=Smart.EN +Red-Eyes fuses into Dragoon devastation! +AI_LV4 SUPPORT_MASTER_RULE_3 SUPPORT_NEW_MASTER_RULE SUPPORT_MASTER_RULE_2020 + +!Fiber Auroradon Brave Phenix +Name='Baronne de Fleur' Deck='Brave' Dialog=Smart.EN +Chaos combo with Halqifibrax, tokens and Brave! +AI_LV4 SUPPORT_MASTER_RULE_2020 + +!Madame Verre - WitchCraft +Name='Madame Verre' Deck='Witchcraft' Dialog=MadameVerre.EN +Bewitching Witchcraft weaves the win! +AI_LV4 SUPPORT_MASTER_RULE_3 SUPPORT_NEW_MASTER_RULE SUPPORT_MASTER_RULE_2020 + +!Exosister Mikailis +Name='Exosister Mikailis' Deck='Exosister' Dialog=MadameVerre.EN +Holy sisters banish from the grave! +AI_LV4 SUPPORT_MASTER_RULE_3 SUPPORT_MASTER_RULE_2020 + +!Ecclesia-Swordsoul +Name='Swordsoul Grandmaster - Chixiao' Deck='Swordsoul' Dialog=Ecclesia.EN +Strike true with radiant Swordsoul! +AI_LV4 SUPPORT_MASTER_RULE_3 SUPPORT_MASTER_RULE_2020 + +!Ecclesia-Dogmatika +Name='Dogmatika Fleurdelis, the Knighted' Deck='Dogmatika' Dialog=Ecclesia.EN +Dogmatika doctrine stands unbroken! +AI_LV4 SUPPORT_MASTER_RULE_3 SUPPORT_NEW_MASTER_RULE SUPPORT_MASTER_RULE_2020 + +!Ecclesia-Albaz +Name='Mirrorjade the Iceblade Dragon' Deck='Albaz' Dialog=Ecclesia.EN +Albaz forges fusions in flames and frost! +AI_LV4 SUPPORT_MASTER_RULE_3 SUPPORT_MASTER_RULE_2020 + +!Kashtira +Name='Kashtira Arise-Heart' Deck='Kashtira' Dialog=Universal_7.EN +Rise with Arise-Heart and lock the field! +AI_LV4 SUPPORT_MASTER_RULE_2020 + +!Thunder Dragon +Name='Thunder Dragon Colossus' Deck='ThunderDragon' Dialog=Universal_7.EN +Thunder roars with Bystial surge! +AI_WILD SUPPORT_MASTER_RULE_2020 + +!Tearlaments +Name='Tearlaments Rulkallos' Deck='Tearlaments' Dialog=Universal_7.EN +Merge tears into unstoppable depths! +AI_LV4 AI_WILD SUPPORT_MASTER_RULE_2020 + +!Zefra +Name='Zefraath' Deck='Zefra' Dialog=Universal_7.EN +Synchronise constellations with Zefra harmony! +AI_LV4 SUPPORT_MASTER_RULE_2020 + +!Superheavy Samurai +Name='Midnight Snack' Deck='SuperheavySamurai' Dialog=SuperheavySamurai.EN +Massive defence becomes offence! +AI_LV4 SUPPORT_MASTER_RULE_2020 + +!Apophis +Name='Apophis' Deck=Apophis Dialog=Universal_3.EN +Temple of the Kings Deck. +AI_LV4 SUPPORT_MASTER_RULE_2020 \ No newline at end of file diff --git a/tests/fixture/game/Data/locales/en-US/cards.cdb b/tests/fixture/game/Data/locales/en-US/cards.cdb new file mode 100644 index 0000000000000000000000000000000000000000..9a22d342eda8db0357899110bae4038809324971 GIT binary patch literal 12288 zcmeHN%a0sK8Si=6JGQek*@(#=I8ZhM+tRr0i7`%`gT3~y?Un7=$!@SBL{M#a%}jZ_ zyPB%%9Z!USStsJ52yrmtaR3DjL2x2~2!az*;DSWNEszTm7evHAz(f4L>Ur#rF@z&h zx4bho)%E!5_x*m~S6%J3r>{yYSV!rYTXxcW*ejL1bBuYOSH)iif8&eFR5!j#jB#ogO;-6>K2bAHRS#NE!ehaxMJp60$VqAw5QXwr}MO@6Sb!^wezWt(zE$OW!-Bm*DufiX#V&^TL-?rU+-`1d$IOT z?R&LDbC>r1Y|p8xM3dqw5GW9M7YJ-OUVZb`k2bybosZ4WTuVtHMPk_{!8N<2A`xHU zNrHH|A=p|f0?8w`mc_A3MCh~C4zoRJSip72xV1dkG%YqznPw_Y(FP+0d4C>QxrNxq zcru`oqUiX#<|(^?u7+ial@Z1gOe7&wG^}9DJmy_YYeo9+r(&Efi;hT)U^kSJR;q-- zGK5FnLj3GRGO#R_LI*PGvJDs*2?TyOs#Uw~^oJMk{rxW|n%=4HOEZ|vuWZT4^tq1N zWf4hbwMvCQfW;hngR>Z4A=6UyEEAhNhVfk)vjP3K93RTCL8vy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T$OpXMLLL?+^W#@`;Y9sw-^6i Pzg)*b#g36`mFm9$BPK*6 literal 0 HcmV?d00001 diff --git a/tests/fixture/game/Data/script.zip b/tests/fixture/game/Data/script.zip new file mode 100644 index 0000000000000000000000000000000000000000..50fa717c0f7a9b662cb796994fffbb401f6ebefa GIT binary patch literal 59783 zcmV(~K+nHWO9KQH000080000XT=k;UrU4rO0RKk-01f~E0CQtfEeOi4pUPE$pl zTv>D5Mz(%u75_t*UMyA7O6*zgBub@Ka5~Yxo9lZ@mHbsmgK_`PJU(6C4X+IT8;mA{Zs)+`^yjlJU0USk zW6%7v&aL_I(@!6|9Xx(jY_?_kvZ~DK)fqni$4@=}(%h8Rnn|&&-jdRqo1)GaNrfeP zW|+^{hu4dxsaAM3 zOXoIs)+~y7y|y_hzzb%+O7fR9e=%uA>*qyfk}NCU?Bbjc{hdFLrA^ke%*u1qmGxUV zvn)!p#*vKkT%rFK)}=4G&|W29@!?ytHQS;tyPYMNvMAQ{m0R%(I2RL#b64laTyAls zyebn1$}4QfqP4j#lgvEUGwj{%-02x{k~FVuzL3pc>IB@cASK$&d~YxMuG{fszkiQs z)X%PJ}(^VLmHZ1}dGY9hB#sn300@ZR(6CF4=4{h=#Uj9bZPD9N{`z)Pjsl*LP#tj*i1prz|-Rg?~#T0>3nWVcg0kuIn@ofK=U?;X?G*7@cI z)Cnw{ZMz-M@;mErNOR5>*VZ>d|I^}=R2&fKQ2v`SshY3&8%Q!?9L zEDRFI@^32E`F)s-B6K7PfXf2PGTx zvqvjkZgG!5U9*9%&Rh5AsA zK#5yHIq=Zhs|Df^xg}m!R0sb`aiSn1wrYDwVPFP`eAOGITiK2K*_?hj<6tJywatC# zXt#6v@eFK)>8r*>;p}adg15ve$6sdl1%}UY(s3NuK-p`_8ms=mF^UBm@2HgbGY3wQ zP;5f7W5)_ltjD2+$$D@o(SNp2um7rj*IG#dh9B^=YmYc(dGpfC@Ds5c~3rJ zI}|}8!{uHC;sd1YqVf6K(l$185-2taTs3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nBk--rn!xGY2!%TZM<2>34h%j_;A%VMGd&^2B!aDEAf*9mS>2KF978&E*erSeheT3oBjRBZc2&FbyQ+}}1GBWVODL4Sm+qlfQz(HiO%HtVx z^UsIf#QevzaS^<}n#pBw9?899-dxv`Xsc(Gci6yEO`Hg^MMSoW0oHBR#-oly$XmGnYX`GPaFttYz zYcPnc;;P`MH_OxRW2cxvUEu+gQ3YnQR-RL=`85VK%8dbmbE(%B=Gd8irhQ~=)XdK= zPG*6a{~p5Gzs_V{z`9eM6PeWm^dPz&JEEceh28$QWr0D^K!2B8-XbRuvG#S|ToEuX z5YVeQ5D>!KC;xZ(z1bTG$kE8b;*%4DjHIxroU-WqwN@v|i%kMRKxN(kDf0ea@%!=v zrh6m)?^+`}TSq4YTc_Vn@*aRWsxa)y1q7t11N=_~=s(MU1JJeq3;5(|pZ$ z5#D$A`$OnW{x9LLUVra@!TUP(pYminc then minc=min end + if maxmaxc then return false end + end + if smat and smat:IsTuner(c) and (not f1 or f1(smat)) then + return Duel.CheckTunerMaterial(c,smat,f1,f2,minc,maxc,mg) end + return Duel.CheckSynchroMaterial(c,f1,f2,minc,maxc,smat,mg) + end +end +function Auxiliary.SynTarget(f1,f2,minct,maxct) + return function(e,tp,eg,ep,ev,re,r,rp,chk,c,smat,mg,min,max) + local minc=minct + local maxc=maxct + if min then + if min>minc then minc=min end + if maxmaxc then return false end + end + local g=nil + if smat and smat:IsTuner(c) and (not f1 or f1(smat)) then + g=Duel.SelectTunerMaterial(c:GetControler(),c,smat,f1,f2,minc,maxc,mg) + else + g=Duel.SelectSynchroMaterial(c:GetControler(),c,f1,f2,minc,maxc,smat,mg) + end + if g then + g:KeepAlive() + e:SetLabelObject(g) + return true + else return false end + end +end +function Auxiliary.SynOperation(f1,f2,minct,maxct) + return function(e,tp,eg,ep,ev,re,r,rp,c,smat,mg,min,max) + local g=e:GetLabelObject() + c:SetMaterial(g) + Duel.SendtoGrave(g,REASON_MATERIAL+REASON_SYNCHRO) + g:DeleteGroup() + end +end +--Synchro monster, 1 tuner + 1 monster +--backward compatibility +function Auxiliary.AddSynchroProcedure2(c,f1,f2) + Auxiliary.AddSynchroProcedure(c,f1,f2,1,1) +end +---Synchro monster, f1~f3 each 1 MONSTER + f4 min to max monsters +---@param c Card +---@param f1 function|nil +---@param f2 function|nil +---@param f3 function|nil +---@param f4 function|nil +---@param minc integer +---@param maxc integer +---@param gc? function +function Auxiliary.AddSynchroMixProcedure(c,f1,f2,f3,f4,minc,maxc,gc) + local maxct=maxc + if maxct>c:GetLevel() then + maxct=c:GetLevel() + if f1 then maxct=maxct-1 end + if f2 then maxct=maxct-1 end + if f3 then maxct=maxct-1 end + end + local e1=Effect.CreateEffect(c) + e1:SetDescription(1164) + e1:SetType(EFFECT_TYPE_FIELD) + e1:SetCode(EFFECT_SPSUMMON_PROC) + e1:SetProperty(EFFECT_FLAG_CANNOT_DISABLE+EFFECT_FLAG_UNCOPYABLE) + e1:SetRange(LOCATION_EXTRA) + e1:SetCondition(Auxiliary.SynMixCondition(f1,f2,f3,f4,minc,maxct,gc)) + e1:SetTarget(Auxiliary.SynMixTarget(f1,f2,f3,f4,minc,maxct,gc)) + e1:SetOperation(Auxiliary.SynMixOperation(f1,f2,f3,f4,minc,maxct,gc)) + e1:SetValue(SUMMON_TYPE_SYNCHRO) + c:RegisterEffect(e1) +end +function Auxiliary.SynMaterialFilter(c,syncard) + return c:IsFaceupEx() and c:IsCanBeSynchroMaterial(syncard) +end +function Auxiliary.SynLimitFilter(c,f,e,syncard) + return f and not f(e,c,syncard) +end +function Auxiliary.GetSynchroLevelFlowerCardian(c) + return 2 +end +function Auxiliary.GetMinSynchroLevel(c,syncard) + local lv=c:GetSynchroLevel(syncard) + local minlv=c:GetLevel() + while lv&MAX_PARAMETER>0 do + minlv=math.min(minlv,lv&MAX_PARAMETER) + lv=lv>>16 + end + return minlv +end +function Auxiliary.GetSynMaterials(tp,syncard) + local mg=Duel.GetSynchroMaterial(tp):Filter(Auxiliary.SynMaterialFilter,nil,syncard) + if mg:IsExists(Card.GetHandSynchro,1,nil) then + local mg2=Duel.GetMatchingGroup(Card.IsCanBeSynchroMaterial,tp,LOCATION_HAND,0,nil,syncard) + if mg2:GetCount()>0 then mg:Merge(mg2) end + end + return mg +end +function Auxiliary.SynMixCondition(f1,f2,f3,f4,minct,maxct,gc) + return function(e,c,smat,mg1,min,max) + if c==nil then return true end + if c:IsType(TYPE_PENDULUM) and c:IsFaceup() then return false end + local minc=minct + local maxc=maxct + if min then + local exct=0 + if f2 then exct=exct+1 end + if f3 then exct=exct+1 end + if min-exct>minc then minc=min-exct end + if max-exctmaxc then return false end + end + local tp=c:GetControler() + if Duel.IsPlayerAffectedByEffect(tp,8173184) then + Duel.RegisterFlagEffect(tp,8173184+1,0,0,1) + end + if smat and not smat:IsCanBeSynchroMaterial(c) then + Duel.ResetFlagEffect(tp,8173184+1) + return false + end + local mg + local mgchk=false + local goalchk=false + if mg1 then + mg=mg1:Filter(Card.IsCanBeSynchroMaterial,nil,c) + mgchk=true + if min and min==max and #mg==#mg1 and #mg==min+1 then + goalchk=Auxiliary.SynMixCheckGoal(tp,mg,0,0,c,Group.CreateGroup(),smat,gc,mgchk,goalchk) + if not goalchk then + Duel.ResetFlagEffect(tp,8173184+1) + return false + end + end + else + mg=Auxiliary.GetSynMaterials(tp,c) + end + if smat~=nil then mg:AddCard(smat) end + local res=mg:IsExists(Auxiliary.SynMixFilter1,1,nil,f1,f2,f3,f4,minc,maxc,c,mg,smat,gc,mgchk,goalchk) + Duel.ResetFlagEffect(tp,8173184+1) + return res + end +end +function Auxiliary.SynMixTarget(f1,f2,f3,f4,minct,maxct,gc) + return function(e,tp,eg,ep,ev,re,r,rp,chk,c,smat,mg1,min,max) + local minc=minct + local maxc=maxct + if min then + local exct=0 + if f2 then exct=exct+1 end + if f3 then exct=exct+1 end + if min-exct>minc then minc=min-exct end + if max-exctmaxc then return false end + end + ::SynMixTargetSelectStart:: + if Duel.IsPlayerAffectedByEffect(tp,8173184) then + Duel.RegisterFlagEffect(tp,8173184+1,0,0,1) + end + local cancel=Duel.IsSummonCancelable() + local g=Group.CreateGroup() + local mg + local mgchk=false + local goalchk=false + if mg1 then + mg=mg1:Filter(Card.IsCanBeSynchroMaterial,nil,c) + mgchk=true + if min and min==max and #mg==#mg1 and #mg==min+1 and not cancel then + g:Merge(mg) + g:KeepAlive() + e:SetLabelObject(g) + Duel.ResetFlagEffect(tp,8173184+1) + return true + end + else + mg=Auxiliary.GetSynMaterials(tp,c) + end + if smat~=nil then mg:AddCard(smat) end + local c1 + local c2 + local c3 + local g4=Group.CreateGroup() + Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_SMATERIAL) + c1=mg:Filter(Auxiliary.SynMixFilter1,nil,f1,f2,f3,f4,minc,maxc,c,mg,smat,gc,mgchk,goalchk):SelectUnselect(g,tp,false,cancel,1,1) + if not c1 then goto SynMixTargetSelectCancel end + g:AddCard(c1) + if f2 then + Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_SMATERIAL) + c2=mg:Filter(Auxiliary.SynMixFilter2,g,f2,f3,f4,minc,maxc,c,mg,smat,c1,gc,mgchk,goalchk):SelectUnselect(g,tp,false,cancel,1,1) + if not c2 then goto SynMixTargetSelectCancel end + if g:IsContains(c2) then goto SynMixTargetSelectStart end + g:AddCard(c2) + if f3 then + Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_SMATERIAL) + c3=mg:Filter(Auxiliary.SynMixFilter3,g,f3,f4,minc,maxc,c,mg,smat,c1,c2,gc,mgchk,goalchk):SelectUnselect(g,tp,false,cancel,1,1) + if not c3 then goto SynMixTargetSelectCancel end + if g:IsContains(c3) then goto SynMixTargetSelectStart end + g:AddCard(c3) + end + end + for i=0,maxc-1 do + local mg2=mg:Clone() + if f4 then + mg2=mg2:Filter(f4,g,c,c1,c2,c3) + else + mg2:Sub(g) + end + local fulltraversal=mg:IsExists(Card.IsHasEffect,1,nil,89818984) + local cg=mg2:Filter(Auxiliary.SynMixCheckRecursive,g4,tp,g4,mg2,i,minc,maxc,c,g,smat,gc,mgchk,goalchk,fulltraversal) + if cg:GetCount()==0 then break end + local finish=Auxiliary.SynMixCheckGoal(tp,g4,minc,i,c,g,smat,gc,mgchk,goalchk) + Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_SMATERIAL) + local c4=cg:SelectUnselect(g+g4,tp,finish,cancel,minc,maxc) + if not c4 then + if finish then break + else goto SynMixTargetSelectCancel end + end + if g:IsContains(c4) or g4:IsContains(c4) then goto SynMixTargetSelectStart end + g4:AddCard(c4) + end + g:Merge(g4) + if g:GetCount()>0 then + g:KeepAlive() + e:SetLabelObject(g) + Duel.ResetFlagEffect(tp,8173184+1) + return true + end + ::SynMixTargetSelectCancel:: + Duel.ResetFlagEffect(tp,8173184+1) + return false + end +end +function Auxiliary.SynMixOperation(f1,f2,f3,f4,minct,maxct,gc) + return function(e,tp,eg,ep,ev,re,r,rp,c,smat,mg,min,max) + local g=e:GetLabelObject() + c:SetMaterial(g) + Duel.SendtoGrave(g,REASON_MATERIAL+REASON_SYNCHRO) + g:DeleteGroup() + end +end +function Auxiliary.SynMixFilter1(c,f1,f2,f3,f4,minc,maxc,syncard,mg,smat,gc,mgchk,goalchk) + return (not f1 or f1(c,syncard)) and mg:IsExists(Auxiliary.SynMixFilter2,1,c,f2,f3,f4,minc,maxc,syncard,mg,smat,c,gc,mgchk,goalchk) +end +function Auxiliary.SynMixFilter2(c,f2,f3,f4,minc,maxc,syncard,mg,smat,c1,gc,mgchk,goalchk) + if f2 then + return f2(c,syncard,c1) + and (mg:IsExists(Auxiliary.SynMixFilter3,1,Group.FromCards(c1,c),f3,f4,minc,maxc,syncard,mg,smat,c1,c,gc,mgchk,goalchk) + or minc==0 and Auxiliary.SynMixFilter4(c,nil,1,1,syncard,mg,smat,c1,nil,nil,gc,mgchk,goalchk)) + else + return mg:IsExists(Auxiliary.SynMixFilter4,1,c1,f4,minc,maxc,syncard,mg,smat,c1,nil,nil,gc,mgchk,goalchk) + end +end +function Auxiliary.SynMixFilter3(c,f3,f4,minc,maxc,syncard,mg,smat,c1,c2,gc,mgchk,goalchk) + if f3 then + return f3(c,syncard,c1,c2) + and (mg:IsExists(Auxiliary.SynMixFilter4,1,Group.FromCards(c1,c2,c),f4,minc,maxc,syncard,mg,smat,c1,c2,c,gc,mgchk,goalchk) + or minc==0 and Auxiliary.SynMixFilter4(c,nil,1,1,syncard,mg,smat,c1,c2,nil,gc,mgchk,goalchk)) + else + return mg:IsExists(Auxiliary.SynMixFilter4,1,Group.FromCards(c1,c2),f4,minc,maxc,syncard,mg,smat,c1,c2,nil,gc,mgchk,goalchk) + end +end +function Auxiliary.SynMixFilter4(c,f4,minc,maxc,syncard,mg1,smat,c1,c2,c3,gc,mgchk,goalchk) + if f4 and not f4(c,syncard,c1,c2,c3) then return false end + local sg=Group.FromCards(c1,c) + if c2 then sg:AddCard(c2) end + if c3 then sg:AddCard(c3) end + local mg=mg1:Clone() + if f4 then + mg=mg:Filter(f4,sg,syncard,c1,c2,c3) + else + mg:Sub(sg) + end + return Auxiliary.SynMixCheck(mg,sg,minc-1,maxc-1,syncard,mg1,smat,gc,mgchk,goalchk) +end +function Auxiliary.SynMixCheck(mg,sg1,minc,maxc,syncard,mg1,smat,gc,mgchk,goalchk) + local tp=syncard:GetControler() + local sg=Group.CreateGroup() + if minc<=0 and Auxiliary.SynMixCheckGoal(tp,sg1,0,0,syncard,sg,smat,gc,mgchk,goalchk) then return true end + if maxc==0 then return false end + local fulltraversal=#mg<=5 or mg1:IsExists(Card.IsHasEffect,1,nil,89818984) + return mg:IsExists(Auxiliary.SynMixCheckRecursive,1,nil,tp,sg,mg,0,minc,maxc,syncard,sg1,smat,gc,mgchk,goalchk,fulltraversal) +end +function Auxiliary.SynMixCheckRecursive(c,tp,sg,mg,ct,minc,maxc,syncard,sg1,smat,gc,mgchk,goalchk,fulltraversal) + sg:AddCard(c) + ct=ct+1 + local res=Auxiliary.SynMixCheckGoal(tp,sg,minc,ct,syncard,sg1,smat,gc,mgchk,goalchk) + if not res and ct=syncard:GetLevel() +end +-- the material is in hand and don't has extra synchro material effect itself +-- that mean some other tuner added it as material +function Auxiliary.SynMixHandFilter(c,tp,syncard) + if not c:IsLocation(LOCATION_HAND) then return false end + local le={c:IsHasEffect(EFFECT_EXTRA_SYNCHRO_MATERIAL,tp)} + for _,te in pairs(le) do + local tf=te:GetValue() + if Auxiliary.GetValueType(tf)=="function" then + if tf(te,syncard) then return false end + else + if tf~=0 then return false end + end + end + return true +end +function Auxiliary.SynMixHandCheck(g,tp,syncard) + local hg=g:Filter(Auxiliary.SynMixHandFilter,nil,tp,syncard) + local hct=hg:GetCount() + if hct>0 then + local found=false + for c in Auxiliary.Next(g) do + local he,hf,hmin,hmax=c:GetHandSynchro() + if he then + found=true + if hf and hg:IsExists(Auxiliary.SynLimitFilter,1,c,hf,he,syncard) then return false end + if (hmin and hcthmax) then return false end + end + end + if not found then return false end + end + return true +end +function Auxiliary.SynMixCheckGoal(tp,sg,minc,ct,syncard,sg1,smat,gc,mgchk,goalchk) + if goalchk then return true end + if ctlmax) then return false end + end + end + return true +end +--Checking Tune Magician +function Auxiliary.TuneMagicianFilter(c,e) + local f=e:GetValue() + return f(e,c) +end +function Auxiliary.TuneMagicianCheckX(c,sg,ecode) + local eset={c:IsHasEffect(ecode)} + for _,te in pairs(eset) do + if sg:IsExists(Auxiliary.TuneMagicianFilter,1,c,te) then return true end + end + return false +end +function Auxiliary.TuneMagicianCheckAdditionalXyz(g) + return not g:IsExists(Auxiliary.TuneMagicianCheckX,1,nil,g,EFFECT_TUNE_MAGICIAN_X) +end +--deprecated, use plain function instead of this factory +function Auxiliary.TuneMagicianCheckAdditionalX(ecode) + return function(g) + return not g:IsExists(Auxiliary.TuneMagicianCheckX,1,nil,g,ecode) + end +end +function Auxiliary.SynGroupCheckLevelAddition(syncard) + return function(g) + local sumlv=g:GetSum(Auxiliary.GetMinSynchroLevel,syncard) + return sumlv<=syncard:GetLevel() + end +end + +--Xyz Summon +function Auxiliary.XyzAlterFilter(c,alterf,xyzc,e,tp,alterop) + return alterf(c,e,tp,xyzc) and c:IsCanBeXyzMaterial(xyzc) and Duel.GetLocationCountFromEx(tp,tp,c,xyzc)>0 + and not c:IsHasEffect(EFFECT_XYZ_MIN_COUNT) + and Auxiliary.MustMaterialCheck(c,tp,EFFECT_MUST_BE_XMATERIAL) and (not alterop or alterop(e,tp,0,c)) +end +---Xyz monster, lv k*n +---@param c Card +---@param f function|nil +---@param lv integer +---@param ct integer +---@param alterf? function +---@param alterdesc? string +---@param maxct? integer +---@param alterop? function +function Auxiliary.AddXyzProcedure(c,f,lv,ct,alterf,alterdesc,maxct,alterop) + if not maxct then maxct=ct end + local e1=Effect.CreateEffect(c) + e1:SetDescription(1165) + e1:SetType(EFFECT_TYPE_FIELD) + e1:SetCode(EFFECT_SPSUMMON_PROC) + e1:SetProperty(EFFECT_FLAG_CANNOT_DISABLE+EFFECT_FLAG_UNCOPYABLE) + e1:SetRange(LOCATION_EXTRA) + e1:SetCondition(Auxiliary.XyzCondition(f,lv,ct,maxct,alterf,alterdesc,alterop)) + e1:SetTarget(Auxiliary.XyzTarget(f,lv,ct,maxct,alterf,alterdesc,alterop)) + e1:SetOperation(Auxiliary.XyzOperation(f,lv,ct,maxct,alterf,alterdesc,alterop)) + e1:SetValue(SUMMON_TYPE_XYZ) + c:RegisterEffect(e1) +end +function Auxiliary.XyzCondition(f,lv,minct,maxct,alterf,alterdesc,alterop) + return function(e,c,og,min,max) + if c==nil then return true end + if c:IsType(TYPE_PENDULUM) and c:IsFaceup() then return false end + local tp=c:GetControler() + local mg=nil + if og then + mg=og + else + mg=Duel.GetFieldGroup(tp,LOCATION_MZONE,0) + end + if alterf and (not min or min<=1) then + if mg:IsExists(Auxiliary.XyzAlterFilter,1,nil,alterf,c,e,tp,alterop) then + return true + end + end + local minc=minct + local maxc=maxct + if min then + if min>minc then minc=min end + if max=3 and mg:IsExists(Auxiliary.Xyz2XMaterialEffectFilter,1,nil,c,lv,f,tp) then + return Auxiliary.CheckXyz2XMaterial(c,f,lv,minc,maxc,mg) + else + if minc>maxc then return false end + return Duel.CheckXyzMaterial(c,f,lv,minc,maxc,og) + end + end +end +function Auxiliary.Xyz2XMaterialFilter(c,xyzc,lv,f) + return c:IsFaceupEx() and c:IsCanBeXyzMaterial(xyzc) and c:IsXyzLevel(xyzc,lv) and (not f or f(c,xyzc)) +end +function Auxiliary.Xyz2XMaterialEffectFilter(c,xyzc,lv,f,tp,checked) + if not checked and not Auxiliary.Xyz2XMaterialFilter(c,xyzc,lv,f) then return false end + local e=c:IsHasEffect(EFFECT_DOUBLE_XMATERIAL,tp) + if not e then return false end + local tg=e:GetTarget() + if tg and not tg(e,xyzc,tp) then return false end + return true +end +function Auxiliary.Xyz2XMaterialGoal(g,tp,xyzc,minc) + if Duel.GetLocationCountFromEx(tp,tp,g,xyzc)<=0 then return false end + local lg=g:Filter(Card.IsHasEffect,nil,EFFECT_XYZ_MIN_COUNT,tp) + for c in Auxiliary.Next(lg) do + local le=c:IsHasEffect(EFFECT_XYZ_MIN_COUNT) + local ct=le:GetValue() + if #g=minc +end +function Auxiliary.CheckXyz2XMaterial(c,f,lv,minc,maxc,mg) + local tp=c:GetControler() + mg=mg:Filter(Auxiliary.Xyz2XMaterialFilter,nil,c,lv,f) + local sg=Duel.GetMustMaterial(tp,EFFECT_MUST_BE_XMATERIAL) + if sg:IsExists(Auxiliary.MustMaterialCounterFilter,1,nil,mg) then return false end + Duel.SetSelectedCard(sg) + Auxiliary.GCheckAdditional=Auxiliary.TuneMagicianCheckAdditionalXyz + local res=mg:CheckSubGroup(Auxiliary.Xyz2XMaterialGoal,2,maxc,tp,c,minc) + Auxiliary.GCheckAdditional=nil + return res +end +function Auxiliary.XyzTarget(f,lv,minct,maxct,alterf,alterdesc,alterop) + return function(e,tp,eg,ep,ev,re,r,rp,chk,c,og,min,max) + if og and not min then + return true + end + local minc=minct + local maxc=maxct + if min then + if min>minc then minc=min end + if max=3 and mg:IsExists(Auxiliary.Xyz2XMaterialEffectFilter,1,nil,c,lv,f,tp) then + b1=Auxiliary.CheckXyz2XMaterial(c,f,lv,minc,maxc,mg) + else + b1=Duel.CheckXyzMaterial(c,f,lv,minc,maxc,og) + end + b2=#altg>0 + end + local g=nil + if b2 and (not b1 or Duel.SelectYesNo(tp,alterdesc)) then + e:SetLabel(1) + local cancel=Duel.IsSummonCancelable() + Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_XMATERIAL) + local tc=altg:SelectUnselect(nil,tp,false,cancel,1,1) + if tc then + g=Group.FromCards(tc) + if alterop then alterop(e,tp,1,tc) end + end + else + e:SetLabel(0) + if minct>=3 and mg:IsExists(Auxiliary.Xyz2XMaterialEffectFilter,1,nil,c,lv,f,tp) then + mg=mg:Filter(Auxiliary.Xyz2XMaterialFilter,nil,c,lv,f) + local cancel=Duel.IsSummonCancelable() + local sg=Duel.GetMustMaterial(tp,EFFECT_MUST_BE_XMATERIAL) + Duel.SetSelectedCard(sg) + Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_XMATERIAL) + Auxiliary.GCheckAdditional=Auxiliary.TuneMagicianCheckAdditionalXyz + g=mg:SelectSubGroup(tp,Auxiliary.Xyz2XMaterialGoal,cancel,2,maxc,tp,c,minc) + Auxiliary.GCheckAdditional=nil + else + g=Duel.SelectXyzMaterial(tp,c,f,lv,minc,maxc,og) + end + end + if g then + g:KeepAlive() + e:SetLabelObject(g) + return true + else return false end + end +end +function Auxiliary.XyzOperation(f,lv,minct,maxct,alterf,alterdesc,alterop) + return function(e,tp,eg,ep,ev,re,r,rp,c,og,min,max) + if og and not min then + Auxiliary.Xyz2XMaterialOperation(tp,og,c,minct,maxct) + local sg=Group.CreateGroup() + local tc=og:GetFirst() + while tc do + local sg1=tc:GetOverlayGroup() + sg:Merge(sg1) + tc=og:GetNext() + end + Duel.SendtoGrave(sg,REASON_RULE) + c:SetMaterial(og) + Duel.Overlay(c,og) + else + local mg=e:GetLabelObject() + if e:GetLabel()==1 then + local mg2=mg:GetFirst():GetOverlayGroup() + if mg2:GetCount()~=0 then + Duel.Overlay(c,mg2) + end + else + Auxiliary.Xyz2XMaterialOperation(tp,mg,c,minct,maxct) + local sg=Group.CreateGroup() + local tc=mg:GetFirst() + while tc do + local sg1=tc:GetOverlayGroup() + sg:Merge(sg1) + tc=mg:GetNext() + end + Duel.SendtoGrave(sg,REASON_RULE) + end + c:SetMaterial(mg) + Duel.Overlay(c,mg) + mg:DeleteGroup() + end + end +end +function Auxiliary.Xyz2XMaterialOperation(tp,mg,xyzc,minct,maxct) + local sg=mg:Clone() + while #sg1 then + Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_RESOLVECARD) + g=g:Select(tp,1,1,nil) + end + local tc=g:GetFirst() + local te=tc:IsHasEffect(EFFECT_DOUBLE_XMATERIAL,tp) + Duel.Hint(HINT_CARD,0,tc:GetCode()) + te:UseCountLimit(tp) + sg:RemoveCard(tc) + minct=minct-2 + end +end +---Xyz monster, any condition(level free) +---@param c Card +---@param f function|nil +---@param gf function|nil +---@param minc integer +---@param maxc integer +---@param alterf? function +---@param alterdesc? string +---@param alterop? function +function Auxiliary.AddXyzProcedureLevelFree(c,f,gf,minc,maxc,alterf,alterdesc,alterop) + local e1=Effect.CreateEffect(c) + e1:SetDescription(1165) + e1:SetType(EFFECT_TYPE_FIELD) + e1:SetCode(EFFECT_SPSUMMON_PROC) + e1:SetProperty(EFFECT_FLAG_CANNOT_DISABLE+EFFECT_FLAG_UNCOPYABLE) + e1:SetRange(LOCATION_EXTRA) + e1:SetCondition(Auxiliary.XyzLevelFreeCondition(f,gf,minc,maxc,alterf,alterdesc,alterop)) + e1:SetTarget(Auxiliary.XyzLevelFreeTarget(f,gf,minc,maxc,alterf,alterdesc,alterop)) + e1:SetOperation(Auxiliary.XyzLevelFreeOperation(f,gf,minc,maxc,alterf,alterdesc,alterop)) + e1:SetValue(SUMMON_TYPE_XYZ) + c:RegisterEffect(e1) +end +-- not fully implemented: EFFECT_DOUBLE_XMATERIAL is not supported +function Auxiliary.XyzLevelFreeFilter(c,xyzc,f) + return (not c:IsOnField() or c:IsFaceup()) and c:IsCanBeXyzMaterial(xyzc) and (not f or f(c,xyzc)) +end +function Auxiliary.XyzLevelFreeGoal(g,tp,xyzc,gf) + if Duel.GetLocationCountFromEx(tp,tp,g,xyzc)<=0 then return false end + if gf and not gf(g,xyzc,tp) then return false end + local lg=g:Filter(Card.IsHasEffect,nil,EFFECT_XYZ_MIN_COUNT) + for c in Auxiliary.Next(lg) do + local le=c:IsHasEffect(EFFECT_XYZ_MIN_COUNT) + local ct=le:GetValue() + if #gminc then minc=min end + if maxminc then minc=min end + if max0 + else + mg=mg:Filter(Auxiliary.XyzLevelFreeFilter,nil,c,f) + end + local g=nil + local cancel=Duel.IsSummonCancelable() + if b2 and (not b1 or Duel.SelectYesNo(tp,alterdesc)) then + e:SetLabel(1) + Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_XMATERIAL) + local tc=altg:SelectUnselect(nil,tp,false,cancel,1,1) + if tc then + g=Group.FromCards(tc) + if alterop then alterop(e,tp,1,tc) end + end + else + e:SetLabel(0) + Duel.SetSelectedCard(sg) + Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_XMATERIAL) + Auxiliary.GCheckAdditional=Auxiliary.TuneMagicianCheckAdditionalXyz + g=mg:SelectSubGroup(tp,Auxiliary.XyzLevelFreeGoal,cancel,minc,maxc,tp,c,gf) + Auxiliary.GCheckAdditional=nil + end + if g and g:GetCount()>0 then + g:KeepAlive() + e:SetLabelObject(g) + return true + else return false end + end +end +function Auxiliary.XyzLevelFreeOperation(f,gf,minct,maxct,alterf,alterdesc,alterop) + return function(e,tp,eg,ep,ev,re,r,rp,c,og,min,max) + if og and not min then + local sg=Group.CreateGroup() + local tc=og:GetFirst() + while tc do + local sg1=tc:GetOverlayGroup() + sg:Merge(sg1) + tc=og:GetNext() + end + Duel.SendtoGrave(sg,REASON_RULE) + c:SetMaterial(og) + Duel.Overlay(c,og) + else + local mg=e:GetLabelObject() + if e:GetLabel()==1 then + local mg2=mg:GetFirst():GetOverlayGroup() + if mg2:GetCount()~=0 then + Duel.Overlay(c,mg2) + end + else + local sg=Group.CreateGroup() + local tc=mg:GetFirst() + while tc do + local sg1=tc:GetOverlayGroup() + sg:Merge(sg1) + tc=mg:GetNext() + end + Duel.SendtoGrave(sg,REASON_RULE) + end + c:SetMaterial(mg) + Duel.Overlay(c,mg) + mg:DeleteGroup() + end + end +end + +--Fusion Summon + +---Fusion monster, mixed materials (fixed count) +---@param fcard Card +---@param sub boolean Can be fusion summoned with substitute material +---@param insf boolean Can be fusion summoned with no material (Instant Fusion) +---@param ... number|function|table +function Auxiliary.AddFusionProcMix(fcard,sub,insf,...) + if fcard:IsStatus(STATUS_COPYING_EFFECT) then return end + local val={...} + local fun={} + local mat={} + for i=1,#val do + if type(val[i])=='function' then + fun[i]=function(c,fc,subm,mg,sg) return val[i](c,fc,subm,mg,sg) and not c:IsHasEffect(6205579) end + elseif type(val[i])=='table' then + fun[i]=function(c,fc,subm,mg,sg) + for _,fcode in ipairs(val[i]) do + if type(fcode)=='function' then + if fcode(c,fc,subm,mg,sg) and not c:IsHasEffect(6205579) then return true end + elseif type(fcode)=='number' then + if c:IsFusionCode(fcode) or (subm and c:CheckFusionSubstitute(fc)) then return true end + end + end + return false + end + for _,fcode in ipairs(val[i]) do + if type(fcode)=='number' then mat[fcode]=true end + end + elseif type(val[i])=='number' then + fun[i]=function(c,fc,subm) return c:IsFusionCode(val[i]) or (subm and c:CheckFusionSubstitute(fc)) end + mat[val[i]]=true + end + end + local mt=getmetatable(fcard) + if mt.material==nil then + mt.material=mat + end + if mt.material_count==nil then + mt.material_count={#fun,#fun} + end + for index,_ in pairs(mat) do + Auxiliary.AddCodeList(fcard,index) + end + local e1=Effect.CreateEffect(fcard) + e1:SetType(EFFECT_TYPE_SINGLE) + e1:SetProperty(EFFECT_FLAG_CANNOT_DISABLE+EFFECT_FLAG_UNCOPYABLE) + e1:SetCode(EFFECT_FUSION_MATERIAL) + e1:SetCondition(Auxiliary.FConditionMix(insf,sub,table.unpack(fun))) + e1:SetOperation(Auxiliary.FOperationMix(insf,sub,table.unpack(fun))) + fcard:RegisterEffect(e1) +end +function Auxiliary.FConditionMix(insf,sub,...) + --g:Material group(nil for Instant Fusion) + --gc:Material already used + --chkf: check field, default:PLAYER_NONE + --chkf&0x100: Not fusion summon, can use substitute (Hex-Sealed Fusion) + --chkf&0x200: Not fusion summon, can't use substitute ("Contact Fusion", Neos Fusion) + local funs={...} + return function(e,g,gc,chkfnf) + if g==nil then return insf and Auxiliary.MustMaterialCheck(nil,e:GetHandlerPlayer(),EFFECT_MUST_BE_FMATERIAL) end + local c=e:GetHandler() + local tp=c:GetControler() + local hexsealed=chkfnf&0x100>0 + local notfusion=chkfnf&0x200>0 + local sub2=(sub or hexsealed) and not notfusion + local mg=g:Filter(Auxiliary.FConditionFilterMix,c,c,sub2,notfusion,table.unpack(funs)) + if gc then + if not mg:IsContains(gc) then return false end + Duel.SetSelectedCard(gc) + end + return mg:CheckSubGroup(Auxiliary.FCheckMixGoal,#funs,#funs,tp,c,sub2,chkfnf,table.unpack(funs)) + end +end +function Auxiliary.FOperationMix(insf,sub,...) + local funs={...} + return function(e,tp,eg,ep,ev,re,r,rp,gc,chkfnf) + local c=e:GetHandler() + local hexsealed=chkfnf&0x100>0 + local notfusion=chkfnf&0x200>0 + local sub2=(sub or hexsealed) and not notfusion + local cancel=notfusion and Duel.GetCurrentChain()==0 + local mg=eg:Filter(Auxiliary.FConditionFilterMix,c,c,sub2,notfusion,table.unpack(funs)) + if gc then Duel.SetSelectedCard(gc) end + Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_FMATERIAL) + local sg=mg:SelectSubGroup(tp,Auxiliary.FCheckMixGoal,cancel,#funs,#funs,tp,c,sub2,chkfnf,table.unpack(funs)) + if sg then + Duel.SetFusionMaterial(sg) + else + Duel.SetFusionMaterial(Group.CreateGroup()) + end + end +end +function Auxiliary.FConditionFilterMix(c,fc,sub,notfusion,...) + local check_type=notfusion and SUMMON_TYPE_SPECIAL or SUMMON_TYPE_FUSION + if not FusionSpell.IsCanBeFusionMaterial(c,fc,check_type) then return false end + for i,f in ipairs({...}) do + if f(c,fc,sub) then return true end + end + return false +end +function Auxiliary.FCheckMix(c,mg,sg,fc,sub,fun1,fun2,...) + if fun2 then + sg:AddCard(c) + local res=false + if fun1(c,fc,false,mg,sg) then + res=mg:IsExists(Auxiliary.FCheckMix,1,sg,mg,sg,fc,sub,fun2,...) + elseif sub and fun1(c,fc,true,mg,sg) then + res=mg:IsExists(Auxiliary.FCheckMix,1,sg,mg,sg,fc,false,fun2,...) + end + sg:RemoveCard(c) + return res + else + return fun1(c,fc,sub,mg,sg) + end +end +--if sg1 is subset of sg2 then not Auxiliary.FCheckAdditional(tp,sg1,fc) -> not Auxiliary.FCheckAdditional(tp,sg2,fc) +function Auxiliary.FCheckMixGoal(sg,tp,fc,sub,chkfnf,...) + local chkf=chkfnf&0xff + local not_fusion=chkfnf&(0x100|0x200)>0 + if not not_fusion and sg:IsExists(Auxiliary.TuneMagicianCheckX,1,nil,sg,EFFECT_TUNE_MAGICIAN_F) then return false end + if not Auxiliary.MustMaterialCheck(sg,tp,EFFECT_MUST_BE_FMATERIAL) then return false end + local g=Group.CreateGroup() + return sg:IsExists(Auxiliary.FCheckMix,1,nil,sg,g,fc,sub,...) and (chkf==PLAYER_NONE or Duel.GetLocationCountFromEx(tp,tp,sg,fc)>0) + and (not Auxiliary.FCheckAdditional or Auxiliary.FCheckAdditional(tp,sg,fc)) + and (not Auxiliary.FGoalCheckAdditional or Auxiliary.FGoalCheckAdditional(tp,sg,fc)) +end + +---Fusion monster, mixed material * minc to maxc + material + ... +---@param fcard Card +---@param sub boolean Can be fusion summoned with substitute material +---@param insf boolean Can be fusion summoned with no material (Instant Fusion) +---@param fun1 number|function|table +---@param minc integer +---@param maxc integer +---@param ... number|function|table +function Auxiliary.AddFusionProcMixRep(fcard,sub,insf,fun1,minc,maxc,...) + if fcard:IsStatus(STATUS_COPYING_EFFECT) then return end + local val={fun1,...} + local fun={} + local mat={} + for i=1,#val do + if type(val[i])=='function' then + fun[i]=function(c,fc,subm,mg,sg) return val[i](c,fc,subm,mg,sg) and not c:IsHasEffect(6205579) end + elseif type(val[i])=='table' then + fun[i]=function(c,fc,subm,mg,sg) + for _,fcode in ipairs(val[i]) do + if type(fcode)=='function' then + if fcode(c,fc,subm,mg,sg) and not c:IsHasEffect(6205579) then return true end + elseif type(fcode)=='number' then + if c:IsFusionCode(fcode) or (subm and c:CheckFusionSubstitute(fc)) then return true end + end + end + return false + end + for _,fcode in ipairs(val[i]) do + if type(fcode)=='number' then mat[fcode]=true end + end + elseif type(val[i])=='number' then + fun[i]=function(c,fc,subm) return c:IsFusionCode(val[i]) or (subm and c:CheckFusionSubstitute(fc)) end + mat[val[i]]=true + end + end + local mt=getmetatable(fcard) + if mt.material==nil then + mt.material=mat + end + if mt.material_count==nil then + mt.material_count={#fun+minc-1,#fun+maxc-1} + end + for index,_ in pairs(mat) do + Auxiliary.AddCodeList(fcard,index) + end + local e1=Effect.CreateEffect(fcard) + e1:SetType(EFFECT_TYPE_SINGLE) + e1:SetProperty(EFFECT_FLAG_CANNOT_DISABLE+EFFECT_FLAG_UNCOPYABLE) + e1:SetCode(EFFECT_FUSION_MATERIAL) + e1:SetCondition(Auxiliary.FConditionMixRep(insf,sub,fun[1],minc,maxc,table.unpack(fun,2))) + e1:SetOperation(Auxiliary.FOperationMixRep(insf,sub,fun[1],minc,maxc,table.unpack(fun,2))) + fcard:RegisterEffect(e1) +end +function Auxiliary.FConditionMixRep(insf,sub,fun1,minc,maxc,...) + local funs={...} + return function(e,g,gc,chkfnf) + if g==nil then return insf and Auxiliary.MustMaterialCheck(nil,e:GetHandlerPlayer(),EFFECT_MUST_BE_FMATERIAL) end + local c=e:GetHandler() + local tp=c:GetControler() + local hexsealed=chkfnf&0x100>0 + local notfusion=chkfnf&0x200>0 + local sub2=(sub or hexsealed) and not notfusion + local mg=g:Filter(Auxiliary.FConditionFilterMix,c,c,sub2,notfusion,fun1,table.unpack(funs)) + if gc then + if not mg:IsContains(gc) then return false end + local sg=Group.CreateGroup() + return Auxiliary.FSelectMixRep(gc,tp,mg,sg,c,sub2,chkfnf,fun1,minc,maxc,table.unpack(funs)) + end + local sg=Group.CreateGroup() + return mg:IsExists(Auxiliary.FSelectMixRep,1,nil,tp,mg,sg,c,sub2,chkfnf,fun1,minc,maxc,table.unpack(funs)) + end +end +function Auxiliary.FOperationMixRep(insf,sub,fun1,minc,maxc,...) + local funs={...} + return function(e,tp,eg,ep,ev,re,r,rp,gc,chkfnf) + local c=e:GetHandler() + local tp=c:GetControler() + local hexsealed=chkfnf&0x100>0 + local notfusion=chkfnf&0x200>0 + local sub2=(sub or hexsealed) and not notfusion + local cancel=notfusion and Duel.GetCurrentChain()==0 + local mg=eg:Filter(Auxiliary.FConditionFilterMix,c,c,sub2,notfusion,fun1,table.unpack(funs)) + local sg=Group.CreateGroup() + if gc then sg:AddCard(gc) end + while sg:GetCount()0 + if not not_fusion and sg:IsExists(Auxiliary.TuneMagicianCheckX,1,nil,sg,EFFECT_TUNE_MAGICIAN_F) then return false end + if not Auxiliary.MustMaterialCheck(sg,tp,EFFECT_MUST_BE_FMATERIAL) then return false end + if Auxiliary.FGoalCheckAdditional and not Auxiliary.FGoalCheckAdditional(tp,sg,fc) then return false end + return true +end +function Auxiliary.FCheckMixRepGoal(tp,sg,fc,sub,chkfnf,fun1,minc,maxc,...) + local chkf=chkfnf&0xff + if sg:GetCount()maxc+#{...} then return false end + if not (chkf==PLAYER_NONE or Duel.GetLocationCountFromEx(tp,tp,sg,fc)>0) then return false end + if Auxiliary.FCheckAdditional and not Auxiliary.FCheckAdditional(tp,sg,fc) then return false end + if not Auxiliary.FCheckMixRepGoalCheck(tp,sg,fc,chkfnf) then return false end + local g=Group.CreateGroup() + return Auxiliary.FCheckMixRep(sg,g,fc,sub,chkf,fun1,minc,maxc,...) +end +function Auxiliary.FCheckMixRepTemplate(c,cond,tp,mg,sg,g,fc,sub,chkfnf,fun1,minc,maxc,...) + for i,f in ipairs({...}) do + if f(c,fc,sub) then + g:AddCard(c) + local subf=sub and f(c,fc,false) + local t={...} + table.remove(t,i) + local res=cond(tp,mg,sg,g,fc,subf,chkfnf,fun1,minc,maxc,table.unpack(t)) + g:RemoveCard(c) + if res then return true end + end + end + if maxc>0 then + if fun1(c,fc,sub,mg,sg) then + g:AddCard(c) + local subf1=sub and fun1(c,fc,false,mg,sg) + local res=cond(tp,mg,sg,g,fc,subf1,chkfnf,fun1,minc-1,maxc-1,...) + g:RemoveCard(c) + if res then return true end + end + end + return false +end +function Auxiliary.FCheckMixRepSelectedCond(tp,mg,sg,g,...) + if g:GetCount()0 then + if minc<=0 and #{...}==0 and Auxiliary.FCheckMixRepGoalCheck(tp,g,fc,chkfnf) then return true end + return mg:IsExists(Auxiliary.FCheckSelectMixRepAll,1,g,tp,mg,sg,g,fc,sub,chkfnf,fun1,minc,maxc,...) + else + return mg:IsExists(Auxiliary.FCheckSelectMixRepM,1,g,tp,mg,sg,g,fc,sub,chkfnf,fun1,minc,maxc,...) + end +end +function Auxiliary.FCheckSelectMixRepAll(c,tp,mg,sg,g,fc,sub,chkf,fun1,minc,maxc,fun2,...) + if fun2 then + if fun2(c,fc,sub) then + g:AddCard(c) + local subf2=sub and fun2(c,fc,false) + local res=Auxiliary.FCheckSelectMixRep(tp,mg,sg,g,fc,subf2,chkf,fun1,minc,maxc,...) + g:RemoveCard(c) + return res + end + elseif maxc>0 and fun1(c,fc,sub,mg,sg) then + g:AddCard(c) + local subf1=sub and fun1(c,fc,false,mg,sg) + local res=Auxiliary.FCheckSelectMixRep(tp,mg,sg,g,fc,subf1,chkf,fun1,minc-1,maxc-1) + g:RemoveCard(c) + return res + end + return false +end +function Auxiliary.FCheckSelectMixRepM(c,tp,...) + return c:IsControler(tp) and c:IsLocation(LOCATION_MZONE) + and Auxiliary.FCheckMixRepTemplate(c,Auxiliary.FCheckSelectMixRep,tp,...) +end +function Auxiliary.FSelectMixRep(c,tp,mg,sg,fc,sub,chkfnf,...) + sg:AddCard(c) + local res=false + if Auxiliary.FCheckAdditional and not Auxiliary.FCheckAdditional(tp,sg,fc) then + res=false + elseif Auxiliary.FCheckMixRepGoal(tp,sg,fc,sub,chkfnf,...) then + res=true + else + local g=Group.CreateGroup() + res=sg:IsExists(Auxiliary.FCheckMixRepSelected,1,nil,tp,mg,sg,g,fc,sub,chkfnf,...) + end + sg:RemoveCard(c) + return res +end + +---Fusion monster, name + name +---@param c Card +---@param code1 integer +---@param code2 integer +---@param sub boolean +---@param insf boolean +function Auxiliary.AddFusionProcCode2(c,code1,code2,sub,insf) + Auxiliary.AddFusionProcMix(c,sub,insf,code1,code2) +end +---Fusion monster, name + name + name +---@param c Card +---@param code1 integer +---@param code2 integer +---@param code3 integer +---@param sub boolean +---@param insf boolean +function Auxiliary.AddFusionProcCode3(c,code1,code2,code3,sub,insf) + Auxiliary.AddFusionProcMix(c,sub,insf,code1,code2,code3) +end +---Fusion monster, name + name + name + name +---@param c Card +---@param code1 integer +---@param code2 integer +---@param code3 integer +---@param code4 integer +---@param sub boolean +---@param insf boolean +function Auxiliary.AddFusionProcCode4(c,code1,code2,code3,code4,sub,insf) + Auxiliary.AddFusionProcMix(c,sub,insf,code1,code2,code3,code4) +end +---Fusion monster, name * n +---@param c Card +---@param code1 integer +---@param cc integer +---@param sub boolean +---@param insf boolean +function Auxiliary.AddFusionProcCodeRep(c,code1,cc,sub,insf) + local code={} + for i=1,cc do + code[i]=code1 + end + Auxiliary.AddFusionProcMix(c,sub,insf,table.unpack(code)) +end +---Fusion monster, name * minc to maxc +---@param c Card +---@param code1 integer|table +---@param minc integer +---@param maxc integer +---@param sub boolean +---@param insf boolean +function Auxiliary.AddFusionProcCodeRep2(c,code1,minc,maxc,sub,insf) + Auxiliary.AddFusionProcMixRep(c,sub,insf,code1,minc,maxc) +end +---Fusion monster, name + condition * n +---@param c Card +---@param code1 integer|table +---@param f function|table +---@param cc integer +---@param sub boolean +---@param insf boolean +function Auxiliary.AddFusionProcCodeFun(c,code1,f,cc,sub,insf) + local fun={} + for i=1,cc do + fun[i]=f + end + Auxiliary.AddFusionProcMix(c,sub,insf,code1,table.unpack(fun)) +end +---Fusion monster, condition + condition +---@param c Card +---@param f1 function|table +---@param f2 function|table +---@param insf boolean +function Auxiliary.AddFusionProcFun2(c,f1,f2,insf) + Auxiliary.AddFusionProcMix(c,false,insf,f1,f2) +end +---Fusion monster, condition * n +---@param c Card +---@param f function|table +---@param cc integer +---@param insf boolean +function Auxiliary.AddFusionProcFunRep(c,f,cc,insf) + local fun={} + for i=1,cc do + fun[i]=f + end + Auxiliary.AddFusionProcMix(c,false,insf,table.unpack(fun)) +end +---Fusion monster, condition * minc to maxc +---@param c Card +---@param f function|table +---@param minc integer +---@param maxc integer +---@param insf boolean +function Auxiliary.AddFusionProcFunRep2(c,f,minc,maxc,insf) + Auxiliary.AddFusionProcMixRep(c,false,insf,f,minc,maxc) +end +---Fusion monster, condition1 + condition2 * n +---@param c Card +---@param f1 function|table +---@param f2 function|table +---@param cc integer +---@param insf boolean +function Auxiliary.AddFusionProcFunFun(c,f1,f2,cc,insf) + local fun={} + for i=1,cc do + fun[i]=f2 + end + Auxiliary.AddFusionProcMix(c,false,insf,f1,table.unpack(fun)) +end +--Fusion monster, condition1 + condition2 * minc to maxc +function Auxiliary.AddFusionProcFunFunRep(c,f1,f2,minc,maxc,insf) + Auxiliary.AddFusionProcMixRep(c,false,insf,f2,minc,maxc,f1) +end +---Fusion monster, name + condition * minc to maxc +---@param c Card +---@param code1 integer|table +---@param f function|table +---@param minc integer +---@param maxc integer +---@param sub boolean +---@param insf boolean +function Auxiliary.AddFusionProcCodeFunRep(c,code1,f,minc,maxc,sub,insf) + Auxiliary.AddFusionProcMixRep(c,sub,insf,f,minc,maxc,code1) +end +---Fusion monster, name + name + condition * minc to maxc +---@param c Card +---@param code1 integer|table +---@param code2 integer|table +---@param f function|table +---@param minc integer +---@param maxc integer +---@param sub boolean +---@param insf boolean +function Auxiliary.AddFusionProcCode2FunRep(c,code1,code2,f,minc,maxc,sub,insf) + Auxiliary.AddFusionProcMixRep(c,sub,insf,f,minc,maxc,code1,code2) +end +---Fusion monster, Shaddoll materials can use 影依の原核 +function Auxiliary.FShaddollFilter2(c,attr) + return c:IsFusionAttribute(attr) or c:IsHasEffect(4904633) +end + +--Fusion Summon Effect +function Auxiliary.FMaterialFilter(c,e,tp) + return FusionSpell.IsCanBeFusionMaterial(c) +end +function Auxiliary.FMaterialRemoveFilter(c,e,tp) + return c:IsAbleToRemove() +end +function Auxiliary.FMaterialToGraveFilter(c,e,tp) + return c:IsAbleToGrave() +end +function Auxiliary.FMaterialToGrave(mat) + Duel.SendtoGrave(mat,REASON_EFFECT+REASON_MATERIAL+REASON_FUSION) +end +function Auxiliary.FMaterialRemove(mat) + Duel.Remove(mat,POS_FACEUP,REASON_EFFECT+REASON_MATERIAL+REASON_FUSION) +end +function Auxiliary.FMaterialToDeck(mat) + Duel.SendtoDeck(mat,nil,2,REASON_EFFECT+REASON_MATERIAL+REASON_FUSION) +end +---Add Fusion Summon with table `params`. +---@param c Card +---@param params table +---@return Effect +function Auxiliary.AddFusionEffectProcUltimate(c,params) + --filter,mat_location,mat_filter,mat_operation,gc,reg,get_extra_mat,include_this_card + --grave_filter,grave_operation,removed_filter,removed_operation,deck_filter,deck_operation,extra_filter,extra_operation + --get_fcheck,get_gcheck,get_fgoalcheck,foperation,fcheck,gcheck,fgoalcheck,spsummon_nocheck + --category,opinfo,mat_operation2,foperation2 + if params.mat_location==nil then params.mat_location=LOCATION_HAND+LOCATION_MZONE end + if params.mat_filter==nil then params.mat_filter=Auxiliary.FMaterialFilter end + if params.mat_operation==nil then params.mat_operation=Auxiliary.FMaterialToGrave end + if params.grave_filter==nil then params.grave_filter=Auxiliary.FMaterialRemoveFilter end + if params.grave_operation==nil then params.grave_operation=Auxiliary.FMaterialRemove end + if params.removed_operation==nil then params.removed_operation=params.mat_operation end + if params.deck_filter==nil then params.deck_filter=Auxiliary.FMaterialToGraveFilter end + if params.deck_operation==nil then params.deck_operation=params.mat_operation end + if params.extra_filter==nil then params.extra_filter=Auxiliary.FMaterialToGraveFilter end + if params.extra_operation==nil then params.extra_operation=params.mat_operation end + if params.spsummon_nocheck==nil then params.spsummon_nocheck=false end + if params.category==nil then params.category=0 end + local e1=Effect.CreateEffect(c) + e1:SetCategory(CATEGORY_SPECIAL_SUMMON|CATEGORY_FUSION_SUMMON|params.category) + e1:SetTarget(Auxiliary.FusionEffectUltimateTarget(params)) + e1:SetOperation(Auxiliary.FusionEffectUltimateOperation(params)) + if params.reg~=false then + e1:SetType(EFFECT_TYPE_ACTIVATE) + e1:SetCode(EVENT_FREE_CHAIN) + c:RegisterEffect(e1) + end + return e1 +end +Auxiliary.FMaterialBase=nil +function Auxiliary.FusionEffectUltimateFilter(c,e,tp,mg,chkf,params) + --mg,gc,f1,f2,get_fcheck,spsummon_nocheck + if not c:IsType(TYPE_FUSION) then return false end + if not c:IsCanBeSpecialSummoned(e,SUMMON_TYPE_FUSION,tp,params.spsummon_nocheck,false) then return false end + if params.filter1 and not params.filter1(c) then return false end + if params.filter2 and not params.filter2(c) then return false end + if params.get_fcheck then Auxiliary.FCheckAdditional=params.get_fcheck(c,e,tp) end + local res=c:CheckFusionMaterial(mg,params.gc,chkf) + if params.get_fcheck then Auxiliary.FCheckAdditional=nil end + return res +end +function Auxiliary.FusionEffectUltimateMatFilter(c,e,tp,f) + return not c:IsImmuneToEffect(e) and (not f or f(c,e,tp)) +end +function Auxiliary.FusionEffectUltimateMatLocFilter(c,e,tp,loc,f) + return not c:IsLocation(loc) or (not f or f(c,e,tp)) +end +function Auxiliary.FusionEffectUltimateTarget(params) + return function(e,tp,eg,ep,ev,re,r,rp,chk) + if chk==0 then + local chkf=tp + local gc + if params.include_this_card then + gc=e:GetHandler() + end + local mgall,mgbase=Duel.GetFusionMaterial(tp,params.mat_location) + local mgex=Group.CreateGroup() + if params.get_extra_mat then mgex=params.get_extra_mat(e,tp,eg,ep,ev,re,r,rp) end + mgall:Merge(mgex) + mgbase:Merge(mgex) + local mg1=mgall:Filter(Auxiliary.FusionEffectUltimateMatFilter,nil,e,tp,params.mat_filter) + :Filter(Auxiliary.FusionEffectUltimateMatLocFilter,nil,e,tp,LOCATION_GRAVE,params.grave_filter) + :Filter(Auxiliary.FusionEffectUltimateMatLocFilter,nil,e,tp,LOCATION_REMOVED,params.removed_filter) + :Filter(Auxiliary.FusionEffectUltimateMatLocFilter,nil,e,tp,LOCATION_DECK,params.deck_filter) + :Filter(Auxiliary.FusionEffectUltimateMatLocFilter,nil,e,tp,LOCATION_EXTRA,params.extra_filter) + if gc then mg1:AddCard(gc) end + Auxiliary.FMaterialBase=mgbase:Filter(Auxiliary.IsInGroup,nil,mg1) + Auxiliary.FCheckAdditional=params.fcheck + Auxiliary.GCheckAdditional=params.gcheck + if params.get_gcheck then + Auxiliary.GCheckAdditional=params.get_gcheck(e,tp,nil) + end + Auxiliary.FGoalCheckAdditional=params.fgoalcheck + local res=Duel.IsExistingMatchingCard(Auxiliary.FusionEffectUltimateFilter,tp,LOCATION_EXTRA,0,1,nil,e,tp,mg1,chkf,{ + filter1=params.filter, + gc=gc, + get_fcheck=params.get_fcheck, + spsummon_nocheck=params.spsummon_nocheck + }) + Auxiliary.FCheckAdditional=nil + Auxiliary.GCheckAdditional=nil + if not res then + local ce=Duel.GetChainMaterial(tp) + if ce~=nil then + local fgroup=ce:GetTarget() + local mg2=fgroup(ce,e,tp):Filter(Auxiliary.FusionEffectUltimateMatFilter,nil,e,tp,params.mat_filter) + local mf=ce:GetValue() + res=Duel.IsExistingMatchingCard(Auxiliary.FusionEffectUltimateFilter,tp,LOCATION_EXTRA,0,1,nil,e,tp,mg2,chkf,{ + filter1=params.filter, + filter2=mf, + gc=gc, + get_fcheck=params.get_fcheck + }) + end + end + Auxiliary.FMaterialBase=nil + Auxiliary.FGoalCheckAdditional=nil + return res + end + Duel.SetOperationInfo(0,CATEGORY_SPECIAL_SUMMON,nil,1,tp,LOCATION_EXTRA) + if params.mat_operation==Auxiliary.FMaterialRemove + or params.grave_operation==Auxiliary.FMaterialRemove + or params.deck_operation==Auxiliary.FMaterialRemove then + Duel.SetOperationInfo(0,CATEGORY_REMOVE,nil,1,tp,params.mat_location) + e:SetCategory(e:GetCategory()|CATEGORY_REMOVE) + end + if params.mat_operation==Auxiliary.FMaterialToDeck + or params.grave_operation==Auxiliary.FMaterialToDeck + or params.deck_operation==Auxiliary.FMaterialToDeck then + Duel.SetOperationInfo(0,CATEGORY_TODECK,nil,1,tp,params.mat_location) + e:SetCategory(e:GetCategory()|CATEGORY_TODECK) + end + if params.mat_location&LOCATION_DECK>0 then + e:SetCategory(e:GetCategory()|CATEGORY_DECKDES) + end + if params.opinfo then + params.opinfo(e,tp) + end + end +end +--- +---@param params table +---@return function +function Auxiliary.FusionEffectUltimateOperation(params) + return function(e,tp,eg,ep,ev,re,r,rp) + local chkf=tp + local gc + if params.include_this_card then + gc=e:GetHandler() + if gc:IsOnField() and gc:IsFacedown() or not gc:IsRelateToEffect(e) or gc:IsImmuneToEffect(e) then return end + end + local mgall,mgbase=Duel.GetFusionMaterial(tp,params.mat_location) + local mgex=Group.CreateGroup() + if params.get_extra_mat then mgex=params.get_extra_mat(e,tp,eg,ep,ev,re,r,rp) end + mgall:Merge(mgex) + mgbase:Merge(mgex) + local mg1=mgall:Filter(Auxiliary.FusionEffectUltimateMatFilter,nil,e,tp,params.mat_filter) + :Filter(Auxiliary.FusionEffectUltimateMatLocFilter,nil,e,tp,LOCATION_GRAVE,params.grave_filter) + :Filter(Auxiliary.FusionEffectUltimateMatLocFilter,nil,e,tp,LOCATION_REMOVED,params.removed_filter) + :Filter(Auxiliary.FusionEffectUltimateMatLocFilter,nil,e,tp,LOCATION_DECK,params.deck_filter) + :Filter(Auxiliary.FusionEffectUltimateMatLocFilter,nil,e,tp,LOCATION_EXTRA,params.extra_filter) + if gc then mg1:AddCard(gc) end + Auxiliary.FMaterialBase=mgbase:Filter(Auxiliary.IsInGroup,nil,mg1) + Auxiliary.FCheckAdditional=params.fcheck + Auxiliary.GCheckAdditional=params.gcheck + if params.get_gcheck then + Auxiliary.GCheckAdditional=params.get_gcheck(e,tp,nil) + end + Auxiliary.FGoalCheckAdditional=params.fgoalcheck + local sg1=Duel.GetMatchingGroup(Auxiliary.FusionEffectUltimateFilter,tp,LOCATION_EXTRA,0,nil,e,tp,mg1,chkf,{ + filter1=params.filter, + gc=gc, + get_fcheck=params.get_fcheck, + spsummon_nocheck=params.spsummon_nocheck + }) + Auxiliary.FCheckAdditional=nil + Auxiliary.GCheckAdditional=nil + local mg2=nil + local sg2=nil + local ce=Duel.GetChainMaterial(tp) + if ce then + local fgroup=ce:GetTarget() + mg2=fgroup(ce,e,tp):Filter(Auxiliary.FusionEffectUltimateMatFilter,nil,e,tp,params.mat_filter) + local mf=ce:GetValue() + sg2=Duel.GetMatchingGroup(Auxiliary.FusionEffectUltimateFilter,tp,LOCATION_EXTRA,0,nil,e,tp,mg2,chkf,{ + filter1=params.filter, + filter2=mf, + gc=gc, + get_fcheck=params.get_fcheck + }) + end + if sg1:GetCount()>0 or (sg2~=nil and sg2:GetCount()>0) then + local sg=sg1:Clone() + if sg2 then sg:Merge(sg2) end + Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_SPSUMMON) + local tg=sg:Select(tp,1,1,nil) + local tc=tg:GetFirst() + Auxiliary.FCheckAdditional=params.fcheck + Auxiliary.GCheckAdditional=params.gcheck + if params.get_gcheck then + Auxiliary.GCheckAdditional=params.get_gcheck(e,tp,tc) + end + if params.get_fcheck then Auxiliary.FCheckAdditional=params.get_fcheck(tc,e,tp) end + if sg1:IsContains(tc) and (sg2==nil or not sg2:IsContains(tc) or ce and not Duel.SelectYesNo(tp,ce:GetDescription())) then + local mat1=Duel.SelectFusionMaterial(tp,tc,mg1,gc,chkf) + tc:SetMaterial(mat1) + if params.mat_operation2 then params.mat_operation2(e,tp,mat1) end + if params.grave_operation~=params.mat_operation then + local mat=mat1:Filter(Card.IsLocation,nil,LOCATION_GRAVE) + mat1:Sub(mat) + params.grave_operation(mat) + end + if params.removed_operation~=params.mat_operation then + local mat=mat1:Filter(Card.IsLocation,nil,LOCATION_REMOVED) + mat1:Sub(mat) + params.removed_operation(mat) + end + if params.deck_operation~=params.mat_operation then + local mat=mat1:Filter(Card.IsLocation,nil,LOCATION_DECK) + mat1:Sub(mat) + params.deck_operation(mat) + end + if params.extra_operation~=params.mat_operation then + local mat=mat1:Filter(Card.IsLocation,nil,LOCATION_EXTRA) + mat1:Sub(mat) + params.extra_operation(mat) + end + params.mat_operation(mat1) + Duel.BreakEffect() + Duel.SpecialSummon(tc,SUMMON_TYPE_FUSION,tp,tp,params.spsummon_nocheck,false,POS_FACEUP) + elseif ce and mg2 then + local mat2=Duel.SelectFusionMaterial(tp,tc,mg2,gc,chkf) + local fop=ce:GetOperation() + fop(ce,e,tp,tc,mat2) + end + tc:CompleteProcedure() + if params.foperation then params.foperation(e,tp,tc) end + end + Auxiliary.FCheckAdditional=nil + Auxiliary.GCheckAdditional=nil + Auxiliary.FGoalCheckAdditional=nil + Auxiliary.FMaterialBase=nil + if params.foperation2 then params.foperation2(e,tp,eg,ep,ev,re,r,rp) end + end +end +function Auxiliary.AddFusionEffectProc(c,filter,mat_location,mat_filter,mat_operation,params) + if params==nil then params={} end + params.filter=filter + params.mat_location=mat_location + params.mat_filter=mat_filter + params.mat_operation=mat_operation + return Auxiliary.AddFusionEffectProcUltimate(c,params) +end + +--Contact Fusion +function Auxiliary.AddContactFusionProcedure(c,filter,self_location,opponent_location,mat_operation,...) + self_location=self_location or 0 + opponent_location=opponent_location or 0 + local operation_params={...} + local e2=Effect.CreateEffect(c) + e2:SetType(EFFECT_TYPE_FIELD) + e2:SetCode(EFFECT_SPSUMMON_PROC) + e2:SetProperty(EFFECT_FLAG_CANNOT_DISABLE+EFFECT_FLAG_UNCOPYABLE) + e2:SetRange(LOCATION_EXTRA) + e2:SetCondition(Auxiliary.ContactFusionCondition(filter,self_location,opponent_location)) + e2:SetTarget(Auxiliary.ContactFusionTarget(filter,self_location,opponent_location)) + e2:SetOperation(Auxiliary.ContactFusionOperation(mat_operation,operation_params)) + c:RegisterEffect(e2) + return e2 +end +function Auxiliary.ContactFusionMaterialFilter(c,fc,filter) + return FusionSpell.IsCanBeFusionMaterial(c,fc,SUMMON_TYPE_SPECIAL) and (not filter or filter(c,fc)) +end +function Auxiliary.ContactFusionCondition(filter,self_location,opponent_location) + return function(e,c) + if c==nil then return true end + if c:IsType(TYPE_PENDULUM) and c:IsFaceup() then return false end + local tp=c:GetControler() + local mg=Duel.GetMatchingGroup(Auxiliary.ContactFusionMaterialFilter,tp,self_location,opponent_location,c,c,filter) + return c:CheckFusionMaterial(mg,nil,tp|0x200) + end +end +function Auxiliary.ContactFusionTarget(filter,self_location,opponent_location) + return function(e,tp,eg,ep,ev,re,r,rp,chk,c) + local mg=Duel.GetMatchingGroup(Auxiliary.ContactFusionMaterialFilter,tp,self_location,opponent_location,c,c,filter) + local g=Duel.SelectFusionMaterial(tp,c,mg,nil,tp|0x200) + if #g>0 then + g:KeepAlive() + e:SetLabelObject(g) + return true + else return false end + end +end +function Auxiliary.ContactFusionOperation(mat_operation,operation_params) + return function(e,tp,eg,ep,ev,re,r,rp,c) + local g=e:GetLabelObject() + c:SetMaterial(g) + mat_operation(g,table.unpack(operation_params)) + g:DeleteGroup() + end +end +--send to deck of contact fusion +function Auxiliary.ContactFusionSendToDeck(c) + return function(g) + local cg=g:Filter(Card.IsFacedown,nil) + if cg:GetCount()>0 then + Duel.ConfirmCards(1-c:GetControler(),cg) + end + local hg=g:Filter(Card.IsLocation,nil,LOCATION_GRAVE+LOCATION_REMOVED) + if hg:GetCount()>0 then + Duel.HintSelection(hg) + end + Duel.SendtoDeck(g,nil,SEQ_DECKSHUFFLE,REASON_COST) + end +end +Auxiliary.tdcfop=Auxiliary.ContactFusionSendToDeck + +--Ritual Summon +function Auxiliary.AddRitualProcUltimate(c,filter,level_function,greater_or_equal,summon_location,grave_filter,mat_filter,pause,extra_operation,extra_target) + summon_location=summon_location or LOCATION_HAND + local e1=Effect.CreateEffect(c) + e1:SetCategory(CATEGORY_SPECIAL_SUMMON) + e1:SetType(EFFECT_TYPE_ACTIVATE) + e1:SetCode(EVENT_FREE_CHAIN) + e1:SetTarget(Auxiliary.RitualUltimateTarget(filter,level_function,greater_or_equal,summon_location,grave_filter,mat_filter,extra_target)) + e1:SetOperation(Auxiliary.RitualUltimateOperation(filter,level_function,greater_or_equal,summon_location,grave_filter,mat_filter,extra_operation)) + if not pause then + c:RegisterEffect(e1) + end + return e1 +end +---@param g Group +---@param c Card +---@param lv integer +---@return boolean +function Auxiliary.RitualCheckGreater(g,c,lv) + Duel.SetSelectedCard(g) + return g:CheckWithSumGreater(Card.GetRitualLevel,lv,c) +end +---@param g Group +---@param c Card +---@param lv integer +---@return boolean +function Auxiliary.RitualCheckEqual(g,c,lv) + return g:CheckWithSumEqual(Card.GetRitualLevel,lv,#g,#g,c) +end +---@param g Group +---@param tp integer +---@param c Card +---@param lv integer +---@param greater_or_equal string +---|"'Greater'" +---|"'Equal'" +---@return boolean +function Auxiliary.RitualCheck(g,tp,c,lv,greater_or_equal) + -- Check if there's space to summon + if c:IsLocation(LOCATION_EXTRA) then + if Duel.GetLocationCountFromEx(tp,tp,g,c)<=0 then + return false + end + else + if Duel.GetMZoneCount(tp,g,tp)<=0 then + return false + end + end + return Auxiliary["RitualCheck"..greater_or_equal](g,c,lv) and (not c.mat_group_check or c.mat_group_check(g,tp)) + and (not Auxiliary.RCheckAdditional or Auxiliary.RCheckAdditional(tp,g,c)) +end +function Auxiliary.RitualCheckAdditionalLevel(c,rc) + local raw_level=c:GetRitualLevel(rc) + local lv1=raw_level&0xffff + local lv2=raw_level>>16 + if lv2>0 then + return math.min(lv1,lv2) + else + return lv1 + end +end +function Auxiliary.RitualCheckAdditional(c,lv,greater_or_equal) + if greater_or_equal=="Equal" then + return function(g) + return (not Auxiliary.RGCheckAdditional or Auxiliary.RGCheckAdditional(g)) and g:GetSum(Auxiliary.RitualCheckAdditionalLevel,c)<=lv + end + else + return function(g,ec) + if ec then + return (not Auxiliary.RGCheckAdditional or Auxiliary.RGCheckAdditional(g,ec)) and g:GetSum(Auxiliary.RitualCheckAdditionalLevel,c)-Auxiliary.RitualCheckAdditionalLevel(ec,c)<=lv + else + return not Auxiliary.RGCheckAdditional or Auxiliary.RGCheckAdditional(g) + end + end + end +end +function Auxiliary.RitualUltimateFilter(c,filter,e,tp,m1,m2,level_function,greater_or_equal,chk) + if bit.band(c:GetType(),0x81)~=0x81 or (filter and not filter(c,e,tp,chk)) or not c:IsCanBeSpecialSummoned(e,SUMMON_TYPE_RITUAL,tp,false,true) then return false end + local mg=m1:Filter(Card.IsCanBeRitualMaterial,c,c) + if m2 then + mg:Merge(m2) + end + if c.mat_filter then + mg=mg:Filter(c.mat_filter,c,tp) + else + mg:RemoveCard(c) + end + local lv=level_function(c) + Auxiliary.GCheckAdditional=Auxiliary.RitualCheckAdditional(c,lv,greater_or_equal) + local res=mg:CheckSubGroup(Auxiliary.RitualCheck,1,lv,tp,c,lv,greater_or_equal) + Auxiliary.GCheckAdditional=nil + return res +end +function Auxiliary.RitualExtraFilter(c,f) + return c:GetLevel()>0 and f(c) and c:IsType(TYPE_MONSTER) and c:IsAbleToRemove() +end +function Auxiliary.RitualUltimateTarget(filter,level_function,greater_or_equal,summon_location,grave_filter,mat_filter,extra_target) + return function(e,tp,eg,ep,ev,re,r,rp,chk) + if chk==0 then + local mg=Duel.GetRitualMaterial(tp) + if mat_filter then mg=mg:Filter(mat_filter,nil,e,tp,true) end + local exg=nil + if grave_filter then + exg=Duel.GetMatchingGroup(Auxiliary.RitualExtraFilter,tp,LOCATION_GRAVE,0,nil,grave_filter) + end + return Duel.IsExistingMatchingCard(Auxiliary.RitualUltimateFilter,tp,summon_location,0,1,nil,filter,e,tp,mg,exg,level_function,greater_or_equal,true) + end + Duel.SetOperationInfo(0,CATEGORY_SPECIAL_SUMMON,nil,1,tp,summon_location) + if grave_filter then + Duel.SetOperationInfo(0,CATEGORY_REMOVE,nil,0,tp,LOCATION_GRAVE) + end + if extra_target then + extra_target(e,tp,eg,ep,ev,re,r,rp) + end + end +end +function Auxiliary.RitualUltimateOperation(filter,level_function,greater_or_equal,summon_location,grave_filter,mat_filter,extra_operation) + return function(e,tp,eg,ep,ev,re,r,rp) + ::RitualUltimateSelectStart:: + local mg=Duel.GetRitualMaterial(tp) + if mat_filter then mg=mg:Filter(mat_filter,nil,e,tp) end + local exg=nil + if grave_filter then + exg=Duel.GetMatchingGroup(Auxiliary.RitualExtraFilter,tp,LOCATION_GRAVE,0,nil,grave_filter) + end + Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_SPSUMMON) + local tg=Duel.SelectMatchingCard(tp,Auxiliary.NecroValleyFilter(Auxiliary.RitualUltimateFilter),tp,summon_location,0,1,1,nil,filter,e,tp,mg,exg,level_function,greater_or_equal) + local tc=tg:GetFirst() + local mat + if tc then + mg=mg:Filter(Card.IsCanBeRitualMaterial,tc,tc) + if exg then + mg:Merge(exg) + end + if tc.mat_filter then + mg=mg:Filter(tc.mat_filter,tc,tp) + else + mg:RemoveCard(tc) + end + Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_RELEASE) + local lv=level_function(tc) + Auxiliary.GCheckAdditional=Auxiliary.RitualCheckAdditional(tc,lv,greater_or_equal) + mat=mg:SelectSubGroup(tp,Auxiliary.RitualCheck,true,1,lv,tp,tc,lv,greater_or_equal) + Auxiliary.GCheckAdditional=nil + if not mat then goto RitualUltimateSelectStart end + tc:SetMaterial(mat) + Duel.ReleaseRitualMaterial(mat) + Duel.BreakEffect() + Duel.SpecialSummon(tc,SUMMON_TYPE_RITUAL,tp,tp,false,true,POS_FACEUP) + tc:CompleteProcedure() + end + if extra_operation then + extra_operation(e,tp,eg,ep,ev,re,r,rp,tc,mat) + end + end +end +--Ritual Summon, geq fixed lv +function Auxiliary.AddRitualProcGreater(c,filter,summon_location,grave_filter,mat_filter,pause,extra_operation,extra_target) + return Auxiliary.AddRitualProcUltimate(c,filter,Card.GetOriginalLevel,"Greater",summon_location,grave_filter,mat_filter,pause,extra_operation,extra_target) +end +function Auxiliary.AddRitualProcGreaterCode(c,code1,summon_location,grave_filter,mat_filter,pause,extra_operation,extra_target) + Auxiliary.AddCodeList(c,code1) + return Auxiliary.AddRitualProcGreater(c,Auxiliary.FilterBoolFunction(Card.IsCode,code1),summon_location,grave_filter,mat_filter,pause,extra_operation,extra_target) +end +--Ritual Summon, equal to fixed lv +function Auxiliary.AddRitualProcEqual(c,filter,summon_location,grave_filter,mat_filter,pause,extra_operation,extra_target) + return Auxiliary.AddRitualProcUltimate(c,filter,Card.GetOriginalLevel,"Equal",summon_location,grave_filter,mat_filter,pause,extra_operation,extra_target) +end +function Auxiliary.AddRitualProcEqualCode(c,code1,summon_location,grave_filter,mat_filter,pause,extra_operation,extra_target) + Auxiliary.AddCodeList(c,code1) + return Auxiliary.AddRitualProcEqual(c,Auxiliary.FilterBoolFunction(Card.IsCode,code1),summon_location,grave_filter,mat_filter,pause,extra_operation,extra_target) +end +--Ritual Summon, equal to monster lv +function Auxiliary.AddRitualProcEqual2(c,filter,summon_location,grave_filter,mat_filter,pause,extra_operation,extra_target) + return Auxiliary.AddRitualProcUltimate(c,filter,Card.GetLevel,"Equal",summon_location,grave_filter,mat_filter,pause,extra_operation,extra_target) +end +function Auxiliary.AddRitualProcEqual2Code(c,code1,summon_location,grave_filter,mat_filter,pause,extra_operation,extra_target) + Auxiliary.AddCodeList(c,code1) + return Auxiliary.AddRitualProcEqual2(c,Auxiliary.FilterBoolFunction(Card.IsCode,code1),summon_location,grave_filter,mat_filter,pause,extra_operation,extra_target) +end +function Auxiliary.AddRitualProcEqual2Code2(c,code1,code2,summon_location,grave_filter,mat_filter,pause,extra_operation,extra_target) + Auxiliary.AddCodeList(c,code1,code2) + return Auxiliary.AddRitualProcEqual2(c,Auxiliary.FilterBoolFunction(Card.IsCode,code1,code2),summon_location,grave_filter,mat_filter,pause,extra_operation,extra_target) +end +--Ritual Summon, geq monster lv +function Auxiliary.AddRitualProcGreater2(c,filter,summon_location,grave_filter,mat_filter,pause,extra_operation,extra_target) + return Auxiliary.AddRitualProcUltimate(c,filter,Card.GetLevel,"Greater",summon_location,grave_filter,mat_filter,pause,extra_operation,extra_target) +end +function Auxiliary.AddRitualProcGreater2Code(c,code1,summon_location,grave_filter,mat_filter,pause,extra_operation,extra_target) + Auxiliary.AddCodeList(c,code1) + return Auxiliary.AddRitualProcGreater2(c,Auxiliary.FilterBoolFunction(Card.IsCode,code1),summon_location,grave_filter,mat_filter,pause,extra_operation,extra_target) +end +function Auxiliary.AddRitualProcGreater2Code2(c,code1,code2,summon_location,grave_filter,mat_filter,pause,extra_operation,extra_target) + Auxiliary.AddCodeList(c,code1,code2) + return Auxiliary.AddRitualProcGreater2(c,Auxiliary.FilterBoolFunction(Card.IsCode,code1,code2),summon_location,grave_filter,mat_filter,pause,extra_operation,extra_target) +end + +--Pendulum Summon +--add procedure to Pendulum monster, also allows registeration of activation effect +function Auxiliary.EnablePendulumAttribute(c,reg) + if not Auxiliary.PendulumChecklist then + Auxiliary.PendulumChecklist=0 + local ge1=Effect.CreateEffect(c) + ge1:SetType(EFFECT_TYPE_FIELD+EFFECT_TYPE_CONTINUOUS) + ge1:SetCode(EVENT_PHASE_START+PHASE_DRAW) + ge1:SetOperation(Auxiliary.PendulumReset) + Duel.RegisterEffect(ge1,0) + end + local e1=Effect.CreateEffect(c) + e1:SetDescription(1163) + e1:SetType(EFFECT_TYPE_FIELD) + e1:SetCode(EFFECT_SPSUMMON_PROC_G) + e1:SetProperty(EFFECT_FLAG_CANNOT_DISABLE+EFFECT_FLAG_UNCOPYABLE) + e1:SetRange(LOCATION_PZONE) + e1:SetCondition(Auxiliary.PendCondition) + e1:SetOperation(Auxiliary.PendOperation) + e1:SetValue(SUMMON_TYPE_PENDULUM) + c:RegisterEffect(e1) + --register by default + if reg==nil or reg then + local e2=Effect.CreateEffect(c) + e2:SetDescription(1160) + e2:SetType(EFFECT_TYPE_ACTIVATE) + e2:SetCode(EVENT_FREE_CHAIN) + e2:SetRange(LOCATION_HAND) + c:RegisterEffect(e2) + end +end +function Auxiliary.PendulumReset(e,tp,eg,ep,ev,re,r,rp) + Auxiliary.PendulumChecklist=0 +end +function Auxiliary.PConditionExtraFilterSpecific(c,e,tp,lscale,rscale,te) + if not te then return true end + local f=te:GetValue() + return not f or f(te,c,e,tp,lscale,rscale) +end +function Auxiliary.PConditionExtraFilter(c,e,tp,lscale,rscale,eset) + for _,te in ipairs(eset) do + if Auxiliary.PConditionExtraFilterSpecific(c,e,tp,lscale,rscale,te) then return true end + end + return false +end +function Auxiliary.PConditionFilter(c,e,tp,lscale,rscale,eset) + local lv=0 + if c.pendulum_level then + lv=c.pendulum_level + else + lv=c:GetLevel() + end + local bool=Auxiliary.PendulumSummonableBool(c) + return (c:IsLocation(LOCATION_HAND) or (c:IsFaceup() and c:IsType(TYPE_PENDULUM))) + and lv>lscale and lvrscale then lscale,rscale=rscale,lscale end + local loc=0 + if Duel.GetLocationCount(tp,LOCATION_MZONE)>0 then loc=loc+LOCATION_HAND end + if Duel.GetLocationCountFromEx(tp,tp,nil,TYPE_PENDULUM)>0 then loc=loc+LOCATION_EXTRA end + if loc==0 then return false end + local g=nil + if og then + g=og:Filter(Card.IsLocation,nil,loc) + else + g=Duel.GetFieldGroup(tp,loc,0) + end + return g:IsExists(Auxiliary.PConditionFilter,1,nil,e,tp,lscale,rscale,eset) +end +function Auxiliary.PendOperationCheck(ft1,ft2,ft) + return function(g) + local exg=g:Filter(Card.IsLocation,nil,LOCATION_EXTRA) + local mg=g-exg + return #g<=ft and #exg<=ft2 and #mg<=ft1 + end +end +function Auxiliary.PendOperation(e,tp,eg,ep,ev,re,r,rp,c,sg,og) + local rpz=Duel.GetFieldCard(tp,LOCATION_PZONE,1) + local lscale=c:GetLeftScale() + local rscale=rpz:GetRightScale() + if lscale>rscale then lscale,rscale=rscale,lscale end + local eset={Duel.IsPlayerAffectedByEffect(tp,EFFECT_EXTRA_PENDULUM_SUMMON)} + local tg=nil + local loc=0 + local ft1=Duel.GetLocationCount(tp,LOCATION_MZONE) + local ft2=Duel.GetLocationCountFromEx(tp,tp,nil,TYPE_PENDULUM) + local ft=Duel.GetUsableMZoneCount(tp) + local ect=c29724053 and Duel.IsPlayerAffectedByEffect(tp,29724053) and c29724053[tp] + if ect and ect0 then ft1=1 end + if ft2>0 then ft2=1 end + ft=1 + end + if ft1>0 then loc=loc|LOCATION_HAND end + if ft2>0 then loc=loc|LOCATION_EXTRA end + if og then + tg=og:Filter(Card.IsLocation,nil,loc):Filter(Auxiliary.PConditionFilter,nil,e,tp,lscale,rscale,eset) + else + tg=Duel.GetMatchingGroup(Auxiliary.PConditionFilter,tp,loc,0,nil,e,tp,lscale,rscale,eset) + end + local ce=nil + local b1=Auxiliary.PendulumChecklist&(0x1<0 + if b1 and b2 then + local options={1163} + for _,te in ipairs(eset) do + table.insert(options,te:GetDescription()) + end + local op=Duel.SelectOption(tp,table.unpack(options)) + if op>0 then + ce=eset[op] + end + elseif b2 and not b1 then + local options={} + for _,te in ipairs(eset) do + table.insert(options,te:GetDescription()) + end + local op=Duel.SelectOption(tp,table.unpack(options)) + ce=eset[op+1] + end + if ce then + tg=tg:Filter(Auxiliary.PConditionExtraFilterSpecific,nil,e,tp,lscale,rscale,ce) + end + Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_SPSUMMON) + Auxiliary.GCheckAdditional=Auxiliary.PendOperationCheck(ft1,ft2,ft) + local g=tg:SelectSubGroup(tp,Auxiliary.TRUE,true,1,math.min(#tg,ft)) + Auxiliary.GCheckAdditional=nil + if not g then return end + if ce then + Duel.Hint(HINT_CARD,0,ce:GetOwner():GetOriginalCode()) + ce:UseCountLimit(tp) + else + Auxiliary.PendulumChecklist=Auxiliary.PendulumChecklist|(0x1<0 +end +function Auxiliary.PSSCompleteProcedure(e,tp,eg,ep,ev,re,r,rp) + local c=e:GetHandler() + if c:IsSummonType(SUMMON_TYPE_PENDULUM) then + c:CompleteProcedure() + end +end + +---Link Summon +---@param c Card +---@param f function|nil +---@param min integer +---@param max? integer +---@param gf? function +---@return Effect +function Auxiliary.AddLinkProcedure(c,f,min,max,gf) + if max==nil then max=c:GetLink() end + local e1=Effect.CreateEffect(c) + e1:SetDescription(1166) + e1:SetType(EFFECT_TYPE_FIELD) + e1:SetCode(EFFECT_SPSUMMON_PROC) + e1:SetProperty(EFFECT_FLAG_CANNOT_DISABLE+EFFECT_FLAG_UNCOPYABLE) + e1:SetRange(LOCATION_EXTRA) + e1:SetCondition(Auxiliary.LinkCondition(f,min,max,gf)) + e1:SetTarget(Auxiliary.LinkTarget(f,min,max,gf)) + e1:SetOperation(Auxiliary.LinkOperation(f,min,max,gf)) + e1:SetValue(SUMMON_TYPE_LINK) + c:RegisterEffect(e1) + return e1 +end +function Auxiliary.LConditionFilter(c,f,lc,e) + return (c:IsFaceup() or not c:IsOnField() or e:IsHasProperty(EFFECT_FLAG_SET_AVAILABLE)) + and c:IsCanBeLinkMaterial(lc) and (not f or f(c)) +end +function Auxiliary.LExtraFilter(c,f,lc,tp) + if c:IsOnField() and c:IsFacedown() then return false end + if not c:IsCanBeLinkMaterial(lc) or f and not f(c) then return false end + local le={c:IsHasEffect(EFFECT_EXTRA_LINK_MATERIAL,tp)} + for _,te in pairs(le) do + local tf=te:GetValue() + local related,valid=tf(te,lc,nil,c,tp) + if related then return true end + end + return false +end +function Auxiliary.GetLinkCount(c) + if c:IsLinkType(TYPE_LINK) and c:GetLink()>1 then + return 1+0x10000*c:GetLink() + else return 1 end +end +function Auxiliary.GetLinkMaterials(tp,f,lc,e) + local mg=Duel.GetMatchingGroup(Auxiliary.LConditionFilter,tp,LOCATION_MZONE,0,nil,f,lc,e) + local mg2=Duel.GetMatchingGroup(Auxiliary.LExtraFilter,tp,LOCATION_HAND+LOCATION_SZONE,LOCATION_ONFIELD,nil,f,lc,tp) + if mg2:GetCount()>0 then mg:Merge(mg2) end + return mg +end +function Auxiliary.LCheckOtherMaterial(c,mg,lc,tp) + local le={c:IsHasEffect(EFFECT_EXTRA_LINK_MATERIAL,tp)} + local res1=false + local res2=true + for _,te in pairs(le) do + local f=te:GetValue() + local related,valid=f(te,lc,mg,c,tp) + if related then res2=false end + if related and valid then res1=true end + end + return res1 or res2 +end +function Auxiliary.LUncompatibilityFilter(c,sg,lc,tp) + local mg=sg:Filter(Auxiliary.TRUE,c) + return not Auxiliary.LCheckOtherMaterial(c,mg,lc,tp) +end +function Auxiliary.LCheckGoal(sg,tp,lc,gf,lmat) + return sg:CheckWithSumEqual(Auxiliary.GetLinkCount,lc:GetLink(),#sg,#sg) + and Duel.GetLocationCountFromEx(tp,tp,sg,lc)>0 and (not gf or gf(sg,lc,tp)) + and not sg:IsExists(Auxiliary.LUncompatibilityFilter,1,nil,sg,lc,tp) + and (not lmat or sg:IsContains(lmat)) +end +function Auxiliary.LExtraMaterialCount(mg,lc,tp) + for tc in Auxiliary.Next(mg) do + local le={tc:IsHasEffect(EFFECT_EXTRA_LINK_MATERIAL,tp)} + for _,te in pairs(le) do + local sg=mg:Filter(Auxiliary.TRUE,tc) + local f=te:GetValue() + local related,valid=f(te,lc,sg,tc,tp) + if related and valid then + te:UseCountLimit(tp) + end + end + end +end +function Auxiliary.LinkCondition(f,minct,maxct,gf) + return function(e,c,og,lmat,min,max) + if c==nil then return true end + if c:IsType(TYPE_PENDULUM) and c:IsFaceup() then return false end + local minc=minct + local maxc=maxct + if min then + if min>minc then minc=min end + if maxmaxc then return false end + end + local tp=c:GetControler() + local mg=nil + if og then + mg=og:Filter(Auxiliary.LConditionFilter,nil,f,c,e) + else + mg=Auxiliary.GetLinkMaterials(tp,f,c,e) + end + if lmat~=nil then + if not Auxiliary.LConditionFilter(lmat,f,c,e) then return false end + mg:AddCard(lmat) + end + local fg=Duel.GetMustMaterial(tp,EFFECT_MUST_BE_LMATERIAL) + if fg:IsExists(Auxiliary.MustMaterialCounterFilter,1,nil,mg) then return false end + Duel.SetSelectedCard(fg) + return mg:CheckSubGroup(Auxiliary.LCheckGoal,minc,maxc,tp,c,gf,lmat) + end +end +function Auxiliary.LinkTarget(f,minct,maxct,gf) + return function(e,tp,eg,ep,ev,re,r,rp,chk,c,og,lmat,min,max) + local minc=minct + local maxc=maxct + if min then + if min>minc then minc=min end + if maxmaxc then return false end + end + local mg=nil + if og then + mg=og:Filter(Auxiliary.LConditionFilter,nil,f,c,e) + else + mg=Auxiliary.GetLinkMaterials(tp,f,c,e) + end + if lmat~=nil then + if not Auxiliary.LConditionFilter(lmat,f,c,e) then return false end + mg:AddCard(lmat) + end + local fg=Duel.GetMustMaterial(tp,EFFECT_MUST_BE_LMATERIAL) + Duel.SetSelectedCard(fg) + Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_LMATERIAL) + local cancel=Duel.IsSummonCancelable() + local sg=mg:SelectSubGroup(tp,Auxiliary.LCheckGoal,cancel,minc,maxc,tp,c,gf,lmat) + if sg then + sg:KeepAlive() + e:SetLabelObject(sg) + return true + else return false end + end +end +function Auxiliary.LinkOperation(f,minct,maxct,gf) + return function(e,tp,eg,ep,ev,re,r,rp,c,og,lmat,min,max) + local g=e:GetLabelObject() + c:SetMaterial(g) + Auxiliary.LExtraMaterialCount(g,c,tp) + Duel.SendtoGrave(g,REASON_MATERIAL+REASON_LINK) + g:DeleteGroup() + end +end + +--Must use X as material +function Auxiliary.MustMaterialCheck(v,tp,code) + local g=Duel.GetMustMaterial(tp,code) + if not v then + if code==EFFECT_MUST_BE_XMATERIAL and Duel.IsPlayerAffectedByEffect(tp,67120578) then return false end + if code==EFFECT_MUST_BE_SMATERIAL and Duel.IsPlayerAffectedByEffect(tp,8173184) then return false end + return #g==0 + end + return Duel.CheckMustMaterial(tp,v,code) +end +function Auxiliary.MustMaterialCounterFilter(c,g) + return not g:IsContains(c) +end + +--Summon Condition +--sp_summon condition for fusion monster +function Auxiliary.fuslimit(e,se,sp,st) + return st&SUMMON_TYPE_FUSION==SUMMON_TYPE_FUSION +end +--sp_summon condition for ritual monster +function Auxiliary.ritlimit(e,se,sp,st) + return st&SUMMON_TYPE_RITUAL==SUMMON_TYPE_RITUAL +end +--sp_summon condition for synchro monster +function Auxiliary.synlimit(e,se,sp,st) + return st&SUMMON_TYPE_SYNCHRO==SUMMON_TYPE_SYNCHRO +end +--sp_summon condition for xyz monster +function Auxiliary.xyzlimit(e,se,sp,st) + return st&SUMMON_TYPE_XYZ==SUMMON_TYPE_XYZ +end +--sp_summon condition for pendulum monster +function Auxiliary.penlimit(e,se,sp,st) + return st&SUMMON_TYPE_PENDULUM==SUMMON_TYPE_PENDULUM +end +--sp_summon condition for link monster +function Auxiliary.linklimit(e,se,sp,st) + return st&SUMMON_TYPE_LINK==SUMMON_TYPE_LINK +end +--sp_summon condition for /Assault Mode +function Auxiliary.AssaultModeLimit(e,se,sp,st) + return st==SUMMON_TYPE_SPECIAL+SUMMON_VALUE_ASSAULT_MODE or se:GetHandler():IsCode(80280737) +end +--sp_summon condition for Masked HERO +function Auxiliary.MaskChangeLimit(e,se,sp,st) + return st==SUMMON_TYPE_SPECIAL+SUMMON_VALUE_MASK_CHANGE or se:GetHandler():IsCode(21143940) +end +--sp_summon condition for Evil HERO +function Auxiliary.DarkFusionLimit(e,se,sp,st) + return se:GetHandler():IsCode(94820406) + or st==SUMMON_VALUE_DARK_FUSION + or (Duel.IsPlayerAffectedByEffect(sp,72043279) and st&SUMMON_TYPE_FUSION==SUMMON_TYPE_FUSION) +end +--sp_summon condition for Fossil +function Auxiliary.FossilFusionLimit(e,se,sp,st) + return st==SUMMON_VALUE_FOSSIL_FUSION or se:GetHandler():IsCode(59419719) + or not e:GetHandler():IsLocation(LOCATION_EXTRA) +end + + + + + + + +FusionSpell = {} + +---@alias FUSION_SPELL_PRE_SELECT_MAT_LOCATION_FUNCTION fun(tc:Card,tp:integer):integer +---@alias FUSION_SPELL_MATFILTER_FUNCTION fun(c:Card,e:Effect,tp:integer):boolean + +--- A check function for Fusion FCheckAdditional/FGoalCheckAdditional. +--- Parameters: +--- • tp integer — player ID (0 or 1) +--- • mg Group — selected materials from fusion spell, exclude materials from Chain Material or EXTRA_FUSION_MATERIAL +--- • fc Card — the Fusion Monster being summoned +--- • mg_all Group — all selected materials +--- • e Effect — the fusion effect object +--- Returns: +--- • boolean — true if the selected materials is a valid group +---@alias FUSION_FGCHECK_FUNCTION fun(tp:integer,mg:Group,fc:Card,mg_all:Group,e:Effect):boolean + +--- @class FusionEffectParams +--- Optional filter to restrict which Fusion Monsters can be summoned. +--- @field fusfilter? fun(c:Card,e:Effect,tp:integer):boolean +--- Optional filter for valid Fusion Materials. +--- Use only under strong constraints (e.g., D-Fusion effects). +--- If some card can not be used even under Chain Material or EXTRA_FUSION_MATERIAL, use this filter. +--- @field matfilter? FUSION_SPELL_MATFILTER_FUNCTION +--- Location(s) to look for materials before knowing which ones will be used. +--- Defaults to `LOCATION_HAND | LOCATION_MZONE`. +--- @field pre_select_mat_location? integer|FUSION_SPELL_PRE_SELECT_MAT_LOCATION_FUNCTION +--- List of operations to perform on materials based on location. +--- Defaults to: +--- ```lua +--- { +--- { [LOCATION_GRAVE] = FusionSpell.FUSION_OPERATION_BANISH }, +--- { [0xff] = FusionSpell.FUSION_OPERATION_GRAVE } +--- } +--- ``` +--- @field mat_operation_code_map? {[integer]:FUSION_OPERATION_CODE}[] +--- Location(s) to look for materials after they've been selected. +--- @field post_select_mat_location? integer +--- Optional quick check to validate the selected material group. +--- @field additional_fcheck? FUSION_FGCHECK_FUNCTION +--- Optional final check to validate the selected material group. +--- @field additional_fgoalcheck? FUSION_FGCHECK_FUNCTION +--- The location to summon Fusion Monsters from. Defaults to `LOCATION_EXTRA`. +--- @field fuslocation? integer +--- The summon type to perform. Defaults to `SUMMON_TYPE_FUSION`. +--- @field sumtype? integer +--- The position to summon the monster in. Defaults to `POS_FACEUP`. +--- @field sumpos? integer +--- Optional callback executed at key stages of the summon process. +--- Example stage: `FusionSpell.STAGE_BEFORE_SUMMON_COMPLETE`. +--- @field stage_x_operation? FUSION_SPELL_STAGE_X_CALLBACK_FUNCTION +--- Optional extra targeting logic (e.g., to show hints or manage chains). +--- @field extra_target? fun(e:Effect, tp:integer, eg:Group, ep:integer, ev:integer, re:Effect, r:integer, rp:integer, chk:integer):nil +--- Opponent-side locations to search for materials before they are selected. +--- @field pre_select_mat_opponent_location? integer|FUSION_SPELL_PRE_SELECT_MAT_LOCATION_FUNCTION +--- Opponent-side locations to search for materials after they are selected. +--- @field post_select_mat_opponent_location? integer +--- Function that returns a card that must be included in the fusion materials +--- @field gc? fun(e:Effect):Card|nil +--- Function that material must pass to be legal as material come from fusion spell +--- Use under weak constraints (e.g., Vision Fusion). +--- If some card can not be used by fusion spell, but could be used with EXTRA_FUSION_MATERIAL, use this filter. +--- Fusion with Chain Material will never call this function, as no material comes from fusion spell. +--- @field fusion_spell_matfilter? FUSION_SPELL_MATFILTER_FUNCTION +--- Whether skip the IsCanBeSpecialSummoned check, for クロック・リザード, default false +--- @field skip_summon_check? boolean +--- Whether skip the location count check, default false, used for 叛逆の堕天使, only works for target function +--- @field skip_location_count_check? boolean + + +--- Add LOCATION_EXTRA and opponent mzone to EFFECT_EXTRA_FUSION_MATERIAL list, remove once core updated +function FusionSpell.GetFusionMaterial(tp,locations) + local res=Duel.GetFusionMaterial(tp,locations) + local g_from_extra=Duel.GetMatchingGroup(Card.IsHasEffect,tp,LOCATION_EXTRA,0,nil,EFFECT_EXTRA_FUSION_MATERIAL) + if #g_from_extra>0 then + res:Merge(g_from_extra) + end + local g_from_opponent_field=Duel.GetMatchingGroup(Card.IsHasEffect,tp,0,LOCATION_ONFIELD,nil,EFFECT_EXTRA_FUSION_MATERIAL) + if #g_from_opponent_field>0 then + res:Merge(g_from_opponent_field) + end + return res +end + +--- Workaround for IsCanBeFusionMaterial, remove once core fixes +--- @param c Card +--- @param tc Card +--- @param sumtype? integer +function FusionSpell.IsCanBeFusionMaterial(c,tc,sumtype) + sumtype=sumtype or SUMMON_TYPE_FUSION + --- Prohibition will prevent card to be fusion material + if c:IsForbidden()==true then + return false + end + local can_not_be_fusion_material_effects={c:IsHasEffect(EFFECT_CANNOT_BE_FUSION_MATERIAL)} + for _,effect in ipairs(can_not_be_fusion_material_effects) do + local value=effect:GetValue() + if value~=nil then + if type(value)=='function' and value(effect,tc,sumtype)==true then + return false + elseif value==1 or value==true then + return false + end + end + end + return true +end + +--- Get possible materials from opponent locations, must be face-up +function FusionSpell.GetFusionMaterialFromOpponentLocation(tp,locations) + return Duel.GetMatchingGroup(Card.IsFaceupEx,tp,0,locations,nil) +end + +--- Registers a Fusion Summon effect to a card. +--- @param c Card -- The card to register the effect to. +--- @param opts? FusionEffectParams +--- @return Effect -- The registered effect object. +function FusionSpell.RegisterSummonEffect(c,opts) + local e1 = FusionSpell.CreateSummonEffect(c,opts) + Card.RegisterEffect(c, e1) + return e1 +end + +--- Creates and returns a Fusion Summon effect, attached to the specified card. +--- Accepts a table of named parameters to configure the effect behavior. +--- +--- @param opts? FusionEffectParams Named options table. +--- @return Effect The created and configured `Effect` object. +function FusionSpell.CreateSummonEffect(c,opts) + opts=opts or {} + local fusfilter=opts.fusfilter or aux.TRUE + local matfilter=opts.matfilter or aux.TRUE + local pre_select_mat_location=opts.pre_select_mat_location or (LOCATION_HAND|LOCATION_MZONE) + local mat_operation_code_map=opts.mat_operation_code_map or {} + local post_select_mat_location=opts.post_select_mat_location or 0 + local additional_fcheck=opts.additional_fcheck or aux.TRUE + local additional_fgoalcheck=opts.additional_fgoalcheck or aux.TRUE + local fuslocation=opts.fuslocation or LOCATION_EXTRA + local sumtype=opts.sumtype or SUMMON_TYPE_FUSION + local sumpos=opts.sumpos or POS_FACEUP + local stage_x_operation=opts.stage_x_operation or aux.TRUE + local extra_target=opts.extra_target or aux.TRUE + local pre_select_mat_opponent_location=opts.pre_select_mat_opponent_location or 0 + local post_select_mat_opponent_location=opts.post_select_mat_opponent_location or 0 + local gc=opts.gc or function() return nil end + local fusion_spell_matfilter=opts.fusion_spell_matfilter or aux.TRUE + local skip_summon_check=opts.skip_summon_check or false + local skip_location_count_check=opts.skip_location_count_check or false + + -- Ensure material operation fallbacks are present + table.insert(mat_operation_code_map,{ [LOCATION_GRAVE] = FusionSpell.FUSION_OPERATION_BANISH }) + table.insert(mat_operation_code_map,{ [0xff] = FusionSpell.FUSION_OPERATION_GRAVE }) + + -- Build and return the effect + local e1 = Effect.CreateEffect(c) + e1:SetCategory(CATEGORY_SPECIAL_SUMMON+CATEGORY_FUSION_SUMMON) + e1:SetType(EFFECT_TYPE_ACTIVATE) + e1:SetCode(EVENT_FREE_CHAIN) + e1:SetTarget(FusionSpell.GetSummonTarget( + fusfilter, + matfilter, + pre_select_mat_location, + mat_operation_code_map, + post_select_mat_location, + additional_fcheck, + additional_fgoalcheck, + fuslocation, + sumtype, + sumpos, + extra_target, + pre_select_mat_opponent_location, + post_select_mat_opponent_location, + gc, + fusion_spell_matfilter, + skip_summon_check, + skip_location_count_check + )) + e1:SetOperation(FusionSpell.GetSummonOperation( + fusfilter, + matfilter, + pre_select_mat_location, + mat_operation_code_map, + post_select_mat_location, + additional_fcheck, + additional_fgoalcheck, + fuslocation, + sumtype, + sumpos, + stage_x_operation, + pre_select_mat_opponent_location, + post_select_mat_opponent_location, + gc, + fusion_spell_matfilter, + skip_summon_check + )) + e1:SetDescription(1169) --- 融合召喚 + return e1 +end + +---@param fusfilter fun(c:Card,e:Effect,tp:integer):boolean filter for the monster to be Fusion Summoned +---@param matfilter FUSION_SPELL_MATFILTER_FUNCTION filter for the materials, use it only under very strong limitation like D-Fusion. +---@param pre_select_mat_location integer|FUSION_SPELL_PRE_SELECT_MAT_LOCATION_FUNCTION location where to find the materials before known the materials +---@param mat_operation_code_map {[integer]:FUSION_OPERATION_CODE}[] operation code to do for the materials, it will be check in order +---@param post_select_mat_location integer location where to find the materials after known the materials +---@param additional_fcheck FUSION_FGCHECK_FUNCTION function to check the partial material group fits the requirement +---@param additional_fgoalcheck FUSION_FGCHECK_FUNCTION function to check the final material group fits the requirement +---@param fuslocation integer location where to summon fusion monsters from (default LOCATION_EXTRA), use it on Clock Lizard +---@param sumtype integer summon type +---@param sumpos integer summon position +---@param extra_target fun(e:Effect, tp:integer, eg:Group, ep:integer, ev:integer, re:Effect, r:integer, rp:integer, chk:integer):nil extra target function to add opration info etc +---@param pre_select_mat_opponent_location integer|FUSION_SPELL_PRE_SELECT_MAT_LOCATION_FUNCTION location where to find the materials before known the materials on opponent location +---@param post_select_mat_opponent_location integer location where to find the materials after known the materials on opponent location +---@param gc fun(e:Effect):Card|nil Function that returns a card that must be included in the fusion materials +---@param fusion_spell_matfilter FUSION_SPELL_MATFILTER_FUNCTION a material must pass this to be legal as material come from fusion spell +---@param skip_summon_check boolean whether skip the IsCanBeSpecialSummoned check, for クロック・リザード +---@param skip_location_count_check boolean Whether skip the location count check, default false, used for 叛逆の堕天使 +function FusionSpell.GetSummonTarget( + fusfilter, + matfilter, + pre_select_mat_location, + mat_operation_code_map, + post_select_mat_location, + additional_fcheck, + additional_fgoalcheck, + fuslocation, + sumtype, + sumpos, + extra_target, + pre_select_mat_opponent_location, + post_select_mat_opponent_location, + gc, + fusion_spell_matfilter, + skip_summon_check, + skip_location_count_check + ) + return function(e,tp,eg,ep,ev,re,r,rp,chk) + if chk==0 then + if extra_target(e,tp,eg,ep,ev,re,r,rp,chk)==false then + return false + end + local sg=Duel.IsExistingMatchingCard(function(c) + return FusionSpell.SummonTargetFilter( + c, + fusfilter, + matfilter, + e, + tp, + pre_select_mat_location, + mat_operation_code_map, + post_select_mat_location, + additional_fcheck, + additional_fgoalcheck, + sumtype,sumpos, + pre_select_mat_opponent_location, + post_select_mat_opponent_location, + gc, + fusion_spell_matfilter, + skip_summon_check, + skip_location_count_check) + end, + tp,fuslocation,0,1,nil) + if sg==true then + return true + end + -- --- check for chain material targets + if sumtype&SUMMON_TYPE_FUSION~=0 then + local ce_sg=FusionSpell.IsExistsChainMaterialSummonTargets(e,tp,fusfilter,matfilter,additional_fcheck,additional_fgoalcheck,fuslocation,sumtype,sumpos,gc,skip_summon_check,skip_location_count_check) + if ce_sg==true then + return true + end + end + return false + end + Duel.SetOperationInfo(0,CATEGORY_SPECIAL_SUMMON,nil,1,tp,fuslocation) + extra_target(e,tp,eg,ep,ev,re,r,rp,chk) + end +end + +---@param fusfilter fun(c:Card,e:Effect,tp:integer):boolean filter for the monster to be Fusion Summoned +---@param matfilter FUSION_SPELL_MATFILTER_FUNCTION filter for the materials, use it only under very strong limitation like D-Fusion. +---@param pre_select_mat_location integer|FUSION_SPELL_PRE_SELECT_MAT_LOCATION_FUNCTION location where to find the materials before known the materials +---@param mat_operation_code_map {[integer]:FUSION_OPERATION_CODE}[] operation code to do for the materials, it will be check in order +---@param post_select_mat_location integer location where to find the materials after known the materials +---@param additional_fcheck FUSION_FGCHECK_FUNCTION function to check the partial material group fits the requirement +---@param additional_fgoalcheck FUSION_FGCHECK_FUNCTION function to check the final material group fits the requirement +---@param fuslocation integer location where to summon fusion monsters from, use it on Clock Lizard +---@param sumtype integer summon type +---@param sumpos integer summon position +---@param stage_x_operation function callback function when special summon is in progress. will be called with different stage name +---@param pre_select_mat_opponent_location integer|FUSION_SPELL_PRE_SELECT_MAT_LOCATION_FUNCTION location where to find the materials before known the materials on opponent location +---@param post_select_mat_opponent_location integer location where to find the materials after known the materials on opponent location +---@param gc fun(e:Effect):Card|nil Function that returns a card that must be included in the fusion materials +---@param fusion_spell_matfilter FUSION_SPELL_MATFILTER_FUNCTION a material must pass this to be legal as material come from fusion spell +---@param skip_summon_check boolean whether skip the IsCanBeSpecialSummoned check, for クロック・リザード +function FusionSpell.GetSummonOperation( + fusfilter, + matfilter, + pre_select_mat_location, + mat_operation_code_map, + post_select_mat_location, + additional_fcheck, + additional_fgoalcheck, + fuslocation, + sumtype, + sumpos, + stage_x_operation, + pre_select_mat_opponent_location, + post_select_mat_opponent_location, + gc, + fusion_spell_matfilter, + skip_summon_check + ) + return function(e,tp,eg,ep,ev,re,r,rp) + local tc=nil + -- if gc is gone, terminate + if gc(e)==nil or gc(e):IsRelateToEffect(e) or e:GetHandler()~=gc(e) then + local fusion_targets=Group.CreateGroup() + local sg=Duel.GetMatchingGroup(function(c) + return FusionSpell.SummonTargetFilter( + c, + fusfilter, + aux.NecroValleyFilter(matfilter), + e, + tp, + pre_select_mat_location, + mat_operation_code_map, + post_select_mat_location, + additional_fcheck, + additional_fgoalcheck, + sumtype,sumpos, + pre_select_mat_opponent_location, + post_select_mat_opponent_location, + gc, + fusion_spell_matfilter, + skip_summon_check, + false --[[skip_location_count_check]]) + end, + tp,fuslocation,0,nil) + fusion_targets:Merge(sg) + --- check for chain material targets + local ce_sgs={} + if sumtype&SUMMON_TYPE_FUSION~=0 then + ce_sgs=FusionSpell.ListChainMaterialSummonTargets(e,tp,fusfilter,aux.NecroValleyFilter(matfilter),additional_fcheck,additional_fgoalcheck,fuslocation,sumtype,sumpos,gc,skip_summon_check,false--[[skip_location_count_check]]) + --- add chain material targets + for _,ce_sg in pairs(ce_sgs) do + fusion_targets:Merge(ce_sg) + end + end + + if #fusion_targets>0 then + local materials=Group.CreateGroup() + local fusion_effect=nil + local fusion_succeeded=false + + while #materials==0 do + Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_SPSUMMON) + + tc=fusion_targets:Select(tp,1,1,nil):GetFirst() + + ---@type Effect[] + local avaliable_fusion_effect = {} + if sg:IsContains(tc) then + table.insert(avaliable_fusion_effect,e) + end + for ce, ce_sg in pairs(ce_sgs) do + if ce_sg:IsContains(tc) then + table.insert(avaliable_fusion_effect,ce) + end + end + assert(#avaliable_fusion_effect>0, "Selected a target card that has 0 fusion effect") + fusion_effect=avaliable_fusion_effect[1] + if #avaliable_fusion_effect>1 then + fusion_effect=FusionSpell.MultiFusionEffectPrompt(avaliable_fusion_effect,tp) + end + if fusion_effect==e then + --- use fusion spell effect + local mg=FusionSpell.GetMaterialsGroupForTargetCard( + tc, + tp, + e, + aux.NecroValleyFilter(matfilter), + pre_select_mat_location, + mat_operation_code_map, + post_select_mat_location, + sumtype, + pre_select_mat_opponent_location, + post_select_mat_opponent_location, + fusion_spell_matfilter) + aux.FCheckAdditional=FusionSpell.GetFusionSpellFCheckAdditionalFunction( + additional_fcheck, + tp, + tc, + pre_select_mat_location, + post_select_mat_location, + pre_select_mat_opponent_location, + post_select_mat_opponent_location, + fusion_spell_matfilter, + e, + mat_operation_code_map) + aux.FGoalCheckAdditional=FusionSpell.GetFusionSpellFGoalCheckAdditionalFunction(additional_fgoalcheck,tp,tc,pre_select_mat_location,e) + materials=Duel.SelectFusionMaterial(tp,tc,mg,gc(e),tp) + aux.FCheckAdditional=nil + aux.FGoalCheckAdditional=nil + else + --- use chain material effect + ---@type function + local chain_material_filter=fusion_effect:GetTarget() + local chain_mg=chain_material_filter(fusion_effect,e,tp):Filter(aux.NecroValleyFilter(function(c) return matfilter(c,e,tp) end),nil) + assert(#chain_mg>0, "we are trying to apply a chain material, but it has no possible material") + aux.FCheckAdditional=FusionSpell.GetFusionSpellFCheckAdditionalFunctionForChainMaterial(additional_fcheck,e) + aux.FGoalCheckAdditional=FusionSpell.GetFusionSpellFGoalCheckAdditionalFunctionForChainMaterial(additional_fgoalcheck,e) + materials=Duel.SelectFusionMaterial(tp,tc,chain_mg,gc(e),tp) + aux.FCheckAdditional=nil + aux.FGoalCheckAdditional=nil + end + end + + assert(tc~=nil) + assert(fusion_effect~=nil) + + if #materials>0 then + local materials_from_spell_card=Group.CreateGroup() + if fusion_effect==e then + --- fusion with fusion spell + tc:SetMaterial(materials) + ---@type {[Effect]:true} + local applied_extra_effects={} + ---@type {[FUSION_OPERATION_FUNCTION]:Group} + local material_grouped_by_op={} + + local materials_with_one_material_effect=materials:Filter(function(mc) + return (#FusionSpell.GetMaterialEffects(mc,tp,tc,pre_select_mat_location,post_select_mat_location,pre_select_mat_opponent_location,post_select_mat_opponent_location,fusion_spell_matfilter,e,mat_operation_code_map))==1 + end,nil) + for material in aux.Next(materials_with_one_material_effect) do + --For material that can be material only by 1 effect, either fusion spell or extra material effect, do the operation on it. + local fusion_operation=nil + local material_effect=FusionSpell.GetMaterialEffects( + material, + tp, + tc, + pre_select_mat_location, + post_select_mat_location, + pre_select_mat_opponent_location, + post_select_mat_opponent_location, + fusion_spell_matfilter, + e, + mat_operation_code_map)[1] + + if material_effect==true then + local fusion_operation_code=FusionSpell.GetOperationCodeByMaterialLocation(material:GetLocation(),mat_operation_code_map) + fusion_operation=FusionSpell.GetFusionOperationByCode(fusion_operation_code) + materials_from_spell_card:AddCard(material) + else + -- extra material effects + --- pay the operation cost, only valid in 影牢の呪縛 as of 2025 May + local material_cost=material_effect:GetCost() + if material_cost~=nil then + material_cost(material_effect,tp,eg,ep,ev,re,r,rp) + end + local fusion_operation_code=material_effect:GetOperation()() + fusion_operation=FusionSpell.GetFusionOperationByCode(fusion_operation_code,material:GetLocation(),mat_operation_code_map) + applied_extra_effects[material_effect]=true + end + + assert(fusion_operation~=nil) + material_grouped_by_op[fusion_operation]=material_grouped_by_op[fusion_operation] or Group.CreateGroup() + material_grouped_by_op[fusion_operation]:AddCard(material) + end + local materials_with_two_material_effect=materials:Filter(function(mc) + return (#FusionSpell.GetMaterialEffects(mc,tp,tc,pre_select_mat_location,post_select_mat_location,pre_select_mat_opponent_location,post_select_mat_opponent_location,fusion_spell_matfilter,e,mat_operation_code_map))==2 + end,nil) + assert(#materials_with_one_material_effect+#materials_with_two_material_effect==#materials, "We can not have one material have zero/3+ material effect yet") + --For material that can be material by multiple effect, ask user which to apply. + --As of 2025 May, if a material could be used as extra material, it must be able to be used as fusion spell material. The code below is based on this assumption. + -- If we have Aiラブ融合 + 影牢の呪縛 or 多層融合 + アマゾネスの秘術 in same archetype, is code would fail in some scenario. + --First, group them by extra_material_effect + ---@type {[Effect]:Group} + local material_grouped_by_extra_material_effect={} + for material in aux.Next(materials_with_two_material_effect) do + local material_effect=FusionSpell.GetExtraMaterialEffect(material,tp,tc,pre_select_mat_location) + assert(material_effect~=nil, "We can not have a material w/o extra material effect when it has 2 options") + material_grouped_by_extra_material_effect[material_effect]=material_grouped_by_extra_material_effect[material_effect] or Group.CreateGroup() + material_grouped_by_extra_material_effect[material_effect]:AddCard(material) + end + + ---For each group, let user select the material that apply the extra material effect. + for material_effect,grouped_materials in pairs(material_grouped_by_extra_material_effect) do + Duel.Hint(HINT_SELECTMSG,tp,material_effect:GetDescription()) + local extra_material_limit=#grouped_materials + --- in case of アマゾネスの秘術 or 影牢の呪縛, limit the maximuim number to choose + local material_effect_material_count_limit=({material_effect:GetLabel()})[1] + if material_effect_material_count_limit~= 0 then + extra_material_limit=material_effect_material_count_limit + end + local materials_to_apply=grouped_materials:Select(tp,0,extra_material_limit,nil) + local rest_materials=grouped_materials-materials_to_apply + if #rest_materials>0 then + for material in aux.Next(rest_materials) do + local fusion_operation_code=FusionSpell.GetOperationCodeByMaterialLocation(material:GetLocation(),mat_operation_code_map) + local fusion_operation=FusionSpell.GetFusionOperationByCode(fusion_operation_code) + material_grouped_by_op[fusion_operation]=material_grouped_by_op[fusion_operation] or Group.CreateGroup() + material_grouped_by_op[fusion_operation]:AddCard(material) + materials_from_spell_card:AddCard(material) + end + end + if #materials_to_apply>0 then + applied_extra_effects[material_effect]=true + local fusion_operation_code=material_effect:GetOperation()() + for material in aux.Next(materials_to_apply) do + local fusion_operation=FusionSpell.GetFusionOperationByCode(fusion_operation_code,material:GetLocation(),mat_operation_code_map) + assert(fusion_operation~=nil) + --- pay the operation cost, only valid in 影牢の呪縛 as of 2025 May + local material_cost=material_effect:GetCost() + if material_cost~=nil then + material_cost(material_effect,tp,eg,ep,ev,re,r,rp) + end + material_grouped_by_op[fusion_operation]=material_grouped_by_op[fusion_operation] or Group.CreateGroup() + material_grouped_by_op[fusion_operation]:AddCard(material) + end + end + end + + if stage_x_operation(e,tc,tp,FusionSpell.STAGE_BEFORE_MOVE_MATERIAL,materials_from_spell_card,materials)~=false then + -- before do the operations to the materials, hint the opponent selected materials + local confirm_materials=materials:Filter(function(c) return c:IsLocation(LOCATION_HAND|LOCATION_EXTRA|LOCATION_DECK) or c:IsFacedown() end,nil) + if #confirm_materials>0 then + Duel.ConfirmCards(1-tp,confirm_materials) + end + Duel.HintSelection(materials-confirm_materials) + + local operated_material_count=0 + -- perform operations on grouped materials + for operation,grouped_materials in pairs(material_grouped_by_op) do + operated_material_count=operated_material_count+operation(grouped_materials,tp) + end + + -- mark effect as used once. if count limit reached, reset the effect + for effect,_ in pairs(applied_extra_effects) do + --- hint opponent that this effect is applied + Duel.Hint(HINT_OPSELECTED,1-tp,effect:GetDescription()) + effect:UseCountLimit(tp) + if effect:CheckCountLimit(tp)==false then + effect:Reset() + end + end + + -- check if all materials are moved successfully (ラピッド・トリガー) + fusion_succeeded=(operated_material_count==#materials) + + if fusion_succeeded==true then + Duel.BreakEffect() + Duel.SpecialSummonStep(tc,sumtype,tp,tp,false,false,sumpos) + end + end + else + if stage_x_operation(e,tc,tp,FusionSpell.STAGE_BEFORE_MOVE_MATERIAL,materials_from_spell_card,materials)~=false then + --- hint opponent that this effect is applied + Duel.Hint(HINT_OPSELECTED,1-tp,fusion_effect:GetDescription()) + + --- fusion with chain material + fusion_effect:GetOperation()(e,e,tp,tc,materials,sumtype,sumpos) + --- use the chain material effect, reset if exhausted + fusion_effect:UseCountLimit(tp) + if fusion_effect:CheckCountLimit(tp)==false then + fusion_effect:Reset() + end + + -- for chain material effects as of 2025 May it always succeeds + fusion_succeeded=true + end + + end + + if fusion_succeeded==true then + stage_x_operation(e,tc,tp,FusionSpell.STAGE_BEFORE_SUMMON_COMPLETE,materials_from_spell_card,materials) + Duel.SpecialSummonComplete() + stage_x_operation(e,tc,tp,FusionSpell.STAGE_BEFORE_PROCEDURE_COMPLETE,materials_from_spell_card,materials) + tc:CompleteProcedure() + stage_x_operation(e,tc,tp,FusionSpell.STAGE_AT_SUMMON_OPERATION_FINISH,materials_from_spell_card,materials) + end + end + end + end + stage_x_operation(e,tc,tp,FusionSpell.STAGE_AT_ALL_OPERATION_FINISH) + end +end + +---@param pre_select_mat_location integer|FUSION_SPELL_PRE_SELECT_MAT_LOCATION_FUNCTION location where to find the materials before known the materials +---@param post_select_mat_location integer location where to find the materials after known the materials +---@return integer locations all possible locations of the material +function FusionSpell.GetAllLocationsForTargetCard(tc,tp,pre_select_mat_location,post_select_mat_location) + local all_locations=0 + if type(pre_select_mat_location)=="function" then + all_locations=all_locations|pre_select_mat_location(tc,tp) + else + all_locations=all_locations|pre_select_mat_location + end + all_locations=all_locations|post_select_mat_location + return all_locations +end + +---@param tc Card the target card to summon +---@param tp integer the triggering player +---@param e Effect the fusion effect +---@param matfilter FUSION_SPELL_MATFILTER_FUNCTION filter for the materials, use it only under very strong limitation like D-Fusion. +---@param pre_select_mat_location integer|FUSION_SPELL_PRE_SELECT_MAT_LOCATION_FUNCTION location where to find the materials before known the materials +---@param mat_operation_code_map {[integer]:FUSION_OPERATION_CODE}[] operation code to do for the materials, it will be check in order +---@param post_select_mat_location integer location where to find the materials after known the materials +---@param sumtype integer summon type +---@param pre_select_mat_opponent_location integer|FUSION_SPELL_PRE_SELECT_MAT_LOCATION_FUNCTION location where to find the materials before known the materials on opponent location +---@param post_select_mat_opponent_location integer location where to find the materials after known the materials on opponent location +---@param fusion_spell_matfilter FUSION_SPELL_MATFILTER_FUNCTION a material must pass this to be legal as material come from fusion spell +function FusionSpell.GetMaterialsGroupForTargetCard( + tc, + tp, + e, + matfilter, + pre_select_mat_location, + mat_operation_code_map, + post_select_mat_location, + sumtype, + pre_select_mat_opponent_location, + post_select_mat_opponent_location, + fusion_spell_matfilter + ) + local all_locations=FusionSpell.GetAllLocationsForTargetCard(tc,tp,pre_select_mat_location,post_select_mat_location) + local mg=FusionSpell.GetFusionMaterial(tp,all_locations) + local calculated_mat_opponent_location=FusionSpell.GetAllLocationsForTargetCard(tc,tp,pre_select_mat_opponent_location,post_select_mat_opponent_location) + local opponent_mg=FusionSpell.GetFusionMaterialFromOpponentLocation(tp,calculated_mat_opponent_location) + if #opponent_mg>0 then + mg:Merge(opponent_mg) + end + + --- filter by the strong material filter, target card can not be fusion material of itself + mg=mg:Filter(function(c) return matfilter(c,e,tp) end,tc) + --- filter out card can not be affected by effect + mg=mg:Filter(aux.NOT(Card.IsImmuneToEffect),nil,e) + --- filter out card that are facedown banished + mg=mg:Filter(function(c) return not(c:IsLocation(LOCATION_REMOVED) and c:IsFacedown()) end,nil) + --- filter out card can not be material + --- comment out, currently core can not return correct value if affected by EFFECT_EXTRA_FUSION_MATERIAL. + --mg=mg:Filter(Card.IsCanBeFusionMaterial,nil,tc,sumtype) + --- workaround until core fixes + mg=mg:Filter(function(mc) return FusionSpell.IsCanBeFusionMaterial(mc,tc,sumtype) end,nil) + --- a material must come from at least one source, either from fusion spell or EXTRA_FUSION_MATERIAL + mg=mg:Filter(function(mc) + local effects=FusionSpell.GetMaterialEffects(mc,tp,tc,pre_select_mat_location,post_select_mat_location,pre_select_mat_opponent_location,post_select_mat_opponent_location,fusion_spell_matfilter,e,mat_operation_code_map) + if #effects<1 then + return false + end + return true + end,nil) + return mg +end + +---@param location integer +---@param mat_operation_code_map {[integer]:FUSION_OPERATION_CODE}[] operation code to do for the materials, it will be check in order +function FusionSpell.GetOperationCodeByMaterialLocation(location,mat_operation_code_map) + for _,map in ipairs(mat_operation_code_map) do + for key,value in pairs(map) do + if location&key~=0 then + return value + end + end + end +end + +---@param c Card the candidate card to summon +---@param fusfilter fun(c:Card,e:Effect,tp:integer):boolean +---@param matfilter FUSION_SPELL_MATFILTER_FUNCTION filter for the materials, use it only under very strong limitation like D-Fusion. +---@param pre_select_mat_location integer|FUSION_SPELL_PRE_SELECT_MAT_LOCATION_FUNCTION location where to find the materials before known the materials (default LOCATION_HAND|LOCATION_MZONE) +---@param post_select_mat_location integer location where to find the materials after known the materials +---@param pre_select_mat_opponent_location integer|FUSION_SPELL_PRE_SELECT_MAT_LOCATION_FUNCTION location where to find the materials before known the materials on opponent location +---@param post_select_mat_opponent_location integer location where to find the materials before known the materials on opponent location +---@param gc fun(e:Effect):Card|nil +---@param fusion_spell_matfilter fun(c:Card):boolean a material must pass this to be legal as material come from fusion spell +---@param skip_summon_check boolean whether skip the IsCanBeSpecialSummoned check, for クロック・リザード +---@param skip_location_count_check boolean Whether skip the location count check, default false, used for 叛逆の堕天使 +function FusionSpell.SummonTargetFilter( + c, + fusfilter, + matfilter, + e, + tp, + pre_select_mat_location, + mat_operation_code_map, + post_select_mat_location, + additional_fcheck, + additional_fgoalcheck, + sumtype, + sumpos, + pre_select_mat_opponent_location, + post_select_mat_opponent_location, + gc, + fusion_spell_matfilter, + skip_summon_check, + skip_location_count_check) + if not c:IsType(TYPE_FUSION) or fusfilter(c,e,tp)==false then + return false + end + if not skip_summon_check then + if not c:IsCanBeSpecialSummoned(e,sumtype,tp,false,false,sumpos) then + return false + end + end + local mg=FusionSpell.GetMaterialsGroupForTargetCard( + c, + tp, + e, + matfilter, + pre_select_mat_location, + mat_operation_code_map, + post_select_mat_location, + sumtype, + pre_select_mat_opponent_location, + post_select_mat_opponent_location, + fusion_spell_matfilter) + aux.FCheckAdditional=FusionSpell.GetFusionSpellFCheckAdditionalFunction( + additional_fcheck, + tp, + c, + pre_select_mat_location, + post_select_mat_location, + pre_select_mat_opponent_location, + post_select_mat_opponent_location, + fusion_spell_matfilter, + e, + mat_operation_code_map) + aux.FGoalCheckAdditional=FusionSpell.GetFusionSpellFGoalCheckAdditionalFunction(additional_fgoalcheck,tp,c,pre_select_mat_location,e) + local chkf=FusionSpell.GetCheckFieldPlayer(tp,skip_location_count_check) + local res=c:CheckFusionMaterial(mg,gc(e),chkf) + aux.FCheckAdditional=nil + aux.FGoalCheckAdditional=nil + return res +end + +---@param matfilter FUSION_SPELL_MATFILTER_FUNCTION filter for the materials, use it only under very strong limitation like D-Fusion. +---@param gc fun(e:Effect):Card|nil +---@param skip_summon_check boolean whether skip the IsCanBeSpecialSummoned check, for クロック・リザード +---@param skip_location_count_check boolean Whether skip the location count check, default false, used for 叛逆の堕天使 +---@return {[Effect]:Group} effect_targets_map Return a map of different chain material to potiential fusion targets +function FusionSpell.ListChainMaterialSummonTargets(e,tp,fusfilter,matfilter,additional_fcheck,additional_fgoalcheck,fuslocation,sumtype,sumpos,gc,skip_summon_check,skip_location_count_check) + local chain_material_effects={Duel.IsPlayerAffectedByEffect(tp,EFFECT_CHAIN_MATERIAL)} + ---@type {[Effect]:Group} + local chain_material_targets={} + for _,ce in ipairs(chain_material_effects) do + ---@type function + local chain_material_filter=ce:GetTarget() + ---@type Group + local chain_mg=chain_material_filter(ce,e,tp):Filter(function(c) return matfilter(c,e,tp) end,nil) + if #chain_mg>0 then + local ce_fusfilter=ce:GetValue() + local ce_sg=Duel.GetMatchingGroup(function(c) + return FusionSpell.ChainMaterialSummonTargetFilter(c,aux.AND(ce_fusfilter,fusfilter),e,tp,chain_mg,additional_fcheck,additional_fgoalcheck,sumtype,sumpos,gc,skip_summon_check,skip_location_count_check) + end,tp,fuslocation,0,nil) + if #ce_sg>0 then + chain_material_targets[ce]=ce_sg + end + end + end + return chain_material_targets +end + +---@param fusfilter fun(c:Card,e:Effect,tp:integer):boolean +---@param matfilter FUSION_SPELL_MATFILTER_FUNCTION filter for the materials, use it only under very strong limitation like D-Fusion. +---@param gc fun(e:Effect):Card|nil +---@param skip_summon_check boolean whether skip the IsCanBeSpecialSummoned check, for クロック・リザード +---@param skip_location_count_check boolean Whether skip the location count check, default false, used for 叛逆の堕天使 +---@return boolean res return whether there is a valid target for any chain material effect +function FusionSpell.IsExistsChainMaterialSummonTargets(e,tp,fusfilter,matfilter,additional_fcheck,additional_fgoalcheck,fuslocation,sumtype,sumpos,gc,skip_summon_check,skip_location_count_check) + local chain_material_effects={Duel.IsPlayerAffectedByEffect(tp,EFFECT_CHAIN_MATERIAL)} + ---@type {[Effect]:Group} + for _,ce in ipairs(chain_material_effects) do + ---@type function + local chain_material_filter=ce:GetTarget() + local chain_mg=chain_material_filter(ce,e,tp):Filter(function(c) return matfilter(c,e,tp) end,nil) + if #chain_mg>0 then + local ce_fusfilter=ce:GetValue() + local res=Duel.IsExistingMatchingCard(function(c) + return FusionSpell.ChainMaterialSummonTargetFilter(c,aux.AND(ce_fusfilter,fusfilter or aux.TRUE),e,tp,chain_mg,additional_fcheck,additional_fgoalcheck,sumtype,sumpos,gc,skip_summon_check,skip_location_count_check) + end, + tp,fuslocation,0,1,nil) + if res==true then + return res + end + end + end + return false +end + +---@param c Card +---@param fusfilter fun(c:Card,e:Effect,tp:integer):boolean +---@param gc fun(e:Effect):Card|nil +---@param skip_summon_check boolean whether skip the IsCanBeSpecialSummoned check, for クロック・リザード +---@param skip_location_count_check boolean Whether skip the location count check, default false, used for 叛逆の堕天使 +---@return boolean result Whether c could be fusion summoned by this chain material effect +function FusionSpell.ChainMaterialSummonTargetFilter(c,fusfilter,e,tp,mg,additional_fcheck,additional_fgoalcheck,sumtype,sumpos,gc,skip_summon_check,skip_location_count_check) + if not c:IsType(TYPE_FUSION) or fusfilter(c,e,tp)==false then + return false + end + if not skip_summon_check then + if not c:IsCanBeSpecialSummoned(e,sumtype,tp,false,false,sumpos) then + return false + end + end + aux.FCheckAdditional=FusionSpell.GetFusionSpellFCheckAdditionalFunctionForChainMaterial(additional_fcheck,e) + aux.FGoalCheckAdditional=FusionSpell.GetFusionSpellFGoalCheckAdditionalFunctionForChainMaterial(additional_fgoalcheck,e) + local chkf=FusionSpell.GetCheckFieldPlayer(tp,skip_location_count_check) + local res=c:CheckFusionMaterial(mg,gc(e),chkf) + aux.FCheckAdditional=nil + aux.FGoalCheckAdditional=nil + return res +end + +---@alias FUSION_SPELL_STAGE_X_CALLBACK_FUNCTION fun(e:Effect,tc:Card,tp:integer,stage:FUSION_SPELL_CALLBACK_STAGE,mg_fusion_spell:Group,mg_all:Group):boolean|nil +-- different stage for call back +---@alias FUSION_SPELL_CALLBACK_STAGE integer +-- Right before the Fusion Monster is officially summoned +FusionSpell.STAGE_BEFORE_SUMMON_COMPLETE=1 +-- Right before the entire Fusion procedure finishes +FusionSpell.STAGE_BEFORE_PROCEDURE_COMPLETE=2 +-- After the summon operation succeeds +FusionSpell.STAGE_AT_SUMMON_OPERATION_FINISH=3 +-- After **all** operations have run, whether the summon succeeded or not +FusionSpell.STAGE_AT_ALL_OPERATION_FINISH=4 +-- Right before the selected materials are moved, the return value of this stage will be checked, fusion procedure will be terminated if returned false +FusionSpell.STAGE_BEFORE_MOVE_MATERIAL=5 + +-- operation that would be applied on the material +---@alias FUSION_OPERATION_CODE integer +--- used only on EFFECT_EXTRA_FUSION_MATERIAL effects, inherits the operation of fusion spell, use FusionSpell.FUSION_OPERATION_INHERIT|LOCATION to tell the desired location to inherit. +--- if location is not specified, use the material location. +--- E.g. for 捕食植物トリアンティス, it should be FUSION_OPERATION_INHERIT|LOCATION_MZONE. +FusionSpell.FUSION_OPERATION_INHERIT=0x10000 +FusionSpell.FUSION_OPERATION_GRAVE=0x1 +FusionSpell.FUSION_OPERATION_BANISH=0x2 +FusionSpell.FUSION_OPERATION_BANISH_FACEDOWN=0x3 +FusionSpell.FUSION_OPERATION_SHUFFLE=0x4 +FusionSpell.FUSION_OPERATION_DECK_BOTTOM=0x5 +FusionSpell.FUSION_OPERATION_DESTROY=0x6 +FusionSpell.FUSION_OPERATION_DISCARD=0x7 + +---@return FUSION_OPERATION_FUNCTION +function FusionSpell.GetFusionOperationByCode(code,matlocation,fusion_spell_operation_code_map) + if code==FusionSpell.FUSION_OPERATION_GRAVE then + return FusionSpell.GraveMaterial + elseif code==FusionSpell.FUSION_OPERATION_BANISH then + return FusionSpell.BanishMaterial + elseif code==FusionSpell.FUSION_OPERATION_BANISH_FACEDOWN then + return FusionSpell.BanishMaterialFaceDown + elseif code==FusionSpell.FUSION_OPERATION_SHUFFLE then + return FusionSpell.ShuffleMaterial + elseif code==FusionSpell.FUSION_OPERATION_DECK_BOTTOM then + return FusionSpell.SendDeckBottomMaterial + elseif code==FusionSpell.FUSION_OPERATION_DESTROY then + return FusionSpell.DestroyMaterial + elseif code==FusionSpell.FUSION_OPERATION_DISCARD then + return FusionSpell.DiscardMaterial + elseif code&FusionSpell.FUSION_OPERATION_INHERIT==FusionSpell.FUSION_OPERATION_INHERIT then + local inhreit_as=code&(~FusionSpell.FUSION_OPERATION_INHERIT)&0xff --- 0xff is LOCATION_ALL + if inhreit_as~=0 then + matlocation=inhreit_as + end + if matlocation==nil or fusion_spell_operation_code_map==nil then + -- we are in trouble + assert(false, "we have a material that inhreits, but no operation to inhreit from") + return FusionSpell.GraveMaterial + end + return FusionSpell.GetFusionOperationByCode(FusionSpell.GetOperationCodeByMaterialLocation(matlocation,fusion_spell_operation_code_map)) + end + assert(false, string.format("we have an unknown fusion operation code %d",code)) + return FusionSpell.GraveMaterial +end + +---@return FUSION_FILTER_FUNCTION +function FusionSpell.GetFusionFilterByCode(code,matlocation,fusion_spell_operation_code_map) + if code==FusionSpell.FUSION_OPERATION_GRAVE then + return FusionSpell.GraveMaterialFilter + elseif code==FusionSpell.FUSION_OPERATION_BANISH then + return FusionSpell.BanishMaterialFilter + elseif code==FusionSpell.FUSION_OPERATION_BANISH_FACEDOWN then + return FusionSpell.BanishMaterialFaceDownFilter + elseif code==FusionSpell.FUSION_OPERATION_SHUFFLE then + return FusionSpell.ShuffleMaterialFilter + elseif code==FusionSpell.FUSION_OPERATION_DECK_BOTTOM then + return FusionSpell.SendDeckBottomMaterialFilter + elseif code==FusionSpell.FUSION_OPERATION_DESTROY then + return FusionSpell.DestroyMaterialFilter + elseif code==FusionSpell.FUSION_OPERATION_DISCARD then + return FusionSpell.DiscardMaterialFilter + elseif code&FusionSpell.FUSION_OPERATION_INHERIT==FusionSpell.FUSION_OPERATION_INHERIT then + local inhreit_as=code&(~FusionSpell.FUSION_OPERATION_INHERIT)&0xff --- 0xff is LOCATION_ALL + if inhreit_as~=0 then + matlocation=inhreit_as + end + if matlocation==nil or fusion_spell_operation_code_map==nil then + -- we are in trouble + assert(false, "we have a material that inhreits, but no operation to inhreit from") + return FusionSpell.GraveMaterialFilter + end + return FusionSpell.GetFusionFilterByCode(FusionSpell.GetOperationCodeByMaterialLocation(matlocation,fusion_spell_operation_code_map)) + end + assert(false, string.format("we have an unknown fusion operation code %d",code)) + return FusionSpell.GraveMaterialFilter +end + +---@alias FUSION_OPERATION_FUNCTION fun(sg:Card|Group,tp:integer):integer +---@alias FUSION_FILTER_FUNCTION fun(c:Card,tp:integer?,e:Effect?):boolean + +---@type FUSION_OPERATION_FUNCTION +function FusionSpell.GraveMaterial(sg,tp) + return Duel.SendtoGrave(sg,REASON_EFFECT+REASON_MATERIAL+REASON_FUSION,tp) +end + +---@type FUSION_FILTER_FUNCTION +function FusionSpell.GraveMaterialFilter(c) + return c:IsAbleToGrave() +end + +---@type FUSION_OPERATION_FUNCTION +function FusionSpell.BanishMaterial(sg,tp) + return Duel.Remove(sg,POS_FACEUP,REASON_EFFECT+REASON_MATERIAL+REASON_FUSION,tp) +end + +---@type FUSION_FILTER_FUNCTION +function FusionSpell.BanishMaterialFilter(c,tp) + return c:IsAbleToRemove(tp,POS_FACEUP,REASON_EFFECT+REASON_MATERIAL+REASON_FUSION) +end + +---@type FUSION_OPERATION_FUNCTION +function FusionSpell.BanishMaterialFaceDown(sg,tp) + return Duel.Remove(sg,POS_FACEDOWN,REASON_EFFECT+REASON_MATERIAL+REASON_FUSION,tp) +end + +---@type FUSION_FILTER_FUNCTION +function FusionSpell.BanishMaterialFaceDownFilter(c,tp) + return c:IsAbleToRemove(tp,POS_FACEDOWN,REASON_EFFECT+REASON_MATERIAL+REASON_FUSION) +end + +---@type FUSION_OPERATION_FUNCTION +function FusionSpell.ShuffleMaterial(sg,tp) + return Duel.SendtoDeck(sg,nil,SEQ_DECKSHUFFLE,REASON_EFFECT+REASON_MATERIAL+REASON_FUSION,tp) +end + +---@type FUSION_FILTER_FUNCTION +function FusionSpell.ShuffleMaterialFilter(c) + return c:IsAbleToDeck() +end + +---@type FUSION_OPERATION_FUNCTION +function FusionSpell.SendDeckBottomMaterial(sg,tp) + -- prompt user to select order + return aux.PlaceCardsOnDeckBottom(tp,sg,REASON_EFFECT+REASON_MATERIAL+REASON_FUSION) +end + +---@type FUSION_FILTER_FUNCTION +function FusionSpell.SendDeckBottomMaterialFilter(c) + return c:IsAbleToDeck() +end + +---@type FUSION_OPERATION_FUNCTION +function FusionSpell.DestroyMaterial(sg,tp) + return Duel.Destroy(sg,REASON_EFFECT+REASON_MATERIAL+REASON_FUSION,nil,tp) +end + +---@type FUSION_FILTER_FUNCTION +function FusionSpell.DestroyMaterialFilter(c,tp,e) + return c:IsDestructable(e) +end + +---@type FUSION_OPERATION_FUNCTION +function FusionSpell.DiscardMaterial(sg,tp) + return Duel.SendtoGrave(sg,REASON_EFFECT+REASON_MATERIAL+REASON_FUSION+REASON_DISCARD,tp) +end + +---@type FUSION_FILTER_FUNCTION +function FusionSpell.DiscardMaterialFilter(c) + return c:IsDiscardable(REASON_EFFECT+REASON_MATERIAL+REASON_FUSION) +end + +--Returns a list of effect, if element is the EFFECT_EXTRA_FUSION_MATERIAL, stands for it can be included by that extra material effect. +--if element is true, stands for it can be included by the fusion effect itself. +---@param pre_select_mat_location integer|FUSION_SPELL_PRE_SELECT_MAT_LOCATION_FUNCTION location where to find the materials before known the materials +---@param pre_select_mat_opponent_location integer|FUSION_SPELL_PRE_SELECT_MAT_LOCATION_FUNCTION location where to find the materials before known the materials on opponent location +---@param post_select_mat_opponent_location integer location where to find the materials after known the materials on opponent location +---@param fusion_spell_matfilter FUSION_SPELL_MATFILTER_FUNCTION a material must pass this to be legal as material come from fusion spell +---@param e Effect the fusion effect +---@param mat_operation_code_map {[integer]:FUSION_OPERATION_CODE}[] operation code to do for the materials, it will be check in order +---@return (true|Effect)[] +function FusionSpell.GetMaterialEffects(c,tp,tc,pre_select_mat_location,post_select_mat_location,pre_select_mat_opponent_location,post_select_mat_opponent_location,fusion_spell_matfilter,e,mat_operation_code_map) + local res={} + local calculated_mat_opponent_location=FusionSpell.GetAllLocationsForTargetCard(tc,tp,pre_select_mat_opponent_location,post_select_mat_opponent_location) + local all_locations=FusionSpell.GetAllLocationsForTargetCard(tc,tp,pre_select_mat_location,post_select_mat_location) + if c:IsControler(tp) and c:IsLocation(all_locations) and fusion_spell_matfilter(c,e,tp) then + --- in order to be qualified for being material, it need to be able to perform the operation. + ---@type FUSION_FILTER_FUNCTION + local filter_by_operation=FusionSpell.GetFusionFilterByCode(FusionSpell.GetOperationCodeByMaterialLocation(c:GetLocation(),mat_operation_code_map)) + if filter_by_operation(c,tp,e) then + table.insert(res,true) + end + elseif c:IsControler(1-tp) and c:IsLocation(calculated_mat_opponent_location) and fusion_spell_matfilter(c,e,tp) then + --- in order to be qualified for being material, it need to be able to perform the operation. + ---@type FUSION_FILTER_FUNCTION + local filter_by_operation=FusionSpell.GetFusionFilterByCode(FusionSpell.GetOperationCodeByMaterialLocation(c:GetLocation(),mat_operation_code_map)) + if filter_by_operation(c,tp,e) then + table.insert(res,true) + end + end + local extra_effs={c:IsHasEffect(EFFECT_EXTRA_FUSION_MATERIAL)} + for _,eff in ipairs(extra_effs) do + if FusionSpell.GetExtraMaterialEffectApplyForTargetCardWithFusionSpell(eff,c,tp,tc,pre_select_mat_location) then + --- in order to be qualified for being material, it need to be able to perform the operation. + ---@type FUSION_OPERATION_CODE + local operation_code=FusionSpell.FUSION_OPERATION_INHERIT + if eff:GetOperation()~=nil then + operation_code=eff:GetOperation()() + end + operation_code=operation_code or FusionSpell.FUSION_OPERATION_INHERIT + ---@type FUSION_FILTER_FUNCTION + local filter_by_operation=FusionSpell.GetFusionFilterByCode(operation_code,c:GetLocation(),mat_operation_code_map) + if filter_by_operation(c,tp,e) then + table.insert(res,eff) + end + end + end + return res +end + +--Returns the 1st EFFECT_EXTRA_FUSION_MATERIAL is applied on Card c. +--If summon_card is provided, it will filter on whether the effect's value function applies to that card. +---@param c Card the material card +---@param tp integer the player +---@param tc Card the target card +---@param pre_select_mat_location integer|FUSION_SPELL_PRE_SELECT_MAT_LOCATION_FUNCTION location where to find the materials before known the materials +function FusionSpell.GetExtraMaterialEffect(c,tp,tc,pre_select_mat_location) + local effs={c:IsHasEffect(EFFECT_EXTRA_FUSION_MATERIAL)} + for _,eff in ipairs(effs) do + if FusionSpell.GetExtraMaterialEffectApplyForTargetCardWithFusionSpell(eff,c,tp,tc,pre_select_mat_location) then + return eff + end + end +end + +---@param extra_material_effect Effect the extra material effect +---@param mc Card the material card +---@param tp integer the player +---@param tc Card the target card +---@param pre_select_mat_location integer|FUSION_SPELL_PRE_SELECT_MAT_LOCATION_FUNCTION location where to find the materials before known the materials +---@return boolean result whether the extra material effect can apply +function FusionSpell.GetExtraMaterialEffectApplyForTargetCardWithFusionSpell(extra_material_effect,mc,tp,tc,pre_select_mat_location) + if type(pre_select_mat_location)=="function" then + pre_select_mat_location=pre_select_mat_location(tc,tp) + end + --- can not use if count limit exhausted + if extra_material_effect:CheckCountLimit(tp)==false then + return false + end + --- 1st element of label is material count limit, 2nd is location requirement + local labels={extra_material_effect:GetLabel()} + if #labels>=2 then + local location_requirement=labels[2] + if pre_select_mat_location&location_requirement==0 then + return false + end + end + local val=extra_material_effect:GetValue() + if (type(val)=="function" and val(extra_material_effect,tc)) or val==1 then + return true + end + return false +end + +-- when a target card can be summoned by multiple effect, ask for which to apply. +---@return Effect +function FusionSpell.MultiFusionEffectPrompt(effects,tp) + local ops={} + for _,eff in ipairs(effects) do + table.insert(ops,eff:GetDescription()) + end + local op=Duel.SelectOption(tp,table.unpack(ops)) + return effects[op+1] +end + +--- filter out materials that does not necessary come from fusion spell and pass to the gcheck of fusion spell +--- for each extra material effect, check the maximuim size is not exceeded. +--- As of 2025 May, if a material could (but not forced) be used as extra material, it must be able to be used as fusion spell material. The code below is based on this assumption. +--- If we have Aiラブ融合 + 影牢の呪縛 or 多層融合 + アマゾネスの秘術 in same archetype, is code would fail in some scenario. +--- @param fusion_spell_additional_fcheck_function FUSION_FGCHECK_FUNCTION +--- @param tp integer +--- @param tc Card +--- @param pre_select_mat_location integer|FUSION_SPELL_PRE_SELECT_MAT_LOCATION_FUNCTION location where to find the materials before known the materials (default LOCATION_HAND|LOCATION_MZONE) +--- @param post_select_mat_location integer +--- @param pre_select_mat_opponent_location integer|FUSION_SPELL_PRE_SELECT_MAT_LOCATION_FUNCTION location where to find the materials before known the materials on opponent location +--- @param post_select_mat_opponent_location integer location where to find the materials after known the materials on opponent location +--- @param fusion_spell_matfilter FUSION_SPELL_MATFILTER_FUNCTION a material must pass this to be legal as material come from fusion spell +--- @param e Effect the fusion effect +--- @param mat_operation_code_map {[integer]:FUSION_OPERATION_CODE}[] operation code to do for the materials, it will be check in order +function FusionSpell.GetFusionSpellFCheckAdditionalFunction( + fusion_spell_additional_fcheck_function, + tp, + tc, + pre_select_mat_location, + post_select_mat_location, + pre_select_mat_opponent_location, + post_select_mat_opponent_location, + fusion_spell_matfilter, + e, + mat_operation_code_map) + ---@param mg Group + return (function(f_tp,mg,fc) + --- filter out materials that can only be added by extra material effects, and check the count limit + local mandartory_extra_mg=mg:Filter(function (mc) + local material_effects=FusionSpell.GetMaterialEffects(mc,tp,tc,pre_select_mat_location,post_select_mat_location,pre_select_mat_opponent_location,post_select_mat_opponent_location,fusion_spell_matfilter,e,mat_operation_code_map) + if (#material_effects)==1 and material_effects[1]~=true then + return true + end + return false + end,nil) + --- group by extra material effect + ---@type {[Effect]:Group} + local material_grouped_by_extra_material_effect={} + for material in aux.Next(mandartory_extra_mg) do + local material_effect=FusionSpell.GetExtraMaterialEffect(material,tp,tc,pre_select_mat_location) + material_grouped_by_extra_material_effect[material_effect]=material_grouped_by_extra_material_effect[material_effect] or Group.CreateGroup() + material_grouped_by_extra_material_effect[material_effect]:AddCard(material) + end + --- check count limit for each effect + for extra_material_effect,materials in pairs(material_grouped_by_extra_material_effect) do + local labels={extra_material_effect:GetLabel()} + --- first element of label is the material count limit + if labels~=nil and #labels>0 and labels[1]>0 and #materials>labels[1] then + return false + end + end + + local extra_mg=mg:Filter(FusionSpell.GetExtraMaterialEffect,nil,tp,tc,pre_select_mat_location) + return fusion_spell_additional_fcheck_function(f_tp,mg-extra_mg,fc,mg,e) + end) +end + + +--- filter out materials that does not necessary come from fusion spell and pass to the gcheck of fusion spell +--- @param fusion_spell_additional_fgoalcheck_function FUSION_FGCHECK_FUNCTION +--- @param tp integer +--- @param tc Card +--- @param pre_select_mat_location integer|FUSION_SPELL_PRE_SELECT_MAT_LOCATION_FUNCTION location where to find the materials before known the materials (default LOCATION_HAND|LOCATION_MZONE) +--- @param e Effect the fusion effect +function FusionSpell.GetFusionSpellFGoalCheckAdditionalFunction(fusion_spell_additional_fgoalcheck_function,tp,tc,pre_select_mat_location,e) + ---@param mg Group + return (function(f_tp,mg,fc) + local extra_mg=mg:Filter(FusionSpell.GetExtraMaterialEffect,nil,tp,tc,pre_select_mat_location) + return fusion_spell_additional_fgoalcheck_function(f_tp,mg-extra_mg,fc,mg,e) + end) +end + +--- all material must come from chain material, only pass all material group to the fcheck of fusion spell +--- @param fusion_spell_additional_fcheck_function FUSION_FGCHECK_FUNCTION +function FusionSpell.GetFusionSpellFCheckAdditionalFunctionForChainMaterial(fusion_spell_additional_fcheck_function,e) + return (function(f_tp,mg,fc) + return fusion_spell_additional_fcheck_function(f_tp,Group.CreateGroup(),fc,mg,e) + end) +end + +--- all material must come from chain material, only pass all material group to the gcheck of fusion spell +--- @param fusion_spell_additional_fgoalcheck_function FUSION_FGCHECK_FUNCTION +--- @param e Effect the fusion effect +function FusionSpell.GetFusionSpellFGoalCheckAdditionalFunctionForChainMaterial(fusion_spell_additional_fgoalcheck_function,e) + return (function(f_tp,mg,fc) + return fusion_spell_additional_fgoalcheck_function(f_tp,Group.CreateGroup(),fc,mg,e) + end) +end + +--- @param tp integer +--- @param skip_location_count_check boolean +--- @return integer chkf the player id to check the field count +function FusionSpell.GetCheckFieldPlayer(tp,skip_location_count_check) + if skip_location_count_check==true then + return PLAYER_NONE + end + return tp +end + +--[[ MDPro3 patch [anime-xyz2-fix] 2026-08-08 (v2): base = official 1.4.6.1 +ygopro-super-pre procedure.lua (defines FusionSpell + newest procs, pairs with the +super-pre card scripts), plus the Ygoproco XyzCondition2/XyzTarget2/XyzOperation2 +helpers required by Anime Cards.ypk's global AddXyzProcedure patch. This loose file +shadows every archived procedure.lua (Expansions/script beats the zips). +--]] +if Auxiliary.XyzCondition2==nil then +function Auxiliary.XyzCondition2(f,lv,minc,maxc,alterf,desc,op) + return function(e,c,og) + if c==nil then return true end + if c:IsType(TYPE_PENDULUM) and c:IsFaceup() then return false end + local tp=c:GetControler() + local ft=Duel.GetLocationCount(tp,LOCATION_MZONE) + local ct=-ft + if minc<=ct then return false end + if ct<1 and not og and Duel.IsExistingMatchingCard(Auxiliary.XyzAlterFilter,tp,LOCATION_MZONE,0,1,nil,alterf,c) + and (not op or op(e,tp,0)) then + return true + end + return Duel.CheckXyzMaterial(c,f,lv,minc,maxc,og) + end +end +function Auxiliary.XyzTarget2(f,lv,minc,maxc,alterf,desc,op) + return function(e,tp,eg,ep,ev,re,r,rp,chk,c,og) + if og then + return true + else + local ft=Duel.GetLocationCount(tp,LOCATION_MZONE) + local ct=-ft + local b1=Duel.CheckXyzMaterial(c,f,lv,minc,maxc,og) + local b2=ct<1 and Duel.IsExistingMatchingCard(Auxiliary.XyzAlterFilter,tp,LOCATION_MZONE,0,1,nil,alterf,c) + and (not op or op(e,tp,0)) + if b2 and (not b1 or Duel.SelectYesNo(tp,desc)) then + e:SetLabel(1) + return true + else + e:SetLabel(0) + local g=Duel.SelectXyzMaterial(tp,c,f,lv,minc,maxc) + if g then + g:KeepAlive() + e:SetLabelObject(g) + return true + else return false end + end + end + end +end +function Auxiliary.XyzOperation2(f,lv,minc,maxc,alterf,desc,op) + return function(e,tp,eg,ep,ev,re,r,rp,c,og) + if og then + local sg=Group.CreateGroup() + local tc=og:GetFirst() + while tc do + local sg1=tc:GetOverlayGroup() + sg:Merge(sg1) + tc=og:GetNext() + end + Duel.SendtoGrave(sg,REASON_RULE) + c:SetMaterial(og) + Duel.Overlay(c,og) + else + if e:GetLabel()==1 then + if op then op(e,tp,1) end + Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_XMATERIAL) + local mg=Duel.SelectMatchingCard(tp,Auxiliary.XyzAlterFilter,tp,LOCATION_MZONE,0,1,1,nil,alterf,c) + local mg2=mg:GetFirst():GetOverlayGroup() + if mg2:GetCount()~=0 then + Duel.Overlay(c,mg2) + end + c:SetMaterial(mg) + Duel.Overlay(c,mg) + else + local mg=e:GetLabelObject() + local sg=Group.CreateGroup() + local tc=mg:GetFirst() + while tc do + local sg1=tc:GetOverlayGroup() + sg:Merge(sg1) + tc=mg:GetNext() + end + Duel.SendtoGrave(sg,REASON_RULE) + c:SetMaterial(mg) + Duel.Overlay(c,mg) + mg:DeleteGroup() + end + end + end +end + +end --[anime-xyz2-fix] diff --git a/tests/fixture/make-fixture.py b/tests/fixture/make-fixture.py new file mode 100644 index 0000000..eab8d29 --- /dev/null +++ b/tests/fixture/make-fixture.py @@ -0,0 +1,106 @@ +"""Builds tests/fixture/game: the smallest game root the tests can duel on. + + python3 -I tests/fixture/make-fixture.py + + holds the game's Data/locales/en-US/{cards.cdb,bot.conf}, Data/script.zip and +Data/Windbot/Decks/AI_OldSchool.ydk (the Unity repo's Data/ at the commit named in tests/fixture/README.md). + is a game copy's Expansions/script/ (its non-card files override script.zip's). + +It also writes Data/Characters/fixture-oldschool, a character that owns the deck. +The cards are the deck's, plus every card id their scripts name that the database has (tokens, alias targets), +to a fixed point. The scripts are those cards' c.lua and the system files (constant, utility, procedure). +""" +import os +import re +import shutil +import sqlite3 +import sys +import zipfile + +DECK = "AI_OldSchool" + +# A character that owns the deck, so a seat on it gets that character's name and the Smart brain (the game's +# path: deck -> owning character -> brain), not Dovphin. +CHARACTER = """{ + "_comment": "Test fixture: owns AI_OldSchool so its seats play the Smart brain.", + "id": "fixture-oldschool", + "name": "Old School", + "decks": [ + { "path": "AI_OldSchool", "brain": { "executor": "Smart", "difficulty": "hard", "knobs": { "aggression": 0.5 } } } + ], + "brain": { "executor": "Lucky", "difficulty": "normal", "knobs": {} } +} +""" + + +def deck_ids(path): + ids = [] + for line in open(path, encoding="utf-8-sig"): + line = line.strip() + if line.isdigit(): + ids.append(int(line)) + return ids + + +def main(src, exp_script, out): + cdb = os.path.join(src, "Data/locales/en-US/cards.cdb") + scripts = zipfile.ZipFile(os.path.join(src, "Data/script.zip")) + names = set(scripts.namelist()) + db = sqlite3.connect("file:" + cdb + "?mode=ro", uri=True) + known = {row[0] for row in db.execute("SELECT id FROM datas")} + + def script_of(code): + name = "script/c%d.lua" % code + return scripts.read(name).decode("utf-8", "replace") if name in names else "" + + want = set(deck_ids(os.path.join(src, "Data/Windbot/Decks", DECK + ".ydk"))) + todo = list(want) + while todo: + code = todo.pop() + refs = {int(n) for n in re.findall(r"\b\d{5,9}\b", script_of(code))} + alias = db.execute("SELECT alias FROM datas WHERE id=?", (code,)).fetchone() + if alias and alias[0]: + refs.add(alias[0]) + for ref in refs & known - want: + want.add(ref) + todo.append(ref) + + if os.path.exists(out): + shutil.rmtree(out) + os.makedirs(os.path.join(out, "Data/locales/en-US")) + os.makedirs(os.path.join(out, "Data/Windbot/Decks")) + os.makedirs(os.path.join(out, "Expansions/script")) + os.makedirs(os.path.join(out, "Data/Characters/fixture-oldschool")) + with open(os.path.join(out, "Data/Characters/fixture-oldschool/character.json"), "w", newline="\n") as f: + f.write(CHARACTER) + + sub = sqlite3.connect(os.path.join(out, "Data/locales/en-US/cards.cdb")) + for (sql,) in db.execute("SELECT sql FROM sqlite_master WHERE type='table' AND name IN ('datas','texts')"): + sub.execute(sql) + for table in ("datas", "texts"): + cols = len(db.execute("SELECT * FROM %s LIMIT 1" % table).description) + rows = db.execute("SELECT * FROM %s WHERE id IN (%s) ORDER BY id" % (table, ",".join(map(str, sorted(want))))).fetchall() + sub.executemany("INSERT INTO %s VALUES (%s)" % (table, ",".join("?" * cols)), rows) + sub.commit() + sub.execute("VACUUM") + sub.close() + + keep = sorted(n for n in names if n.startswith("script/") and not re.match(r"script/c\d+\.lua$", n) and not n.endswith("/")) + keep += sorted("script/c%d.lua" % c for c in want if "script/c%d.lua" % c in names) + with zipfile.ZipFile(os.path.join(out, "Data/script.zip"), "w", zipfile.ZIP_DEFLATED) as z: + for n in keep: + info = zipfile.ZipInfo(n, date_time=(2026, 1, 1, 0, 0, 0)) + info.compress_type = zipfile.ZIP_DEFLATED + z.writestr(info, scripts.read(n)) + + for name in sorted(os.listdir(exp_script)): + if name.endswith(".lua") and not re.match(r"c\d+\.lua$", name): + shutil.copyfile(os.path.join(exp_script, name), os.path.join(out, "Expansions/script", name)) + + shutil.copyfile(os.path.join(src, "Data/locales/en-US/bot.conf"), os.path.join(out, "Data/locales/en-US/bot.conf")) + shutil.copyfile(os.path.join(src, "Data/Windbot/Decks", DECK + ".ydk"), os.path.join(out, "Data/Windbot/Decks", DECK + ".ydk")) + print("%d cards, %d scripts -> %s" % (len(want), len(keep), out)) + + +if __name__ == "__main__": + main(*sys.argv[1:4])