Commit e832e9cc authored by wind2009's avatar wind2009 Committed by GitHub

Fix bot negating Horus monsters' special summoning (#186)

parent 82d8819c
...@@ -496,6 +496,7 @@ namespace WindBot.Game.AI.Decks ...@@ -496,6 +496,7 @@ namespace WindBot.Game.AI.Decks
{ {
if (Bot.LifePoints > 1500 && Duel.LastChainPlayer == 1) if (Bot.LifePoints > 1500 && Duel.LastChainPlayer == 1)
return true; return true;
if (DefaultOnlyHorusSpSummoning()) return false;
return false; return false;
} }
......
...@@ -437,6 +437,7 @@ namespace WindBot.Game.AI.Decks ...@@ -437,6 +437,7 @@ namespace WindBot.Game.AI.Decks
private bool ThunderKingRaiOheff() private bool ThunderKingRaiOheff()
{ {
if (DefaultOnlyHorusSpSummoning()) return false;
if(Duel.SummoningCards.Count > 0) if(Duel.SummoningCards.Count > 0)
{ {
foreach(ClientCard m in Duel.SummoningCards) foreach(ClientCard m in Duel.SummoningCards)
......
...@@ -370,6 +370,7 @@ namespace WindBot.Game.AI.Decks ...@@ -370,6 +370,7 @@ namespace WindBot.Game.AI.Decks
} }
private bool ThunderKingRaiOheff() private bool ThunderKingRaiOheff()
{ {
if (DefaultOnlyHorusSpSummoning()) return false;
if (Duel.SummoningCards.Count > 0) if (Duel.SummoningCards.Count > 0)
{ {
foreach (ClientCard m in Duel.SummoningCards) foreach (ClientCard m in Duel.SummoningCards)
......
...@@ -213,6 +213,7 @@ namespace WindBot.Game.AI ...@@ -213,6 +213,7 @@ namespace WindBot.Game.AI
public const int AncientWarriors = 0x137; public const int AncientWarriors = 0x137;
public const int RescueACE = 0x18b; public const int RescueACE = 0x18b;
public const int VanquishSoul = 0x195; public const int VanquishSoul = 0x195;
public const int Horus = 0x19d;
} }
protected DefaultExecutor(GameAI ai, Duel duel) protected DefaultExecutor(GameAI ai, Duel duel)
...@@ -834,7 +835,7 @@ namespace WindBot.Game.AI ...@@ -834,7 +835,7 @@ namespace WindBot.Game.AI
/// </summary> /// </summary>
protected bool DefaultSolemnJudgment() protected bool DefaultSolemnJudgment()
{ {
return !Util.IsChainTargetOnly(Card) && !(Duel.Player == 0 && Duel.LastChainPlayer == -1) && DefaultTrap(); return !Util.IsChainTargetOnly(Card) && !(Duel.Player == 0 && Duel.LastChainPlayer == -1) && !DefaultOnlyHorusSpSummoning() && DefaultTrap();
} }
/// <summary> /// <summary>
...@@ -842,7 +843,7 @@ namespace WindBot.Game.AI ...@@ -842,7 +843,7 @@ namespace WindBot.Game.AI
/// </summary> /// </summary>
protected bool DefaultSolemnWarning() protected bool DefaultSolemnWarning()
{ {
return (Bot.LifePoints > 2000) && !(Duel.Player == 0 && Duel.LastChainPlayer == -1) && DefaultTrap(); return (Bot.LifePoints > 2000) && !(Duel.Player == 0 && Duel.LastChainPlayer == -1) && !DefaultOnlyHorusSpSummoning() && DefaultTrap();
} }
/// <summary> /// <summary>
...@@ -850,7 +851,30 @@ namespace WindBot.Game.AI ...@@ -850,7 +851,30 @@ namespace WindBot.Game.AI
/// </summary> /// </summary>
protected bool DefaultSolemnStrike() protected bool DefaultSolemnStrike()
{ {
return (Bot.LifePoints > 1500) && !(Duel.Player == 0 && Duel.LastChainPlayer == -1) && DefaultTrap(); return (Bot.LifePoints > 1500) && !(Duel.Player == 0 && Duel.LastChainPlayer == -1) && !DefaultOnlyHorusSpSummoning() && DefaultTrap();
}
/// <summary>
/// Check whether only Horus monster is special summoning.
/// If returning true, should not negate the special summon since it can be special summoned again.
/// </summary>
/// <returns></returns>
protected bool DefaultOnlyHorusSpSummoning()
{
if (Duel.SummoningCards.Count != 0)
{
bool notOnlyHorusFlag = false;
foreach (ClientCard card in Duel.SummoningCards)
{
if (!card.HasSetcode(_Setcode.Horus) || card.LastLocation != CardLocation.Grave)
{
notOnlyHorusFlag = true;
break;
}
}
return !notOnlyHorusFlag;
}
return false;
} }
/// <summary> /// <summary>
......
...@@ -15,6 +15,7 @@ namespace WindBot.Game ...@@ -15,6 +15,7 @@ namespace WindBot.Game
public int Position { get; set; } public int Position { get; set; }
public int Sequence { get; set; } public int Sequence { get; set; }
public CardLocation Location { get; set; } public CardLocation Location { get; set; }
public CardLocation LastLocation { get; set; }
public int Alias { get; private set; } public int Alias { get; private set; }
public int Level { get; private set; } public int Level { get; private set; }
public int Rank { get; private set; } public int Rank { get; private set; }
...@@ -70,6 +71,7 @@ namespace WindBot.Game ...@@ -70,6 +71,7 @@ namespace WindBot.Game
ActionIndex = new int[16]; ActionIndex = new int[16];
ActionActivateIndex = new Dictionary<int, int>(); ActionActivateIndex = new Dictionary<int, int>();
Location = loc; Location = loc;
LastLocation = 0;
} }
public void SetId(int id) public void SetId(int id)
......
...@@ -376,15 +376,10 @@ namespace WindBot.Game ...@@ -376,15 +376,10 @@ namespace WindBot.Game
_duel.Fields[GetLocalPlayer(1)].Init(deck, extra); _duel.Fields[GetLocalPlayer(1)].Init(deck, extra);
// in case of ending duel in chain's solving // in case of ending duel in chain's solving
_duel.LastChainPlayer = -1;
_duel.LastChainLocation = 0;
_duel.CurrentChain.Clear(); _duel.CurrentChain.Clear();
_duel.ChainTargets.Clear(); _duel.ChainTargets.Clear();
_duel.LastChainTargets.Clear();
_duel.ChainTargetOnly.Clear(); _duel.ChainTargetOnly.Clear();
_duel.LastSummonPlayer = -1;
_duel.SummoningCards.Clear(); _duel.SummoningCards.Clear();
_duel.LastSummonedCards.Clear();
_duel.SolvingChainIndex = 0; _duel.SolvingChainIndex = 0;
_duel.NegatedChainIndexList.Clear(); _duel.NegatedChainIndexList.Clear();
...@@ -615,6 +610,10 @@ namespace WindBot.Game ...@@ -615,6 +610,10 @@ namespace WindBot.Game
packet.ReadInt32(); // reason packet.ReadInt32(); // reason
ClientCard card = _duel.GetCard(previousControler, (CardLocation)previousLocation, previousSequence); ClientCard card = _duel.GetCard(previousControler, (CardLocation)previousLocation, previousSequence);
if (card != null)
{
card.LastLocation = (CardLocation)previousLocation;
}
if ((previousLocation & (int)CardLocation.Overlay) != 0) if ((previousLocation & (int)CardLocation.Overlay) != 0)
{ {
previousLocation = previousLocation & 0x7f; previousLocation = previousLocation & 0x7f;
...@@ -803,6 +802,7 @@ namespace WindBot.Game ...@@ -803,6 +802,7 @@ namespace WindBot.Game
_duel.ChainTargetOnly.Clear(); _duel.ChainTargetOnly.Clear();
_duel.SolvingChainIndex = 0; _duel.SolvingChainIndex = 0;
_duel.NegatedChainIndexList.Clear(); _duel.NegatedChainIndexList.Clear();
_duel.SummoningCards.Clear();
} }
private void OnCardSorting(BinaryReader packet) private void OnCardSorting(BinaryReader packet)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment