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

Add HintMsg and operation for it in OnSelectCard() (#142)

parent bbb765d1
......@@ -2742,8 +2742,6 @@ namespace WindBot.Game.AI.Decks
public override IList<ClientCard> OnSelectCard(IList<ClientCard> cards, int min, int max, int hint, bool cancelable)
{
int HIINT_TOGRAVE = 504;
if (max == 1 && cards[0].Location == CardLocation.Deck
&& Util.GetLastChainCard() != null && Util.GetLastChainCard().IsCode(23002292) && Bot.GetRemainingCount(CardId.WakingtheDragon,1) > 0)
{
......@@ -2764,7 +2762,7 @@ namespace WindBot.Game.AI.Decks
Logger.DebugWriteLine("EvenlyMatched: min=" + min.ToString() + ", max=" + max.ToString());
}
else if (cards[0].Location == CardLocation.Hand && cards[cards.Count - 1].Location == CardLocation.Hand
&& (hint == 501 || hint == HIINT_TOGRAVE) && min == max)
&& (hint == HintMsg.HINTMSG_DISCARD || hint == HintMsg.HINTMSG_TOGRAVE) && min == max)
{
if (Duel.LastChainPlayer == 0 && Util.GetLastChainCard().IsCode(CardId.OneForOne)) return null;
Logger.DebugWriteLine("Hand drop except OneForOne");
......
......@@ -65,6 +65,12 @@ namespace WindBot.Game.AI.Decks
AddExecutor(ExecutorType.Activate, _CardId.EvilswarmExcitonKnight, DefaultEvilswarmExcitonKnightEffect);
}
public List<int> REMOVE_HINTMSG = new List<int>
{
HintMsg.HINTMSG_RELEASE, HintMsg.HINTMSG_DESTROY, HintMsg.HINTMSG_REMOVE, HintMsg.HINTMSG_TOGRAVE,
HintMsg.HINTMSG_RTOHAND, HintMsg.HINTMSG_TODECK, HintMsg.HINTMSG_DISABLE
};
public override IList<ClientCard> OnSelectCard(IList<ClientCard> _cards, int min, int max, int hint, bool cancelable)
{
if (Duel.Phase == DuelPhase.BattleStart)
......@@ -72,18 +78,50 @@ namespace WindBot.Game.AI.Decks
if (AI.HaveSelectedCards())
return null;
IList<ClientCard> cards = new List<ClientCard>(_cards);
IList<ClientCard> selected = new List<ClientCard>();
IList<ClientCard> cards = new List<ClientCard>(_cards);
if (max > cards.Count)
max = cards.Count;
// select random cards
while (selected.Count < max)
if (REMOVE_HINTMSG.Contains(hint))
{
IList<ClientCard> selfCards = new List<ClientCard>();
IList<ClientCard> enemyCards = new List<ClientCard>();
foreach (ClientCard card in cards)
{
if (card?.Controller == 0)
{
selfCards.Add(card);
} else
{
enemyCards.Add(card);
}
}
// select enemy's card first
while (enemyCards.Count > 0 && selected.Count < max)
{
ClientCard card = enemyCards[Program.Rand.Next(enemyCards.Count)];
selected.Add(card);
enemyCards.Remove(card);
}
while (selfCards.Count > 0 && selected.Count < max)
{
ClientCard card = selfCards[Program.Rand.Next(selfCards.Count)];
selected.Add(card);
selfCards.Remove(card);
}
} else
{
ClientCard card = cards[Program.Rand.Next(cards.Count)];
selected.Add(card);
cards.Remove(card);
// select random cards
while (selected.Count < max)
{
ClientCard card = cards[Program.Rand.Next(cards.Count)];
selected.Add(card);
cards.Remove(card);
}
}
return selected;
......
......@@ -309,8 +309,8 @@ namespace WindBot.Game.AI.Decks
// overwrite OnSelectCard to act normally in SelectUnselect
public override IList<ClientCard> OnSelectCard(IList<ClientCard> cards, int min, int max, int hint, bool cancelable)
{
// Patronus HINTMSG_ATOHAND
if (hint == 506)
// Patronus
if (hint == HintMsg.HINTMSG_ATOHAND)
{
bool flag = true;
foreach(ClientCard card in cards)
......@@ -334,8 +334,8 @@ namespace WindBot.Game.AI.Decks
return selected;
}
}
// MaxxC HINTMSG_SPSUMMON
if (hint == 509 && enemy_activate_MaxxC)
// MaxxC solution
if (hint == HintMsg.HINTMSG_SPSUMMON && enemy_activate_MaxxC)
{
// check whether SS from deck while using effect
bool flag = true;
......@@ -392,8 +392,8 @@ namespace WindBot.Game.AI.Decks
}
}
}
// MadameVerre HINTMSG_CONFIRM
if (hint == 526)
// MadameVerre
if (hint == HintMsg.HINTMSG_CONFIRM)
{
Logger.DebugWriteLine("** min-max: " + min.ToString() + " / " + max.ToString());
foreach (ClientCard card in cards)
......
namespace WindBot.Game.AI
{
public static class HintMsg
{
public const int HINTMSG_RELEASE = 500,
HINTMSG_DISCARD = 501,
HINTMSG_DESTROY = 502,
HINTMSG_REMOVE = 503,
HINTMSG_TOGRAVE = 504,
HINTMSG_RTOHAND = 505,
HINTMSG_ATOHAND = 506,
HINTMSG_TODECK = 507,
HINTMSG_SUMMON = 508,
HINTMSG_SPSUMMON = 509,
HINTMSG_SET = 510,
HINTMSG_FMATERIAL = 511,
HINTMSG_SMATERIAL = 512,
HINTMSG_XMATERIAL = 513,
HINTMSG_FACEUP = 514,
HINTMSG_FACEDOWN = 515,
HINTMSG_ATTACK = 516,
HINTMSG_DEFENSE = 517,
HINTMSG_EQUIP = 518,
HINTMSG_REMOVEXYZ = 519,
HINTMSG_CONTROL = 520,
HINTMSG_DESREPLACE = 521,
HINTMSG_FACEUPATTACK = 522,
HINTMSG_FACEUPDEFENSE = 523,
HINTMSG_FACEDOWNATTACK = 524,
HINTMSG_FACEDOWNDEFENSE = 525,
HINTMSG_CONFIRM = 526,
HINTMSG_TOFIELD = 527,
HINTMSG_POSCHANGE = 528,
HINTMSG_SELF = 529,
HINTMSG_OPPO = 530,
HINTMSG_TRIBUTE = 531,
HINTMSG_DEATTACHFROM = 532,
HINTMSG_LMATERIAL = 533,
HINTMSG_ATTACKTARGET = 549,
HINTMSG_EFFECT = 550,
HINTMSG_TARGET = 551,
HINTMSG_COIN = 552,
HINTMSG_DICE = 553,
HINTMSG_CARDTYPE = 554,
HINTMSG_OPTION = 555,
HINTMSG_RESOLVEEFFECT = 556,
HINTMSG_SELECT = 560,
HINTMSG_POSITION = 561,
HINTMSG_ATTRIBUTE = 562,
HINTMSG_RACE = 563,
HINTMSG_CODE = 564,
HINGMSG_NUMBER = 565,
HINGMSG_LVRANK = 567,
HINTMSG_RESOLVECARD = 568,
HINTMSG_ZONE = 569,
HINTMSG_DISABLEZONE = 570,
HINTMSG_TOZONE = 571,
HINTMSG_COUNTER = 572,
HINTMSG_DISABLE = 573,
HINTMSG_OPERATECARD = 574;
}
}
\ No newline at end of file
......@@ -125,6 +125,7 @@
<Compile Include="Game\AI\Enums\InvincibleMonster.cs" />
<Compile Include="Game\AI\Enums\Floodgate.cs" />
<Compile Include="Game\AI\Executor.cs" />
<Compile Include="Game\AI\HintMsg.cs" />
<Compile Include="Game\AI\Opcodes.cs" />
<Compile Include="Game\AI\Zones.cs" />
<Compile Include="Game\AI\ExecutorType.cs" />
......
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