Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add some default function #87

Merged
merged 4 commits into from
Aug 24, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
69 changes: 69 additions & 0 deletions Game/AI/DefaultExecutor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,14 @@ protected class _CardId
public const int MacroCosmos = 30241314;
public const int UpstartGoblin = 70368879;
public const int EaterOfMillions = 63845230;

public const int InvokedPurgatrio = 12307878;
public const int ChaosAncientGearGiant = 51788412;
public const int UltimateAncientGearGolem = 12652643;

public const int ImperialOrder = 61740673;
public const int NaturiaBeast = 33198837;
public const int AntiSpellFragrance = 58921041;
}

protected DefaultExecutor(GameAI ai, Duel duel)
Expand Down Expand Up @@ -342,6 +350,31 @@ protected bool DefaultCallOfTheHaunted()
return true;
}

/// <summary>
/// Default Scapegoat effect
/// </summary>
protected bool DefaultScapegoat()
{
if (DefaultSpellWillBeNegated()) return false;
if (Duel.Player == 0) return false;
if (Duel.Phase == DuelPhase.End) return true;
if (DefaultOnBecomeTarget()) return true;
if (Duel.Phase > DuelPhase.Main1 && Duel.Phase < DuelPhase.Main2)
{
if (Enemy.HasInMonstersZone(_CardId.UltimateConductorTytanno, true)) return false;
if (Enemy.HasInMonstersZone(_CardId.InvokedPurgatrio, true)) return false;
if (Enemy.HasInMonstersZone(_CardId.ChaosAncientGearGiant, true)) return false;
if (Enemy.HasInMonstersZone(_CardId.UltimateAncientGearGolem, true)) return false;
int total_atk = 0;
List<ClientCard> enemy_monster = Enemy.GetMonsters();
foreach (ClientCard m in enemy_monster)
{
if (m.IsAttack()) total_atk += m.Attack;
}
if (total_atk >= Bot.LifePoints) return true;
}
return false;
}
/// <summary>
/// Always active in opponent's turn.
/// </summary>
Expand Down Expand Up @@ -641,6 +674,42 @@ protected bool DefaultMonsterRepos()
return false;
}

/// <summary>
/// If spell will be negated
/// </summary>
protected bool DefaultSpellWillBeNegated()
{
ClientCard card = null;
foreach (ClientCard check in Bot.GetSpells())
{
if (check.Id == _CardId.ImperialOrder && !check.IsDisabled())
card = check;
}
if (card != null && card.IsFaceup())
return true;
if (Enemy.HasInSpellZone(_CardId.ImperialOrder, true) || Enemy.HasInMonstersZone(_CardId.NaturiaBeast, true))
return true;
return false;
}

/// <summary>
/// If spell must set first to activate
/// </summary>
protected bool DefaultSpellMustSetFirst()
{
ClientCard card = null;
foreach (ClientCard check in Bot.GetSpells())
{
if (check.Id == _CardId.AntiSpellFragrance && !check.IsDisabled())
card = check;
}
if (card != null && card.IsFaceup())
return true;
if (Enemy.HasInSpellZone(_CardId.AntiSpellFragrance, true))
return true;
return false;
}

/// <summary>
/// if spell/trap is the target or enermy activate HarpiesFeatherDuster
/// </summary>
Expand Down