Commit 0111d23e authored by Momobako's avatar Momobako

merge

parents 8a7a0f01 d5ee2352
#created by ...
#main
46986414
46986414
46986414
30603688
30603688
30603688
71007216
71007216
7084129
7084129
7084129
43722862
43722862
14558127
14558127
14824019
23434538
70117860
1784686
1784686
2314238
23314220
70368879
70368879
89739383
41735184
73616671
47222536
47222536
47222536
67775894
67775894
7922915
7922915
7922915
48680970
48680970
48680970
40605147
40605147
#extra
41721210
41721210
50954680
58074177
90036274
14577226
16691074
22110647
80117527
71384012
71384012
71384012
1482001
!side
...@@ -15,6 +15,7 @@ ...@@ -15,6 +15,7 @@
80280944 80280944
48048590 48048590
77723643 77723643
77723643
55623480 55623480
30328508 30328508
30328508 30328508
......
using System.Collections.Generic; using System.Collections.Generic;
using YGOSharp.OCGWrapper.Enums; using YGOSharp.OCGWrapper.Enums;
namespace WindBot.Game.AI namespace WindBot.Game.AI
{ {
public class AIFunctions public class AIFunctions
...@@ -150,7 +149,26 @@ namespace WindBot.Game.AI ...@@ -150,7 +149,26 @@ namespace WindBot.Game.AI
} }
return bestMonster; return bestMonster;
} }
public ClientCard GetWorstBotMonster(bool onlyATK = false)
{
int WorstPower = -1;
ClientCard WorstMonster = null;
for (int i = 0; i < 7; ++i)
{
ClientCard card = Bot.MonsterZone[i];
if (card == null || card.Data == null) continue;
if (onlyATK && card.IsDefense()) continue;
int newPower = card.GetDefensePower();
if (newPower < WorstPower)
{
WorstPower = newPower;
WorstMonster = card;
}
}
return WorstMonster;
}
public ClientCard GetOneEnemyBetterThanValue(int value, bool onlyATK = false, bool canBeTarget = false) public ClientCard GetOneEnemyBetterThanValue(int value, bool onlyATK = false, bool canBeTarget = false)
{ {
ClientCard bestCard = null; ClientCard bestCard = null;
...@@ -250,12 +268,31 @@ namespace WindBot.Game.AI ...@@ -250,12 +268,31 @@ namespace WindBot.Game.AI
List<ClientCard> monsters = Enemy.GetMonsters(); List<ClientCard> monsters = Enemy.GetMonsters();
// after GetHighestAttackMonster, the left monsters must be face-down. // after GetHighestAttackMonster, the left monsters must be face-down.
if (monsters.Count > 0 && !onlyFaceup && (!canBeTarget || !card.IsShouldNotBeTarget())) if (monsters.Count > 0 && !onlyFaceup)
return monsters[0]; return monsters[0];
return null; return null;
} }
public ClientCard GetWorstEnemyMonster(bool onlyATK = false)
{
int WorstPower = -1;
ClientCard WorstMonster = null;
for (int i = 0; i < 7; ++i)
{
ClientCard card = Enemy.MonsterZone[i];
if (card == null || card.Data == null) continue;
if (onlyATK && card.IsDefense()) continue;
int newPower = card.GetDefensePower();
if (newPower < WorstPower)
{
WorstPower = newPower;
WorstMonster = card;
}
}
return WorstMonster;
}
public ClientCard GetBestEnemySpell(bool onlyFaceup = false) public ClientCard GetBestEnemySpell(bool onlyFaceup = false)
{ {
ClientCard card = GetProblematicEnemySpell(); ClientCard card = GetProblematicEnemySpell();
...@@ -337,6 +374,16 @@ namespace WindBot.Game.AI ...@@ -337,6 +374,16 @@ namespace WindBot.Game.AI
return count; return count;
} }
public bool ChainContainPlayer(int player)
{
foreach (ClientCard card in Duel.CurrentChain)
{
if (card.Controller == player)
return true;
}
return false;
}
public bool HasChainedTrap(int player) public bool HasChainedTrap(int player)
{ {
foreach (ClientCard card in Duel.CurrentChain) foreach (ClientCard card in Duel.CurrentChain)
......
This diff is collapsed.
This diff is collapsed.
...@@ -1052,7 +1052,7 @@ namespace WindBot.Game.AI.Decks ...@@ -1052,7 +1052,7 @@ namespace WindBot.Game.AI.Decks
if (Card.Location == CardLocation.Grave) if (Card.Location == CardLocation.Grave)
return true; return true;
if (Bot.LifePoints <= 1000) return false; if (Bot.LifePoints <= 1000) return false;
ClientCard select = AI.Utils.GetBestEnemyMonster(); ClientCard select = AI.Utils.GetBestEnemyCard();
if (select == null) return false; if (select == null) return false;
if(select!=null) if(select!=null)
{ {
......
This diff is collapsed.
...@@ -25,7 +25,9 @@ namespace WindBot.Game.AI ...@@ -25,7 +25,9 @@ namespace WindBot.Game.AI
public const int DupeFrog = 46239604; public const int DupeFrog = 46239604;
public const int MaraudingCaptain = 2460565; public const int MaraudingCaptain = 2460565;
public const int EvilswarmExcitonKnight = 46772449;
public const int HarpiesFeatherDuster = 18144506; public const int HarpiesFeatherDuster = 18144506;
public const int DarkMagicAttack = 2314238;
public const int MysticalSpaceTyphoon = 5318639; public const int MysticalSpaceTyphoon = 5318639;
public const int CosmicCyclone = 8267140; public const int CosmicCyclone = 8267140;
public const int ChickenGame = 67616300; public const int ChickenGame = 67616300;
...@@ -39,6 +41,7 @@ namespace WindBot.Game.AI ...@@ -39,6 +41,7 @@ namespace WindBot.Game.AI
public const int VampireFräulein = 6039967; public const int VampireFräulein = 6039967;
public const int InjectionFairyLily = 79575620; public const int InjectionFairyLily = 79575620;
public const int BlueEyesChaosMAXDragon = 55410871;
} }
protected DefaultExecutor(GameAI ai, Duel duel) protected DefaultExecutor(GameAI ai, Duel duel)
...@@ -469,7 +472,13 @@ namespace WindBot.Game.AI ...@@ -469,7 +472,13 @@ namespace WindBot.Game.AI
{ {
if (Card.IsFaceup() && Card.IsDefense() && Card.Attack == 0) if (Card.IsFaceup() && Card.IsDefense() && Card.Attack == 0)
return false; return false;
if (Enemy.HasInMonstersZone(_CardId.BlueEyesChaosMAXDragon) &&
Card.IsAttack() && (4000-Card.Defense)*2>(4000 - Card.Attack))
return false;
if (Enemy.HasInMonstersZone(_CardId.BlueEyesChaosMAXDragon) &&
Card.IsDefense() && Card.IsFaceup() &&
(4000 - Card.Defense) * 2 > (4000 - Card.Attack))
return true;
bool enemyBetter = AI.Utils.IsAllEnemyBetter(true); bool enemyBetter = AI.Utils.IsAllEnemyBetter(true);
if (Card.IsAttack() && enemyBetter) if (Card.IsAttack() && enemyBetter)
...@@ -485,7 +494,9 @@ namespace WindBot.Game.AI ...@@ -485,7 +494,9 @@ namespace WindBot.Game.AI
protected bool DefaultOnBecomeTarget() protected bool DefaultOnBecomeTarget()
{ {
if (AI.Utils.IsChainTarget(Card)) return true; if (AI.Utils.IsChainTarget(Card)) return true;
if (AI.Utils.ChainContainsCard(_CardId.EvilswarmExcitonKnight)) return true;
if (Enemy.HasInSpellZone(_CardId.HarpiesFeatherDuster, true)) return true; if (Enemy.HasInSpellZone(_CardId.HarpiesFeatherDuster, true)) return true;
if (Enemy.HasInSpellZone(_CardId.DarkMagicAttack, true)) return true;
return false; return false;
} }
/// <summary> /// <summary>
......
...@@ -80,15 +80,15 @@ namespace WindBot.Game.AI ...@@ -80,15 +80,15 @@ namespace WindBot.Game.AI
public void SendSorry() public void SendSorry()
{ {
InternalSendMessage(new[] { "Sorry, an error occurs." }); InternalSendMessageForced(new[] { "Sorry, an error occurs." });
} }
public void SendDeckSorry(string card) public void SendDeckSorry(string card)
{ {
if (card == "DECK") if (card == "DECK")
InternalSendMessage(new[] { "Deck illegal. Please check the database of your YGOPro and WindBot." }); InternalSendMessageForced(new[] { "Deck illegal. Please check the database of your YGOPro and WindBot." });
else else
InternalSendMessage(_deckerror, card); InternalSendMessageForced(_deckerror, card);
} }
public void SendWelcome() public void SendWelcome()
...@@ -159,6 +159,15 @@ namespace WindBot.Game.AI ...@@ -159,6 +159,15 @@ namespace WindBot.Game.AI
} }
private void InternalSendMessage(IList<string> array, params object[] opts) private void InternalSendMessage(IList<string> array, params object[] opts)
{
if (!_game._chat)
return;
string message = string.Format(array[Program.Rand.Next(array.Count)], opts);
if (message != "")
_game.Chat(message);
}
private void InternalSendMessageForced(IList<string> array, params object[] opts)
{ {
string message = string.Format(array[Program.Rand.Next(array.Count)], opts); string message = string.Format(array[Program.Rand.Next(array.Count)], opts);
if (message != "") if (message != "")
......
...@@ -72,6 +72,7 @@ ...@@ -72,6 +72,7 @@
ElShaddollGrysra = 48424886, ElShaddollGrysra = 48424886,
ElShaddollWinda = 94977269, ElShaddollWinda = 94977269,
UltimateConductorTytanno = 18940556, UltimateConductorTytanno = 18940556,
OvertexCoatls = 41782653 OvertexCoatls = 41782653,
FirePrison = 269510
} }
} }
...@@ -43,6 +43,7 @@ ...@@ -43,6 +43,7 @@
FlowerCardianLightshower = 42291297, FlowerCardianLightshower = 42291297,
YaziEviloftheYangZing = 43202238, YaziEviloftheYangZing = 43202238,
RaidraptorUltimateFalcon = 86221741, RaidraptorUltimateFalcon = 86221741,
DisdainfulBirdofParadise = 27240101 DisdainfulBirdofParadise = 27240101,
DarkestDiabolosLordOfTheLair = 50383626
} }
} }
...@@ -97,6 +97,11 @@ namespace WindBot.Game.AI ...@@ -97,6 +97,11 @@ namespace WindBot.Game.AI
{ {
// Some AI need do something on new turn // Some AI need do something on new turn
} }
public virtual void OnDraw(int player)
{
// Some AI need do something on draw
}
public virtual IList<ClientCard> OnSelectCard(IList<ClientCard> cards, int min, int max, int hint, bool cancelable) public virtual IList<ClientCard> OnSelectCard(IList<ClientCard> cards, int min, int max, int hint, bool cancelable)
{ {
...@@ -146,6 +151,12 @@ namespace WindBot.Game.AI ...@@ -146,6 +151,12 @@ namespace WindBot.Game.AI
return null; return null;
} }
public virtual IList<ClientCard> OnCardSorting(IList<ClientCard> cards)
{
// For overriding
return null;
}
public virtual bool OnSelectYesNo(int desc) public virtual bool OnSelectYesNo(int desc)
{ {
return true; return true;
......
...@@ -23,7 +23,7 @@ namespace WindBot.Game ...@@ -23,7 +23,7 @@ namespace WindBot.Game
public int Defense { get; private set; } public int Defense { get; private set; }
public int LScale { get; private set; } public int LScale { get; private set; }
public int RScale { get; private set; } public int RScale { get; private set; }
public int Link { get; private set; } public int LinkCount { get; private set; }
public int LinkMarker { get; private set; } public int LinkMarker { get; private set; }
public int BaseAttack { get; private set; } public int BaseAttack { get; private set; }
public int BaseDefense { get; private set; } public int BaseDefense { get; private set; }
...@@ -136,11 +136,21 @@ namespace WindBot.Game ...@@ -136,11 +136,21 @@ namespace WindBot.Game
RScale = packet.ReadInt32(); RScale = packet.ReadInt32();
if ((flag & (int)Query.Link) != 0) if ((flag & (int)Query.Link) != 0)
{ {
Link = packet.ReadInt32(); LinkCount = packet.ReadInt32();
LinkMarker = packet.ReadInt32(); LinkMarker = packet.ReadInt32();
} }
} }
public bool HasLinkMarker(int dir)
{
return ((LinkMarker & dir) != 0);
}
public bool HasLinkMarker(LinkMarker dir)
{
return ((LinkMarker & (int)dir) != 0);
}
public bool HasType(CardType type) public bool HasType(CardType type)
{ {
return ((Type & (int)type) != 0); return ((Type & (int)type) != 0);
......
...@@ -70,6 +70,30 @@ namespace WindBot.Game ...@@ -70,6 +70,30 @@ namespace WindBot.Game
} }
return count; return count;
} }
/// <summary>
/// Count Column
/// </summary>
/// <param zone>range of zone 0-4</param>
public int GetColumnCount(int zone, bool IncludeExtraMonsterZone = true)
{
int count = 0;
if (SpellZone[zone] != null)
count++;
if (MonsterZone[zone] != null)
count++;
if(zone == 1 && IncludeExtraMonsterZone)
{
if (MonsterZone[5] != null)
count++;
}
if (zone == 3 && IncludeExtraMonsterZone)
{
if (MonsterZone[6] != null)
count++;
}
return count;
}
public int GetFieldCount() public int GetFieldCount()
...@@ -218,6 +242,76 @@ namespace WindBot.Game ...@@ -218,6 +242,76 @@ namespace WindBot.Game
return HasInCards(SpellZone, cardId, notDisabled); return HasInCards(SpellZone, cardId, notDisabled);
} }
public bool HasInHandOrInSpellZone(int cardId)
{
return HasInHand(cardId) || HasInSpellZone(cardId);
}
public bool HasInHandOrHasInMonstersZone(int cardId)
{
return HasInHand(cardId) || HasInMonstersZone(cardId);
}
public bool HasInHandOrInGraveyard(int cardId)
{
return HasInHand(cardId) || HasInGraveyard(cardId);
}
public bool HasInMonstersZoneOrInGraveyard(int cardId)
{
return HasInMonstersZone(cardId) || HasInGraveyard(cardId);
}
public bool HasInSpellZoneOrInGraveyard(int cardId)
{
return HasInSpellZone(cardId) || HasInGraveyard(cardId);
}
public bool HasInHandOrInMonstersZoneOrInGraveyard(int cardId)
{
return HasInHand(cardId) || HasInMonstersZone(cardId) || HasInGraveyard(cardId);
}
public bool HasInHandOrInSpellZoneOrInGraveyard(int cardId)
{
return HasInHand(cardId) || HasInSpellZone(cardId) || HasInGraveyard(cardId);
}
public bool HasInHandOrInSpellZone(IList<int> cardId)
{
return HasInHand(cardId) || HasInSpellZone(cardId);
}
public bool HasInHandOrHasInMonstersZone(IList<int> cardId)
{
return HasInHand(cardId) || HasInMonstersZone(cardId);
}
public bool HasInHandOrInGraveyard(IList<int> cardId)
{
return HasInHand(cardId) || HasInGraveyard(cardId);
}
public bool HasInMonstersZoneOrInGraveyard(IList<int> cardId)
{
return HasInMonstersZone(cardId) || HasInGraveyard(cardId);
}
public bool HasInSpellZoneOrInGraveyard(IList<int> cardId)
{
return HasInSpellZone(cardId) || HasInGraveyard(cardId);
}
public bool HasInHandOrInMonstersZoneOrInGraveyard(IList<int> cardId)
{
return HasInHand(cardId) || HasInMonstersZone(cardId) || HasInGraveyard(cardId);
}
public bool HasInHandOrInSpellZoneOrInGraveyard(IList<int> cardId)
{
return HasInHand(cardId) || HasInSpellZone(cardId) || HasInGraveyard(cardId);
}
public int GetRemainingCount(int cardId, int initialCount) public int GetRemainingCount(int cardId, int initialCount)
{ {
int remaining = initialCount; int remaining = initialCount;
......
...@@ -70,6 +70,14 @@ namespace WindBot.Game ...@@ -70,6 +70,14 @@ namespace WindBot.Game
return Executor.OnSelectHand(); return Executor.OnSelectHand();
} }
/// <summary>
/// Called when any player draw card.
/// </summary>
public void OnDraw(int player)
{
Executor.OnDraw(player);
}
/// <summary> /// <summary>
/// Called when it's a new turn. /// Called when it's a new turn.
/// </summary> /// </summary>
...@@ -329,6 +337,26 @@ namespace WindBot.Game ...@@ -329,6 +337,26 @@ namespace WindBot.Game
return used; return used;
} }
/// <summary>
/// Called when the AI has to sort cards.
/// </summary>
/// <param name="cards">Cards to sort.</param>
/// <returns>List of sorted cards.</returns>
public IList<ClientCard> OnCardSorting(IList<ClientCard> cards)
{
IList<ClientCard> result = Executor.OnCardSorting(cards);
if (result != null)
return result;
result = new List<ClientCard>();
// TODO: use selector
for (int i = 0; i < cards.Count; i++)
{
result.Add(cards[i]);
}
return result;
}
/// <summary> /// <summary>
/// Called when the AI has to choose to activate or not an effect. /// Called when the AI has to choose to activate or not an effect.
/// </summary> /// </summary>
......
This diff is collapsed.
...@@ -14,7 +14,8 @@ namespace WindBot.Game ...@@ -14,7 +14,8 @@ namespace WindBot.Game
public string Deck; public string Deck;
public string Dialog; public string Dialog;
public int Hand; public int Hand;
public bool Debug;
public bool _chat;
private string _serverHost; private string _serverHost;
private int _serverPort; private int _serverPort;
private short _proVersion; private short _proVersion;
...@@ -29,6 +30,8 @@ namespace WindBot.Game ...@@ -29,6 +30,8 @@ namespace WindBot.Game
Deck = Info.Deck; Deck = Info.Deck;
Dialog = Info.Dialog; Dialog = Info.Dialog;
Hand = Info.Hand; Hand = Info.Hand;
Debug = Info.Debug;
_chat = Info.Chat;
_serverHost = Info.Host; _serverHost = Info.Host;
_serverPort = Info.Port; _serverPort = Info.Port;
_roomInfo = Info.HostInfo; _roomInfo = Info.HostInfo;
......
...@@ -74,6 +74,8 @@ namespace WindBot ...@@ -74,6 +74,8 @@ namespace WindBot
Info.HostInfo = Config.GetString("HostInfo", Info.HostInfo); Info.HostInfo = Config.GetString("HostInfo", Info.HostInfo);
Info.Version = Config.GetInt("Version", Info.Version); Info.Version = Config.GetInt("Version", Info.Version);
Info.Hand = Config.GetInt("Hand", Info.Hand); Info.Hand = Config.GetInt("Hand", Info.Hand);
Info.Debug = Config.GetBool("Debug", Info.Debug);
Info.Chat = Config.GetBool("Chat", Info.Chat);
Run(Info); Run(Info);
} }
...@@ -114,6 +116,12 @@ namespace WindBot ...@@ -114,6 +116,12 @@ namespace WindBot
string hand = HttpUtility.ParseQueryString(RawUrl).Get("hand"); string hand = HttpUtility.ParseQueryString(RawUrl).Get("hand");
if (hand != null) if (hand != null)
Info.Hand = Int32.Parse(hand); Info.Hand = Int32.Parse(hand);
string debug = HttpUtility.ParseQueryString(RawUrl).Get("debug");
if (debug != null)
Info.Debug= bool.Parse(debug);
string chat = HttpUtility.ParseQueryString(RawUrl).Get("chat");
if (chat != null)
Info.Chat = bool.Parse(chat);
if (Info.Name == null || Info.Host == null || port == null) if (Info.Name == null || Info.Host == null || port == null)
{ {
......
...@@ -68,6 +68,7 @@ ...@@ -68,6 +68,7 @@
<Compile Include="Game\AI\DecksManager.cs" /> <Compile Include="Game\AI\DecksManager.cs" />
<Compile Include="Game\AI\Decks\BlackwingExecutor.cs" /> <Compile Include="Game\AI\Decks\BlackwingExecutor.cs" />
<Compile Include="Game\AI\Decks\CyberDragonExecutor.cs" /> <Compile Include="Game\AI\Decks\CyberDragonExecutor.cs" />
<Compile Include="Game\AI\Decks\DarkMagicianExecutor.cs" />
<Compile Include="Game\AI\Decks\SkyStrikerExecutor.cs" /> <Compile Include="Game\AI\Decks\SkyStrikerExecutor.cs" />
<Compile Include="Game\AI\Decks\MokeyMokeyKingExecutor.cs" /> <Compile Include="Game\AI\Decks\MokeyMokeyKingExecutor.cs" />
<Compile Include="Game\AI\Decks\MokeyMokeyExecutor.cs" /> <Compile Include="Game\AI\Decks\MokeyMokeyExecutor.cs" />
......
...@@ -12,7 +12,8 @@ namespace WindBot ...@@ -12,7 +12,8 @@ namespace WindBot
public string HostInfo { get; set; } public string HostInfo { get; set; }
public int Version { get; set; } public int Version { get; set; }
public int Hand { get; set; } public int Hand { get; set; }
public bool Debug { get; set; }
public bool Chat { get; set; }
public WindBotInfo() public WindBotInfo()
{ {
Name = "WindBot"; Name = "WindBot";
...@@ -23,6 +24,8 @@ namespace WindBot ...@@ -23,6 +24,8 @@ namespace WindBot
HostInfo = ""; HostInfo = "";
Version = 0x1343; Version = 0x1343;
Hand = 0; Hand = 0;
Debug = false;
Chat = true;
} }
} }
} }
...@@ -120,6 +120,16 @@ ...@@ -120,6 +120,16 @@
"deck": "LightswornShaddoldinosour", "deck": "LightswornShaddoldinosour",
"dialog": "kiwi.zh-TW" "dialog": "kiwi.zh-TW"
}, },
{
"name": "奇魔果",
"deck": "DarkMagician",
"dialog": "kiwi.zh-TW"
},
{
"name": "奇魔果",
"deck": "DarkMagician",
"dialog": "kiwi.zh-TW"
},
{ {
"name": "燃血鬥士", "name": "燃血鬥士",
"deck": "ChainBurn", "deck": "ChainBurn",
......
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