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 @@
80280944
48048590
77723643
77723643
55623480
30328508
30328508
......
using System.Collections.Generic;
using YGOSharp.OCGWrapper.Enums;
namespace WindBot.Game.AI
{
public class AIFunctions
......@@ -151,6 +150,25 @@ namespace WindBot.Game.AI
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)
{
ClientCard bestCard = null;
......@@ -250,12 +268,31 @@ namespace WindBot.Game.AI
List<ClientCard> monsters = Enemy.GetMonsters();
// 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 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)
{
ClientCard card = GetProblematicEnemySpell();
......@@ -337,6 +374,16 @@ namespace WindBot.Game.AI
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)
{
foreach (ClientCard card in Duel.CurrentChain)
......
This diff is collapsed.
This diff is collapsed.
......@@ -1052,7 +1052,7 @@ namespace WindBot.Game.AI.Decks
if (Card.Location == CardLocation.Grave)
return true;
if (Bot.LifePoints <= 1000) return false;
ClientCard select = AI.Utils.GetBestEnemyMonster();
ClientCard select = AI.Utils.GetBestEnemyCard();
if (select == null) return false;
if(select!=null)
{
......
This diff is collapsed.
......@@ -25,7 +25,9 @@ namespace WindBot.Game.AI
public const int DupeFrog = 46239604;
public const int MaraudingCaptain = 2460565;
public const int EvilswarmExcitonKnight = 46772449;
public const int HarpiesFeatherDuster = 18144506;
public const int DarkMagicAttack = 2314238;
public const int MysticalSpaceTyphoon = 5318639;
public const int CosmicCyclone = 8267140;
public const int ChickenGame = 67616300;
......@@ -39,6 +41,7 @@ namespace WindBot.Game.AI
public const int VampireFräulein = 6039967;
public const int InjectionFairyLily = 79575620;
public const int BlueEyesChaosMAXDragon = 55410871;
}
protected DefaultExecutor(GameAI ai, Duel duel)
......@@ -469,7 +472,13 @@ namespace WindBot.Game.AI
{
if (Card.IsFaceup() && Card.IsDefense() && Card.Attack == 0)
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);
if (Card.IsAttack() && enemyBetter)
......@@ -485,7 +494,9 @@ namespace WindBot.Game.AI
protected bool DefaultOnBecomeTarget()
{
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.DarkMagicAttack, true)) return true;
return false;
}
/// <summary>
......
......@@ -80,15 +80,15 @@ namespace WindBot.Game.AI
public void SendSorry()
{
InternalSendMessage(new[] { "Sorry, an error occurs." });
InternalSendMessageForced(new[] { "Sorry, an error occurs." });
}
public void SendDeckSorry(string card)
{
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
InternalSendMessage(_deckerror, card);
InternalSendMessageForced(_deckerror, card);
}
public void SendWelcome()
......@@ -159,6 +159,15 @@ namespace WindBot.Game.AI
}
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);
if (message != "")
......
......@@ -72,6 +72,7 @@
ElShaddollGrysra = 48424886,
ElShaddollWinda = 94977269,
UltimateConductorTytanno = 18940556,
OvertexCoatls = 41782653
OvertexCoatls = 41782653,
FirePrison = 269510
}
}
......@@ -43,6 +43,7 @@
FlowerCardianLightshower = 42291297,
YaziEviloftheYangZing = 43202238,
RaidraptorUltimateFalcon = 86221741,
DisdainfulBirdofParadise = 27240101
DisdainfulBirdofParadise = 27240101,
DarkestDiabolosLordOfTheLair = 50383626
}
}
......@@ -98,6 +98,11 @@ namespace WindBot.Game.AI
// 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)
{
// For overriding
......@@ -146,6 +151,12 @@ namespace WindBot.Game.AI
return null;
}
public virtual IList<ClientCard> OnCardSorting(IList<ClientCard> cards)
{
// For overriding
return null;
}
public virtual bool OnSelectYesNo(int desc)
{
return true;
......
......@@ -23,7 +23,7 @@ namespace WindBot.Game
public int Defense { get; private set; }
public int LScale { 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 BaseAttack { get; private set; }
public int BaseDefense { get; private set; }
......@@ -136,11 +136,21 @@ namespace WindBot.Game
RScale = packet.ReadInt32();
if ((flag & (int)Query.Link) != 0)
{
Link = packet.ReadInt32();
LinkCount = 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)
{
return ((Type & (int)type) != 0);
......
......@@ -71,6 +71,30 @@ namespace WindBot.Game
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()
{
......@@ -218,6 +242,76 @@ namespace WindBot.Game
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)
{
int remaining = initialCount;
......
......@@ -70,6 +70,14 @@ namespace WindBot.Game
return Executor.OnSelectHand();
}
/// <summary>
/// Called when any player draw card.
/// </summary>
public void OnDraw(int player)
{
Executor.OnDraw(player);
}
/// <summary>
/// Called when it's a new turn.
/// </summary>
......@@ -329,6 +337,26 @@ namespace WindBot.Game
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>
/// Called when the AI has to choose to activate or not an effect.
/// </summary>
......
This diff is collapsed.
......@@ -14,7 +14,8 @@ namespace WindBot.Game
public string Deck;
public string Dialog;
public int Hand;
public bool Debug;
public bool _chat;
private string _serverHost;
private int _serverPort;
private short _proVersion;
......@@ -29,6 +30,8 @@ namespace WindBot.Game
Deck = Info.Deck;
Dialog = Info.Dialog;
Hand = Info.Hand;
Debug = Info.Debug;
_chat = Info.Chat;
_serverHost = Info.Host;
_serverPort = Info.Port;
_roomInfo = Info.HostInfo;
......
......@@ -74,6 +74,8 @@ namespace WindBot
Info.HostInfo = Config.GetString("HostInfo", Info.HostInfo);
Info.Version = Config.GetInt("Version", Info.Version);
Info.Hand = Config.GetInt("Hand", Info.Hand);
Info.Debug = Config.GetBool("Debug", Info.Debug);
Info.Chat = Config.GetBool("Chat", Info.Chat);
Run(Info);
}
......@@ -114,6 +116,12 @@ namespace WindBot
string hand = HttpUtility.ParseQueryString(RawUrl).Get("hand");
if (hand != null)
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)
{
......
......@@ -68,6 +68,7 @@
<Compile Include="Game\AI\DecksManager.cs" />
<Compile Include="Game\AI\Decks\BlackwingExecutor.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\MokeyMokeyKingExecutor.cs" />
<Compile Include="Game\AI\Decks\MokeyMokeyExecutor.cs" />
......
......@@ -12,7 +12,8 @@ namespace WindBot
public string HostInfo { get; set; }
public int Version { get; set; }
public int Hand { get; set; }
public bool Debug { get; set; }
public bool Chat { get; set; }
public WindBotInfo()
{
Name = "WindBot";
......@@ -23,6 +24,8 @@ namespace WindBot
HostInfo = "";
Version = 0x1343;
Hand = 0;
Debug = false;
Chat = true;
}
}
}
......@@ -120,6 +120,16 @@
"deck": "LightswornShaddoldinosour",
"dialog": "kiwi.zh-TW"
},
{
"name": "奇魔果",
"deck": "DarkMagician",
"dialog": "kiwi.zh-TW"
},
{
"name": "奇魔果",
"deck": "DarkMagician",
"dialog": "kiwi.zh-TW"
},
{
"name": "燃血鬥士",
"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