180 lines
6.4 KiB
C#
180 lines
6.4 KiB
C#
using Vanguard.Rules.Cards;
|
||
|
||
namespace Vanguard.Rules.Engine.Abilities;
|
||
|
||
/// <summary>Скрипты карт первого сета, подключённые к движку.</summary>
|
||
public static class CardScripts
|
||
{
|
||
public static IReadOnlyDictionary<string, CardScript> Default { get; } =
|
||
new Dictionary<string, CardScript>(StringComparer.Ordinal)
|
||
{
|
||
["barcgal"] = new BarcgalScript(),
|
||
["wingal"] = new WingalScript(),
|
||
["king-of-knights-alfred"] = new AlfredScript(),
|
||
["blaster-blade"] = new BlasterBladeScript(),
|
||
["lake-maiden-lien"] = new DrawOneScript("lake-maiden-lien"),
|
||
["dragon-monk-gojo"] = new DrawOneScript("dragon-monk-gojo"),
|
||
["screamin-and-dancin-announcer-shout"] = new DrawOneScript("screamin-and-dancin-announcer-shout"),
|
||
};
|
||
}
|
||
|
||
/// <summary>
|
||
/// «[ACT]: повернуть эту карту и сбросить карту из руки → взять карту».
|
||
/// Общий скрипт для Lake Maiden, Lien, Dragon Monk, Gojo и Shout.
|
||
/// </summary>
|
||
public sealed class DrawOneScript : CardScript
|
||
{
|
||
public DrawOneScript(string nameId) => NameId = nameId;
|
||
|
||
public override string NameId { get; }
|
||
|
||
public override IEnumerable<ActivatedAbility> Activated
|
||
{
|
||
get
|
||
{
|
||
yield return new ActivatedAbility
|
||
{
|
||
CanActivate = _ => true,
|
||
RestsSelf = true,
|
||
RequiresDiscard = true,
|
||
Resolve = ctx => ctx.Engine.DrawCards(ctx.Owner, 1),
|
||
};
|
||
}
|
||
}
|
||
}
|
||
|
||
/// <summary>
|
||
/// Blaster Blade: при размещении оплатить Counter Blast 2 и уничтожить Арьергард противника.
|
||
/// На Авангарде — любой, на Арьергарде — только 2 ранга или выше и при Авангарде Royal Paladin.
|
||
/// </summary>
|
||
public sealed class BlasterBladeScript : CardScript
|
||
{
|
||
public override string NameId => "blaster-blade";
|
||
|
||
public override IEnumerable<AbilityDefinition> Abilities
|
||
{
|
||
get
|
||
{
|
||
yield return new AbilityDefinition
|
||
{
|
||
Trigger = AbilityTrigger.OnPlace,
|
||
Optional = true,
|
||
Condition = ctx => ctx.Engine.IsVanguardOf(ctx.Source, ctx.Owner),
|
||
CanPay = ctx => ctx.Engine.CanCounterBlast(ctx.Owner, 2),
|
||
Pay = ctx => ctx.Engine.CounterBlast(ctx.Owner, 2),
|
||
Resolve = ctx =>
|
||
{
|
||
var opponent = 1 - ctx.Owner;
|
||
var slots = ctx.Engine.RearGuardSlots(opponent, _ => true);
|
||
if (slots.Count == 0)
|
||
return;
|
||
|
||
ctx.Engine.AskUnitChoice(
|
||
ctx.Owner,
|
||
opponent,
|
||
"Выберите Арьергард противника",
|
||
slots,
|
||
slot => ctx.Engine.RetireRearGuard(opponent, slot));
|
||
},
|
||
};
|
||
|
||
yield return new AbilityDefinition
|
||
{
|
||
Trigger = AbilityTrigger.OnPlace,
|
||
Optional = true,
|
||
Condition = ctx =>
|
||
!ctx.Engine.IsVanguardOf(ctx.Source, ctx.Owner) &&
|
||
ctx.Engine.VanguardClan(ctx.Owner) == Clan.RoyalPaladin,
|
||
CanPay = ctx => ctx.Engine.CanCounterBlast(ctx.Owner, 2),
|
||
Pay = ctx => ctx.Engine.CounterBlast(ctx.Owner, 2),
|
||
Resolve = ctx =>
|
||
{
|
||
var opponent = 1 - ctx.Owner;
|
||
var slots = ctx.Engine.RearGuardSlots(opponent, d => d.Grade >= 2);
|
||
if (slots.Count == 0)
|
||
return;
|
||
|
||
ctx.Engine.AskUnitChoice(
|
||
ctx.Owner,
|
||
opponent,
|
||
"Выберите Арьергард противника 2 ранга или выше",
|
||
slots,
|
||
slot => ctx.Engine.RetireRearGuard(opponent, slot));
|
||
},
|
||
};
|
||
}
|
||
}
|
||
}
|
||
|
||
/// <summary>
|
||
/// Barcgal: когда другой Royal Paladin сменяет эту карту, вы можете призвать её в круг Арьергарда.
|
||
/// </summary>
|
||
public sealed class BarcgalScript : CardScript
|
||
{
|
||
public override string NameId => "barcgal";
|
||
|
||
public override IEnumerable<AbilityDefinition> Abilities
|
||
{
|
||
get
|
||
{
|
||
yield return new AbilityDefinition
|
||
{
|
||
Trigger = AbilityTrigger.OnRideOver,
|
||
Optional = true,
|
||
Condition = ctx =>
|
||
ctx.Other is not null &&
|
||
ctx.Catalog.CardOf(ctx.Other.PrintingId).Clan == Clan.RoyalPaladin,
|
||
Resolve = ctx => ctx.Engine.CallFromSoul(ctx.Source, ctx.Owner),
|
||
};
|
||
}
|
||
}
|
||
}
|
||
|
||
/// <summary>
|
||
/// Wingal: когда эта карта поддерживает Blaster Blade, усиленная карта получает +4000 до конца боя.
|
||
/// </summary>
|
||
public sealed class WingalScript : CardScript
|
||
{
|
||
private const string BlasterBlade = "blaster-blade";
|
||
|
||
public override string NameId => "wingal";
|
||
|
||
public override IEnumerable<AbilityDefinition> Abilities
|
||
{
|
||
get
|
||
{
|
||
yield return new AbilityDefinition
|
||
{
|
||
Trigger = AbilityTrigger.OnBoost,
|
||
Condition = ctx =>
|
||
ctx.Other is not null &&
|
||
ctx.Catalog.CardOf(ctx.Other.PrintingId).NameId == BlasterBlade,
|
||
Resolve = ctx => ctx.Engine.AddBattlePower(4000),
|
||
};
|
||
}
|
||
}
|
||
}
|
||
|
||
/// <summary>
|
||
/// King of Knights, Alfred: в свой ход на круге Авангарда получает +2000
|
||
/// за каждый свой Арьергард Royal Paladin.
|
||
/// </summary>
|
||
public sealed class AlfredScript : CardScript
|
||
{
|
||
public override string NameId => "king-of-knights-alfred";
|
||
|
||
public override IEnumerable<ContinuousAbility> Continuous
|
||
{
|
||
get
|
||
{
|
||
yield return new ContinuousAbility
|
||
{
|
||
Applies = ctx =>
|
||
ctx.Engine.IsVanguardOf(ctx.Source, ctx.Owner) &&
|
||
ctx.State.ActivePlayer == ctx.Owner,
|
||
PowerBonus = ctx => 2000 * ctx.Engine.CountRearGuards(ctx.Owner, Clan.RoyalPaladin),
|
||
};
|
||
}
|
||
}
|
||
}
|