Skip to content

Commit

Permalink
Enemy Impermanence
Browse files Browse the repository at this point in the history
  • Loading branch information
Eronan committed Dec 23, 2024
1 parent 74e3905 commit f45f4fc
Showing 1 changed file with 68 additions and 3 deletions.
71 changes: 68 additions & 3 deletions Game/AI/Decks/CatenicorumExecutor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,8 @@ public sealed class CardId

private readonly List<int> UsedSpellTrapMaterial = [];

private bool enemyActivateInfiniteImpermanenceFromHand = false;

// Portal Rune Summon from Deck
private bool portalRuneFromDeckIsUsed = false;

Expand Down Expand Up @@ -179,6 +181,69 @@ public CatenicorumExecutor(GameAI ai, Duel duel)
AddExecutor(ExecutorType.Summon, CardId.MulcharmyFuwalos);
}

public override void OnChaining(int player, ClientCard card)
{
if (player == 1)
{
if (card.IsOriginalCode(_CardId.InfiniteImpermanence))
{
if (enemyActivateInfiniteImpermanenceFromHand)
{
enemyActivateInfiniteImpermanenceFromHand = false;
}
else
{
for (int i = 0; i < 5; ++i)
{
if (Enemy.SpellZone[i] == card)
{
ImpermanenceZonesThisTurn.Add(4 - i);
break;
}
}
}
}
}

base.OnChaining(player, card);
}

public override void OnChainSolved(int chainIndex)
{
var card = Duel.CurrentChain[chainIndex];

switch (card.GetOriginCode())
{
case _CardId.InfiniteImpermanence:
ImpermanenceZonesThisTurn.Add(4 - card.Sequence);
break;
}

base.OnChainSolved(chainIndex);
}

public override void OnChainEnd()
{
enemyActivateInfiniteImpermanenceFromHand = false;
base.OnChainEnd();
}

public override void OnMove(ClientCard card, int previousControler, int previousLocation, int currentControler, int currentLocation)
{
if (previousControler == 1)
{
if (card != null)
{
if (card.IsCode(_CardId.InfiniteImpermanence) && previousLocation == (int)CardLocation.Hand && currentLocation == (int)CardLocation.SpellZone)
{
enemyActivateInfiniteImpermanenceFromHand = true;
}
}
}

base.OnMove(card, previousControler, previousLocation, currentControler, currentLocation);
}

public override void OnNewTurn()
{
ImpermanenceZonesThisTurn.Clear();
Expand All @@ -204,10 +269,10 @@ public override void OnNewTurn()
base.OnNewTurn();
}

public override int OnSelectPlace(int cardId, int player, CardLocation location, int available)
public override void OnNewPhase()
{
Logger.WriteLine($"Hand Size: {Bot.Hand.Count}");
return base.OnSelectPlace(cardId, player, location, available);
Logger.DebugWriteLine($"Hand: {{{string.Join(", ", Bot.Hand.Select(card => card.Name))}}}");
base.OnNewPhase();
}

public Func<bool> AvoidImpermanenceActivate(Func<bool> func)
Expand Down

0 comments on commit f45f4fc

Please sign in to comment.