Commit 0fcae795 authored by mercury233's avatar mercury233

update LuckyExecutor OnSelectCard

parent f0cfe743
using YGOSharp.OCGWrapper.Enums; using YGOSharp.OCGWrapper.Enums;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq;
using WindBot; using WindBot;
using WindBot.Game; using WindBot.Game;
using WindBot.Game.AI; using WindBot.Game.AI;
...@@ -65,10 +66,10 @@ namespace WindBot.Game.AI.Decks ...@@ -65,10 +66,10 @@ namespace WindBot.Game.AI.Decks
AddExecutor(ExecutorType.Activate, _CardId.EvilswarmExcitonKnight, DefaultEvilswarmExcitonKnightEffect); AddExecutor(ExecutorType.Activate, _CardId.EvilswarmExcitonKnight, DefaultEvilswarmExcitonKnightEffect);
} }
public List<int> REMOVE_HINTMSG = new List<int> private List<int> HintMsgForRemove = new List<int>
{ {
HintMsg.Release, HintMsg.Destroy, HintMsg.Remove, HintMsg.ToGrave, HintMsg.Release, HintMsg.Destroy, HintMsg.Remove, HintMsg.ToGrave, HintMsg.ReturnToHand, HintMsg.ToDeck,
HintMsg.ReturnToHand, HintMsg.ToDeck, HintMsg.Disable HintMsg.FusionMaterial, HintMsg.SynchroMaterial, HintMsg.XyzMaterial, HintMsg.LinkMaterial, HintMsg.Disable
}; };
public override IList<ClientCard> OnSelectCard(IList<ClientCard> _cards, int min, int max, int hint, bool cancelable) public override IList<ClientCard> OnSelectCard(IList<ClientCard> _cards, int min, int max, int hint, bool cancelable)
...@@ -83,20 +84,9 @@ namespace WindBot.Game.AI.Decks ...@@ -83,20 +84,9 @@ namespace WindBot.Game.AI.Decks
if (max > cards.Count) if (max > cards.Count)
max = cards.Count; max = cards.Count;
if (REMOVE_HINTMSG.Contains(hint)) if (HintMsgForRemove.Contains(hint))
{ {
IList<ClientCard> selfCards = new List<ClientCard>(); IList<ClientCard> enemyCards = cards.Where(card => card.Controller == 1).ToList();
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 // select enemy's card first
while (enemyCards.Count > 0 && selected.Count < max) while (enemyCards.Count > 0 && selected.Count < max)
...@@ -104,24 +94,16 @@ namespace WindBot.Game.AI.Decks ...@@ -104,24 +94,16 @@ namespace WindBot.Game.AI.Decks
ClientCard card = enemyCards[Program.Rand.Next(enemyCards.Count)]; ClientCard card = enemyCards[Program.Rand.Next(enemyCards.Count)];
selected.Add(card); selected.Add(card);
enemyCards.Remove(card); enemyCards.Remove(card);
cards.Remove(card);
} }
}
while (selfCards.Count > 0 && selected.Count < max) // select random cards
{ while (selected.Count < min)
ClientCard card = selfCards[Program.Rand.Next(selfCards.Count)];
selected.Add(card);
selfCards.Remove(card);
}
} else
{ {
// select random cards ClientCard card = cards[Program.Rand.Next(cards.Count)];
while (selected.Count < max) selected.Add(card);
{ cards.Remove(card);
ClientCard card = cards[Program.Rand.Next(cards.Count)];
selected.Add(card);
cards.Remove(card);
}
} }
return selected; return selected;
......
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