Commit 5950a280 authored by wind2009's avatar wind2009

Merge branch 'master' of https://github.com/mycard/windbot into 2pick

parents a27db336 e8280715
name: Automated Test Build
on:
push:
branches: [ "master" ]
pull_request:
branches: [ "master" ]
jobs:
build:
runs-on: windows-2019
env:
Solution_Name: WindBot.sln
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Setup MSBuild.exe
uses: microsoft/setup-msbuild@v1
- name: Build!
run: msbuild $env:Solution_Name /t:Build /p:Configuration=Release
- name: Pack
run: |
mkdir dist
xcopy /e /y bin\Release dist\WindBot\
xcopy /y BotWrapper\bin\Release\bot.conf dist\
xcopy /y BotWrapper\bin\Release\bot.exe dist\
cd dist
7z a WindBot.7z *
cd ..
- name: Upload build artifacts
uses: actions/upload-artifact@v3
with:
path: dist\WindBot.7z
- name: GitHub Release
if: github.event_name == 'push'
uses: marvinpinto/action-automatic-releases@latest
with:
repo_token: "${{ secrets.GITHUB_TOKEN }}"
automatic_release_tag: "latest"
prerelease: true
title: "Development Build"
files: |
dist/WindBot.7z
......@@ -26,7 +26,7 @@ SUPPORT_MASTER_RULE_2020
!P2-自选卡组
Name=P2 Deck=Lucky Dialog=gugugu.zh-CN
人机卡组由你选择。随缘出牌。可将你的卡组文件(.ydk)复制到WindBot的对应文件夹。
人机卡组由你选择。随缘出牌。
SELECT_DECKFILE SUPPORT_MASTER_RULE_3 SUPPORT_NEW_MASTER_RULE SUPPORT_MASTER_RULE_2020
!谜之剑士LV4-龙骑星爆
......@@ -209,11 +209,16 @@ Name=朱露咲浅羽 Deck=Salamangreat Dialog=nlch.zh-CN
浅羽的香喷喷曲奇。
AI_LV3 SUPPORT_NEW_MASTER_RULE SUPPORT_MASTER_RULE_2020
!朱露咲浅羽-真红眼
Name=朱露咲浅羽 Deck=Dragun Dialog=nlch.zh-CN
!我太帅了-真红眼龙骑士
Name=我太帅了 Deck=Dragun Dialog=smart.zh-CN
超魔导真红眼龙骑士卡组。
AI_LV3 SUPPORT_MASTER_RULE_3 SUPPORT_NEW_MASTER_RULE SUPPORT_MASTER_RULE_2020
!我太帅了-水百凤凰勇者
Name=我太帅了 Deck=Brave Dialog=smart.zh-CN
水机百头龙凤凰人勇者卡组。
AI_LV3 SUPPORT_MASTER_RULE_2020
!玻璃女巫
Name=玻璃女巫 Deck=Witchcraft Dialog=verre.zh-CN
魔女术卡组。
......
#created by ...
#main
2563463
81866673
72090076
63362460
30680659
30680659
30680659
26202165
26202165
26202165
91646304
14558127
14558127
14558127
72291078
72291078
23434538
23434538
9742784
97268402
3285551
3285551
3285551
18144506
52947044
52947044
52947044
81439173
83764718
24224830
24224830
65681983
65681983
39568067
38745520
10045474
10045474
10045474
40605147
40605147
#extra
15291624
60461804
84815190
92519087
27548199
42566602
90953320
98558751
21915012
44097050
50588353
70369116
98978921
98978921
60303245
!side
55063751
55063751
55063751
34267821
34267821
34267821
43534808
43534808
43534808
94145021
94145021
94145021
14532163
14532163
14532163
......@@ -12,7 +12,7 @@
"接下来就是我的舞台"
],
"endturn": [
"我的回合结束,试试来击溃我吧"
"每个人的目的不同,我更注重强度,我只想赢。"
],
"directattack": [
"老子上了,要你的命"
......
......@@ -22,7 +22,7 @@
"directattack": [
"{0},直接攻击!",
"不过如此嘛,直接攻击!",
"快走开,我要回去睡觉了。",
"快走开,我要回去睡觉了。"
],
"attack": [
"{0},攻击{1}!",
......
This diff is collapsed.
......@@ -523,7 +523,7 @@ namespace WindBot.Game.AI.Decks
targets.Add(e_c);
if (targets.Count >= 5)
{
AI.SelectCard(targets);
AI.SelectMaterials(targets, HintMsg.Remove);
/*AI.SelectCard(new[] {
CardId.BingirsuTheWorldChaliceWarrior,
CardId.TopologicTrisbaena,
......@@ -548,7 +548,7 @@ namespace WindBot.Game.AI.Decks
targets.Add(s_c);
if (targets.Count >= 5)
{
AI.SelectCard(targets);
AI.SelectMaterials(targets, HintMsg.Remove);
return true;
}
}
......
......@@ -468,13 +468,13 @@ namespace WindBot.Game.AI.Decks
IList<ClientCard> material_list = new List<ClientCard>();
if(Bot.HasInExtra(CardId.BorreloadDragon))
{
AI.SelectCard(
AI.SelectMaterials(new[] {
CardId.TopologicBomberDragon,
CardId.TopologicTrisbaena,
CardId.KnightmareGryphon,
CardId.SummonSorceress,
CardId.BorreloadDragon
);
}, HintMsg.Remove);
}
else
{
......@@ -483,6 +483,7 @@ namespace WindBot.Game.AI.Decks
if (material_list.Count == 5) break;
material_list.Add(m);
}
AI.SelectMaterials(material_list, HintMsg.Remove);
}
return true;
}
......
......@@ -709,7 +709,7 @@ namespace WindBot.Game.AI.Decks
targets.Add(e_c);
if (targets.Count >= 5)
{
AI.SelectCard(targets);
AI.SelectMaterials(targets, HintMsg.Remove);
return true;
}
}
......@@ -719,7 +719,7 @@ namespace WindBot.Game.AI.Decks
targets.Add(s_c);
if (targets.Count >= 5)
{
AI.SelectCard(targets);
AI.SelectMaterials(targets, HintMsg.Remove);
return true;
}
}
......
......@@ -63,6 +63,7 @@ namespace WindBot.Game.AI
public const int SolemnWarning = 84749824;
public const int SolemnStrike = 40605147;
public const int TorrentialTribute = 53582587;
public const int EvenlyMatched = 15693423;
public const int HeavyStorm = 19613556;
public const int HammerShot = 26412047;
public const int DarkHole = 53129443;
......@@ -106,6 +107,7 @@ namespace WindBot.Game.AI
public const int MacroCosmos = 30241314;
public const int UpstartGoblin = 70368879;
public const int CyberEmergency = 60600126;
public const int TheAgentOfCreationVenus = 64734921;
public const int EaterOfMillions = 63845230;
......@@ -471,7 +473,8 @@ namespace WindBot.Game.AI
int[] ignoreList = {
_CardId.MacroCosmos,
_CardId.UpstartGoblin,
_CardId.CyberEmergency
_CardId.CyberEmergency,
_CardId.TheAgentOfCreationVenus
};
if (Util.GetLastChainCard().IsCode(ignoreList))
return false;
......@@ -500,8 +503,9 @@ namespace WindBot.Game.AI
/// </summary>
protected bool DefaultEffectVeiler()
{
if (Util.GetLastChainCard() != null && Util.GetLastChainCard().IsCode(_CardId.GalaxySoldier) && Enemy.Hand.Count >= 3) return false;
if (Util.ChainContainsCard(_CardId.EffectVeiler))
ClientCard LastChainCard = Util.GetLastChainCard();
if (LastChainCard != null && (LastChainCard.IsCode(_CardId.GalaxySoldier) && Enemy.Hand.Count >= 3
|| LastChainCard.IsCode(_CardId.EffectVeiler, _CardId.InfiniteImpermanence)))
return false;
return DefaultBreakthroughSkill();
}
......@@ -539,7 +543,9 @@ namespace WindBot.Game.AI
protected bool DefaultInfiniteImpermanence()
{
// TODO: disable s & t
if (!DefaultUniqueTrap())
ClientCard LastChainCard = Util.GetLastChainCard();
if (LastChainCard != null && (LastChainCard.IsCode(_CardId.GalaxySoldier) && Enemy.Hand.Count >= 3
|| LastChainCard.IsCode(_CardId.EffectVeiler, _CardId.InfiniteImpermanence)))
return false;
return DefaultDisableMonster();
}
......@@ -788,16 +794,17 @@ namespace WindBot.Game.AI
_CardId.EvilswarmExcitonKnight,
_CardId.BlackRoseDragon,
_CardId.JudgmentDragon,
_CardId.TopologicTrisbaena
_CardId.TopologicTrisbaena,
_CardId.EvenlyMatched
};
int[] destroyAllOpponentList =
int[] destroyAllOpponentSpellList =
{
_CardId.HarpiesFeatherDuster,
_CardId.DarkMagicAttack
};
if (Util.ChainContainsCard(destroyAllList)) return true;
if (Enemy.HasInSpellZone(destroyAllOpponentList, true)) return true;
if (Enemy.HasInSpellZone(destroyAllOpponentSpellList, true) && Card.Location == CardLocation.SpellZone) return true;
// TODO: ChainContainsCard(id, player)
return false;
}
......
......@@ -10,6 +10,8 @@
z5 = 0x20,
z6 = 0x40,
FieldZone = 0x20,
MonsterZones = 0x7f,
MainMonsterZones = 0x1f,
ExtraMonsterZones = 0x60,
......
......@@ -248,6 +248,11 @@ namespace WindBot.Game
return HasInHand(cardId) || HasInGraveyard(cardId);
}
public bool HasInGraveyardOrInBanished(int cardId)
{
return HasInBanished(cardId) || HasInGraveyard(cardId);
}
public bool HasInMonstersZoneOrInGraveyard(int cardId)
{
return HasInMonstersZone(cardId) || HasInGraveyard(cardId);
......
......@@ -88,7 +88,7 @@ namespace WindBot.Game
ClientCard card = cards[seq];
if (card == null || subSeq >= card.Overlays.Count)
return null;
return null; // TODO card.Overlays[subSeq]
return new ClientCard(card.Overlays[subSeq], CardLocation.Overlay, 0, 0);
}
return cards[seq];
......
......@@ -98,6 +98,7 @@ namespace WindBot.Game
m_position.Clear();
m_selector_pointer = -1;
m_materialSelector = null;
m_materialSelectorHint = 0;
m_option = -1;
m_yesno = -1;
m_announce = 0;
......@@ -266,10 +267,18 @@ namespace WindBot.Game
}
}
else
{
if (m_materialSelector != null && hint == m_materialSelectorHint)
{
//Logger.DebugWriteLine("m_materialSelector hint match");
selector = m_materialSelector;
}
else
{
// Update the next selector.
selector = GetSelectedCards();
}
}
// If we selected a card, use this card.
if (selector != null)
......@@ -464,13 +473,13 @@ namespace WindBot.Game
/// <returns>Index of the selected option.</returns>
public int OnSelectOption(IList<int> options)
{
if (m_option != -1 && m_option < options.Count)
return m_option;
int result = Executor.OnSelectOption(options);
if (result != -1)
return result;
if (m_option != -1 && m_option < options.Count)
return m_option;
return 0; // Always select the first option.
}
......@@ -745,6 +754,7 @@ namespace WindBot.Game
private CardSelector m_materialSelector;
private int m_materialSelectorHint;
private int m_place;
private int m_option;
private int m_number;
......@@ -912,34 +922,40 @@ namespace WindBot.Game
m_selector.Insert(m_selector_pointer, new CardSelector(loc));
}
public void SelectMaterials(ClientCard card)
public void SelectMaterials(ClientCard card, int hint = 0)
{
m_materialSelector = new CardSelector(card);
m_materialSelectorHint = hint;
}
public void SelectMaterials(IList<ClientCard> cards)
public void SelectMaterials(IList<ClientCard> cards, int hint = 0)
{
m_materialSelector = new CardSelector(cards);
m_materialSelectorHint = hint;
}
public void SelectMaterials(int cardId)
public void SelectMaterials(int cardId, int hint = 0)
{
m_materialSelector = new CardSelector(cardId);
m_materialSelectorHint = hint;
}
public void SelectMaterials(IList<int> ids)
public void SelectMaterials(IList<int> ids, int hint = 0)
{
m_materialSelector = new CardSelector(ids);
m_materialSelectorHint = hint;
}
public void SelectMaterials(CardLocation loc)
public void SelectMaterials(CardLocation loc, int hint = 0)
{
m_materialSelector = new CardSelector(loc);
m_materialSelectorHint = hint;
}
public void CleanSelectMaterials()
{
m_materialSelector = null;
m_materialSelectorHint = 0;
}
public bool HaveSelectedCards()
......
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text.RegularExpressions;
using WindBot.Game.AI;
using YGOSharp.Network;
......@@ -105,6 +106,7 @@ namespace WindBot.Game
_messages.Add(GameMessage.ShuffleHand, OnShuffleHand);
_messages.Add(GameMessage.ShuffleExtra, OnShuffleExtra);
_messages.Add(GameMessage.ShuffleSetCard, OnShuffleSetCard);
_messages.Add(GameMessage.SwapGraveDeck, OnSwapGraveDeck);
_messages.Add(GameMessage.TagSwap, OnTagSwap);
_messages.Add(GameMessage.NewTurn, OnNewTurn);
_messages.Add(GameMessage.NewPhase, OnNewPhase);
......@@ -489,6 +491,36 @@ namespace WindBot.Game
}
}
private void OnSwapGraveDeck(BinaryReader packet)
{
int player = GetLocalPlayer(packet.ReadByte());
IList<ClientCard> tmpDeckList = _duel.Fields[player].Deck.ToList();
_duel.Fields[player].Deck.Clear();
int seq = 0;
foreach(var card in _duel.Fields[player].Graveyard)
{
if (card.IsExtraCard())
{
_duel.Fields[player].ExtraDeck.Add(card);
card.Location = CardLocation.Extra;
card.Position = (int)CardPosition.FaceDown;
// TODO: face-up P cards
}
else
{
_duel.Fields[player].Deck.Add(card);
card.Location = CardLocation.Deck;
card.Sequence = seq++;
}
}
_duel.Fields[player].Graveyard.Clear();
foreach (var card in tmpDeckList)
{
_duel.Fields[player].Graveyard.Add(card);
card.Location = CardLocation.Grave;
}
}
private void OnTagSwap(BinaryReader packet)
{
int player = GetLocalPlayer(packet.ReadByte());
......@@ -1039,6 +1071,7 @@ namespace WindBot.Game
int seq = packet.ReadByte();
packet.ReadByte(); // pos
}
if (count2 == 0) cancelable = false;
IList<ClientCard> selected = func(cards, (finishable ? 0 : 1), 1, _select_hint, cancelable);
......@@ -1297,6 +1330,12 @@ namespace WindBot.Game
location = CardLocation.SpellZone;
filter = (field >> 8) & Zones.SpellZones;
}
else if ((field & 0x2000) != 0)
{
player = 0;
location = CardLocation.FieldZone;
filter = Zones.FieldZone;
}
else if ((field & 0xc000) != 0)
{
player = 0;
......@@ -1315,6 +1354,12 @@ namespace WindBot.Game
location = CardLocation.SpellZone;
filter = (field >> 24) & Zones.SpellZones;
}
else if ((field & 0x20000000) != 0)
{
player = 1;
location = CardLocation.FieldZone;
filter = Zones.FieldZone;
}
else
{
player = 1;
......@@ -1328,7 +1373,7 @@ namespace WindBot.Game
byte[] resp = new byte[3];
resp[0] = (byte)GetLocalPlayer(player);
if (location != CardLocation.PendulumZone)
if (location != CardLocation.PendulumZone && location != CardLocation.FieldZone)
{
resp[1] = (byte)location;
if ((selected & filter) > 0)
......@@ -1348,8 +1393,9 @@ namespace WindBot.Game
if ((selected & filter) > 0)
filter &= selected;
if ((filter & Zones.z0) != 0) resp[2] = 6;
if ((filter & Zones.z1) != 0) resp[2] = 7;
if ((filter & Zones.FieldZone) != 0) resp[2] = 5;
if ((filter & Zones.z0) != 0) resp[2] = 6; // left pendulum zone
if ((filter & Zones.z1) != 0) resp[2] = 7; // right pendulum zone
}
BinaryWriter reply = GamePacketFactory.Create(CtosMessage.Response);
......
......@@ -52,6 +52,9 @@ namespace WindBot
if (!File.Exists(absolutePath))
// In case windbot is placed in a folder under ygopro folder
absolutePath = Path.GetFullPath("../" + databasePath);
if (!File.Exists(absolutePath))
// In case windbot is placed in a folder under ygopro2 folder
absolutePath = Path.GetFullPath("../cdb/" + databasePath);
if (!File.Exists(absolutePath))
{
Logger.WriteErrorLine("Can't find cards database file.");
......
......@@ -79,6 +79,8 @@ WindBot can run as a "server", provide a http interface to create bot.
* BlueEyesMaxDragon
* Brave
* ChainBurn
* DarkMagician
......
......@@ -70,6 +70,7 @@
<Compile Include="Game\AI\DeckAttribute.cs" />
<Compile Include="Game\AI\DecksManager.cs" />
<Compile Include="Game\AI\Decks\AltergeistExecutor.cs" />
<Compile Include="Game\AI\Decks\BraveExecutor.cs" />
<Compile Include="Game\AI\Decks\FamiliarPossessedExecutor.cs" />
<Compile Include="Game\AI\Decks\BlackwingExecutor.cs" />
<Compile Include="Game\AI\Decks\LuckyExecutor.cs" />
......
......@@ -26,7 +26,7 @@ namespace WindBot
Host = "127.0.0.1";
Port = 7911;
HostInfo = "";
Version = 0x1353;
Version = 0x1354;
Hand = 0;
Debug = false;
Chat = true;
......
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