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

Add AI_Swordsoul (#170)

parent cfbdc0de
...@@ -199,6 +199,11 @@ Name=玻璃女巫 Deck=Exosister Dialog=verre.zh-CN ...@@ -199,6 +199,11 @@ Name=玻璃女巫 Deck=Exosister Dialog=verre.zh-CN
救祓少女卡组。 救祓少女卡组。
AI_LV3 SUPPORT_MASTER_RULE_3 SUPPORT_MASTER_RULE_2020 AI_LV3 SUPPORT_MASTER_RULE_3 SUPPORT_MASTER_RULE_2020
!艾克莉西娅-相剑
Name=艾克莉西娅 Deck=Swordsoul Dialog=ecclesia.zh-CN
相剑卡组。
AI_LV3 SUPPORT_MASTER_RULE_3 SUPPORT_MASTER_RULE_2020
!神数不神-刹帝利 !神数不神-刹帝利
Name=神数不神 Deck=Kashtira Dialog=Zefra.zh-CN Name=神数不神 Deck=Kashtira Dialog=Zefra.zh-CN
俱舍怒威族卡组。 俱舍怒威族卡组。
......
#created by ...
#main
27204311
87052196
87052196
23431858
93490856
93490856
93490856
56495147
56495147
56495147
20001443
20001443
20001443
55273560
55273560
55273560
14558127
14558127
14558127
23434538
23434538
23434538
97268402
97268402
97268402
98159737
35261759
35261759
56465981
56465981
56465981
93850690
24224830
24224830
65681983
10045474
10045474
10045474
14821890
14821890
#extra
42632209
60465049
96633955
84815190
47710198
9464441
5041348
69248256
69248256
83755611
43202238
78917791
32519092
32519092
32519092
!side
{
"welcome": [
"这里就是大灵峰吗?"
],
"deckerror": [
"{0}被冰水咒缚了!"
],
"duelstart": [
"走了好久,肚子饿了……",
"前方会遇到怎样的同伴呢?",
"有阿不思在一起的话……"
],
"newturn": [
"我的回合!"
],
"endturn": [
"姐姐到底在哪里……",
"阿不思的干粮也吃完了啊。",
"什么时候开饭呢?"
],
"directattack": [
"{0},直接攻击!",
"开饭!"
],
"attack": [
"用{0}攻击{1}!"
],
"ondirectattack": [
"好饿……",
"呜呜……",
"姐姐……"
],
"facedownmonstername": "怪兽",
"activate": [
"发动{0}的效果!"
],
"summon": [
"{0}召唤!",
"出来吧,{0}!"
],
"setmonster": [
"……"
],
"chaining": [
"发动{0}的效果!",
"{0}!"
]
}
This source diff could not be displayed because it is too large. You can view the blob instead.
...@@ -319,6 +319,40 @@ namespace WindBot.Game.AI ...@@ -319,6 +319,40 @@ namespace WindBot.Game.AI
return card.Level <= 4 && Bot.GetMonsters().Count(m => m.IsFaceup()) == 0 && Util.IsAllEnemyBetterThanValue(card.Attack, true); return card.Level <= 4 && Bot.GetMonsters().Count(m => m.IsFaceup()) == 0 && Util.IsAllEnemyBetterThanValue(card.Attack, true);
} }
/// <summary>
/// Called when the AI has to select one or more cards.
/// </summary>
/// <param name="cards">List of available cards.</param>
/// <param name="min">Minimal quantity.</param>
/// <param name="max">Maximal quantity.</param>
/// <param name="hint">The hint message of the select.</param>
/// <param name="cancelable">True if you can return an empty list.</param>
/// <returns>A new list containing the selected cards.</returns>
public override IList<ClientCard> OnSelectCard(IList<ClientCard> cards, int min, int max, int hint, bool cancelable)
{
// wordaround for Dogmatika Alba Zoa
int albaZoaCount = Bot.ExtraDeck.Count / 2;
if (!cancelable && min == albaZoaCount && max == albaZoaCount
&& Duel.Player == 1 && (Duel.Phase == DuelPhase.Main1 || Duel.Phase == DuelPhase.Main2) && cards.All(card =>
card.Controller == 0 && (card.Location == CardLocation.Hand || card.Location == CardLocation.Extra)))
{
Logger.DebugWriteLine("Dogmatika Alba Zoa solved");
List<ClientCard> extraDeck = new List<ClientCard>(Bot.ExtraDeck);
int shuffleCount = extraDeck.Count;
while (shuffleCount-- > 1)
{
int index = Program.Rand.Next(extraDeck.Count);
ClientCard tempCard = extraDeck[shuffleCount];
extraDeck[shuffleCount] = extraDeck[index];
extraDeck[index] = tempCard;
}
return Util.CheckSelectCount(extraDeck, cards, min, max);
}
return null;
}
/// <summary> /// <summary>
/// Destroy face-down cards first, in our turn. /// Destroy face-down cards first, in our turn.
/// </summary> /// </summary>
......
...@@ -22,6 +22,7 @@ namespace WindBot.Game.AI ...@@ -22,6 +22,7 @@ namespace WindBot.Game.AI
protected ExecutorType Type { get; private set; } protected ExecutorType Type { get; private set; }
protected ClientCard Card { get; private set; } protected ClientCard Card { get; private set; }
protected int ActivateDescription { get; private set; } protected int ActivateDescription { get; private set; }
protected int CurrentTiming { get; private set; }
protected ClientField Bot { get; private set; } protected ClientField Bot { get; private set; }
protected ClientField Enemy { get; private set; } protected ClientField Enemy { get; private set; }
...@@ -233,11 +234,12 @@ namespace WindBot.Game.AI ...@@ -233,11 +234,12 @@ namespace WindBot.Game.AI
/// <summary> /// <summary>
/// Set global variables Type, Card, ActivateDescription for Executor /// Set global variables Type, Card, ActivateDescription for Executor
/// </summary> /// </summary>
public void SetCard(ExecutorType type, ClientCard card, int description) public void SetCard(ExecutorType type, ClientCard card, int description, int timing = -1)
{ {
Type = type; Type = type;
Card = card; Card = card;
ActivateDescription = description; ActivateDescription = description;
CurrentTiming = timing;
} }
/// <summary> /// <summary>
......
...@@ -309,8 +309,9 @@ namespace WindBot.Game ...@@ -309,8 +309,9 @@ namespace WindBot.Game
/// <param name="cards">List of activable cards.</param> /// <param name="cards">List of activable cards.</param>
/// <param name="descs">List of effect descriptions.</param> /// <param name="descs">List of effect descriptions.</param>
/// <param name="forced">You can't return -1 if this param is true.</param> /// <param name="forced">You can't return -1 if this param is true.</param>
/// <param name="timing">Current hint timing</param>
/// <returns>Index of the activated card or -1.</returns> /// <returns>Index of the activated card or -1.</returns>
public int OnSelectChain(IList<ClientCard> cards, IList<int> descs, bool forced) public int OnSelectChain(IList<ClientCard> cards, IList<int> descs, bool forced, int timing = -1)
{ {
Executor.OnSelectChain(cards); Executor.OnSelectChain(cards);
foreach (CardExecutor exec in Executor.Executors) foreach (CardExecutor exec in Executor.Executors)
...@@ -318,7 +319,7 @@ namespace WindBot.Game ...@@ -318,7 +319,7 @@ namespace WindBot.Game
for (int i = 0; i < cards.Count; ++i) for (int i = 0; i < cards.Count; ++i)
{ {
ClientCard card = cards[i]; ClientCard card = cards[i];
if (ShouldExecute(exec, card, ExecutorType.Activate, descs[i])) if (ShouldExecute(exec, card, ExecutorType.Activate, descs[i], timing))
{ {
_dialogs.SendChaining(card.Name); _dialogs.SendChaining(card.Name);
return i; return i;
...@@ -1121,7 +1122,7 @@ namespace WindBot.Game ...@@ -1121,7 +1122,7 @@ namespace WindBot.Game
return new BattlePhaseAction(BattlePhaseAction.BattleAction.ToMainPhaseTwo); return new BattlePhaseAction(BattlePhaseAction.BattleAction.ToMainPhaseTwo);
} }
private bool ShouldExecute(CardExecutor exec, ClientCard card, ExecutorType type, int desc = -1) private bool ShouldExecute(CardExecutor exec, ClientCard card, ExecutorType type, int desc = -1, int timing = -1)
{ {
if (card.Id != 0 && type == ExecutorType.Activate) if (card.Id != 0 && type == ExecutorType.Activate)
{ {
...@@ -1130,7 +1131,7 @@ namespace WindBot.Game ...@@ -1130,7 +1131,7 @@ namespace WindBot.Game
if (!Executor.OnPreActivate(card)) if (!Executor.OnPreActivate(card))
return false; return false;
} }
Executor.SetCard(type, card, desc); Executor.SetCard(type, card, desc, timing);
bool result = card != null && exec.Type == type && bool result = card != null && exec.Type == type &&
(exec.CardId == -1 || exec.CardId == card.Id) && (exec.CardId == -1 || exec.CardId == card.Id) &&
(exec.Func == null || exec.Func()); (exec.Func == null || exec.Func());
......
...@@ -1078,7 +1078,7 @@ namespace WindBot.Game ...@@ -1078,7 +1078,7 @@ namespace WindBot.Game
packet.ReadByte(); // specount packet.ReadByte(); // specount
bool forced = packet.ReadByte() != 0; bool forced = packet.ReadByte() != 0;
packet.ReadInt32(); // hint1 packet.ReadInt32(); // hint1
packet.ReadInt32(); // hint2 int hint2 = packet.ReadInt32(); // hint2
IList<ClientCard> cards = new List<ClientCard>(); IList<ClientCard> cards = new List<ClientCard>();
IList<int> descs = new List<int>(); IList<int> descs = new List<int>();
...@@ -1118,7 +1118,7 @@ namespace WindBot.Game ...@@ -1118,7 +1118,7 @@ namespace WindBot.Game
return; return;
} }
Connection.Send(CtosMessage.Response, _ai.OnSelectChain(cards, descs, forced)); Connection.Send(CtosMessage.Response, _ai.OnSelectChain(cards, descs, forced, hint2));
} }
private void OnSelectCounter(BinaryReader packet) private void OnSelectCounter(BinaryReader packet)
......
...@@ -106,6 +106,7 @@ ...@@ -106,6 +106,7 @@
<Compile Include="Game\AI\Decks\PhantasmExecutor.cs" /> <Compile Include="Game\AI\Decks\PhantasmExecutor.cs" />
<Compile Include="Game\AI\Decks\QliphortExecutor.cs" /> <Compile Include="Game\AI\Decks\QliphortExecutor.cs" />
<Compile Include="Game\AI\Decks\ST1732Executor.cs" /> <Compile Include="Game\AI\Decks\ST1732Executor.cs" />
<Compile Include="Game\AI\Decks\SwordsoulExecutor.cs" />
<Compile Include="Game\AI\Decks\TrickstarExecutor.cs" /> <Compile Include="Game\AI\Decks\TrickstarExecutor.cs" />
<Compile Include="Game\AI\Decks\WitchcraftExecutor.cs" /> <Compile Include="Game\AI\Decks\WitchcraftExecutor.cs" />
<Compile Include="Game\AI\Decks\YosenjuExecutor.cs" /> <Compile Include="Game\AI\Decks\YosenjuExecutor.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