Commit 18b0cc48 authored by wind2009's avatar wind2009 Committed by GitHub

Update default excutor (#178)

parent f0581a87
......@@ -21,7 +21,8 @@ namespace WindBot.Game.AI
/// </summary>
public static bool IsMonsterDangerous(this ClientCard card)
{
return !card.IsDisabled() && Enum.IsDefined(typeof(DangerousMonster), card.Id);
return !card.IsDisabled() &&
(Enum.IsDefined(typeof(DangerousMonster), card.Id) || (card.HasSetcode(0x18d) && (card.HasType(CardType.Ritual) || card.EquipCards.Count > 0)));
}
/// <summary>
......
This diff is collapsed.
......@@ -25,6 +25,7 @@
Heart_eartHDragon = 97403510,
DaigustoSphreeze = 29552709,
OhimetheManifestedMikanko = 81260679,
ArahimetheManifestedMikanko = 75771170
ArahimetheManifestedMikanko = 75771170,
YubelDasEwigLiebeWächter = 47172959
}
}
......@@ -210,6 +210,7 @@
TGGlaiveBlaster = 95973569,
StellarNemesisTPHON_DoomsdayStar = 93039339,
SPLittleKnight = 29301450,
AngelRing = 40678060
AngelRing = 40678060,
SkullGuardianTheSilenforcingProtector = 10774240
}
}
......@@ -109,6 +109,11 @@
NightmareMagician = 40221691,
ArahimetheManifestedMikanko = 75771170,
UFOLight = 9275482,
TaotheGreatChanter = 34541543
TaotheGreatChanter = 34541543,
SpiritOfYubel = 90829280,
DarkGuardian = 26746975,
EnvoyOfTheWaxState = 87462901,
Fluffyfluff = 85401123,
YubelDasEwigLiebeWächter = 47172959
}
}
......@@ -49,6 +49,8 @@
Blackwing_FullArmoredWing = 54082269,
DragunofRedEyes = 37818794,
RedEyesBDragon = 74677422, // sometimes the name of DragunofRedEyes will be changed to RedEyesBDragon
TheArrivalCyberseIgnister = 11738489
TheArrivalCyberseIgnister = 11738489,
MajespecterPorcupineYamaarashi = 51073802,
RaidraptorRisingRebellionFalcon = 71222868
}
}
......@@ -95,6 +95,11 @@ namespace WindBot.Game.AI
// For overriding
}
public virtual void OnChainSolved(int chainIndex)
{
// For overriding
}
public virtual void OnChainEnd()
{
// For overriding
......
using System.Collections.Generic;
using System.Collections.Generic;
using YGOSharp.OCGWrapper.Enums;
namespace WindBot.Game
......@@ -26,6 +26,8 @@ namespace WindBot.Game
public int LastSummonPlayer { get; set; }
public IList<ClientCard> SummoningCards { get; set; }
public IList<ClientCard> LastSummonedCards { get; set; }
public int SolvingChainIndex { get; set; }
public IList<int> NegatedChainIndexList { get; set; }
public Duel()
{
......@@ -41,6 +43,8 @@ namespace WindBot.Game
LastSummonPlayer = -1;
SummoningCards = new List<ClientCard>();
LastSummonedCards = new List<ClientCard>();
SolvingChainIndex = 0;
NegatedChainIndexList = new List<int>();
}
public ClientCard GetCard(int player, CardLocation loc, int seq)
......@@ -169,5 +173,16 @@ namespace WindBot.Game
{
return IsFirst ? player : 1 - player;
}
public ClientCard GetCurrentSolvingChainCard()
{
if (SolvingChainIndex == 0 || SolvingChainIndex > CurrentChain.Count) return null;
return CurrentChain[SolvingChainIndex - 1];
}
public bool IsCurrentSolvingChainNegated()
{
return SolvingChainIndex > 0 && NegatedChainIndexList.Contains(SolvingChainIndex);
}
}
}
\ No newline at end of file
......@@ -141,6 +141,11 @@ namespace WindBot.Game
{
Executor.OnChaining(player,card);
}
public void OnChainSolved(int chainIndex)
{
Executor.OnChainSolved(chainIndex);
}
/// <summary>
/// Called when a chain has been solved.
......@@ -300,6 +305,8 @@ namespace WindBot.Game
// Always select the first available cards and choose the minimum.
IList<ClientCard> selected = new List<ClientCard>();
if (hint == HintMsg.AttackTarget && cancelable) return selected;
if (cards.Count >= min)
{
for (int i = 0; i < min; ++i)
......
......@@ -109,6 +109,10 @@ namespace WindBot.Game
_messages.Add(GameMessage.AttackDisabled, OnAttackDisabled);
_messages.Add(GameMessage.PosChange, OnPosChange);
_messages.Add(GameMessage.Chaining, OnChaining);
_messages.Add(GameMessage.ChainSolving, OnChainSolving);
_messages.Add(GameMessage.ChainNegated, OnChainNegated);
_messages.Add(GameMessage.ChainDisabled, OnChainDisabled);
_messages.Add(GameMessage.ChainSolved, OnChainSolved);
_messages.Add(GameMessage.ChainEnd, OnChainEnd);
_messages.Add(GameMessage.SortCard, OnCardSorting);
_messages.Add(GameMessage.SortChain, OnChainSorting);
......@@ -362,6 +366,19 @@ namespace WindBot.Game
extra = packet.ReadInt16();
_duel.Fields[GetLocalPlayer(1)].Init(deck, extra);
// in case of ending duel in chain's solving
_duel.LastChainPlayer = -1;
_duel.LastChainLocation = 0;
_duel.CurrentChain.Clear();
_duel.ChainTargets.Clear();
_duel.LastChainTargets.Clear();
_duel.ChainTargetOnly.Clear();
_duel.LastSummonPlayer = -1;
_duel.SummoningCards.Clear();
_duel.LastSummonedCards.Clear();
_duel.SolvingChainIndex = 0;
_duel.NegatedChainIndexList.Clear();
Logger.DebugWriteLine("Duel started: " + _room.Names[0] + " versus " + _room.Names[1]);
_ai.OnStart();
}
......@@ -742,6 +759,30 @@ namespace WindBot.Game
}
private void OnChainSolving(BinaryReader packet)
{
int chainIndex = packet.ReadByte();
_duel.SolvingChainIndex = chainIndex;
}
private void OnChainNegated(BinaryReader packet)
{
int chainIndex = packet.ReadByte();
_duel.NegatedChainIndexList.Add(chainIndex);
}
private void OnChainDisabled(BinaryReader packet)
{
int chainIndex = packet.ReadByte();
_duel.NegatedChainIndexList.Add(chainIndex);
}
private void OnChainSolved(BinaryReader packet)
{
int chainIndex = packet.ReadByte();
_ai.OnChainSolved(chainIndex);
}
private void OnChainEnd(BinaryReader packet)
{
_ai.OnChainEnd();
......@@ -751,6 +792,8 @@ namespace WindBot.Game
_duel.ChainTargets.Clear();
_duel.LastChainTargets.Clear();
_duel.ChainTargetOnly.Clear();
_duel.SolvingChainIndex = 0;
_duel.NegatedChainIndexList.Clear();
}
private void OnCardSorting(BinaryReader packet)
......@@ -1083,7 +1126,7 @@ namespace WindBot.Game
int count = packet.ReadByte();
packet.ReadByte(); // specount
bool forced = packet.ReadByte() != 0;
packet.ReadInt32(); // hint1
int hint1 = packet.ReadInt32(); // hint1
int hint2 = packet.ReadInt32(); // hint2
IList<ClientCard> cards = new List<ClientCard>();
......@@ -1124,7 +1167,7 @@ namespace WindBot.Game
return;
}
Connection.Send(CtosMessage.Response, _ai.OnSelectChain(cards, descs, forced, hint2));
Connection.Send(CtosMessage.Response, _ai.OnSelectChain(cards, descs, forced, hint1 | hint2));
}
private void OnSelectCounter(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