Commit c626f14f authored by mercury233's avatar mercury233

comment

parent 360bfea5
......@@ -50,6 +50,12 @@ namespace WindBot.Game.AI
return Program.Rand.Next(2) > 0;
}
/// <summary>
/// Called when the AI has to decide if it should attack
/// </summary>
/// <param name="attackers">List of monsters that can attcack.</param>
/// <param name="defenders">List of monsters of enemy.</param>
/// <returns>A new BattlePhaseAction containing the action to do.</returns>
public virtual BattlePhaseAction OnBattle(IList<ClientCard> attackers, IList<ClientCard> defenders)
{
if (attackers.Count == 0)
......@@ -86,6 +92,13 @@ namespace WindBot.Game.AI
return AI.ToMainPhase2();
}
/// <summary>
/// Decide whether to declare attack between attacker and defender.
/// Can be overrided to update the RealPower of attacker for cards like Honest.
/// </summary>
/// <param name="attacker">Card that attack.</param>
/// <param name="defender">Card that defend.</param>
/// <returns>true if the attack can be done.</returns>
public virtual bool OnPreBattleBetween(ClientCard attacker, ClientCard defender)
{
if (defender.IsMonsterInvincible())
......@@ -115,11 +128,13 @@ namespace WindBot.Game.AI
public virtual IList<ClientCard> OnSelectCard(IList<ClientCard> cards, int min, int max, bool cancelable)
{
// For overriding
return null;
}
public virtual IList<ClientCard> OnSelectSum(IList<ClientCard> cards, int sum, int min, int max, bool mode)
{
// For overriding
return null;
}
......@@ -181,6 +196,9 @@ namespace WindBot.Game.AI
Battle = battle;
}
/// <summary>
/// Set global variables Type, Card, ActivateDescription for Executor
/// </summary>
public void SetCard(ExecutorType type, ClientCard card, int description)
{
Type = type;
......@@ -188,21 +206,33 @@ namespace WindBot.Game.AI
ActivateDescription = description;
}
/// <summary>
/// Do the action for the card if func return true.
/// </summary>
public void AddExecutor(ExecutorType type, int cardId, Func<bool> func)
{
Executors.Add(new CardExecutor(type, cardId, func));
}
/// <summary>
/// Do the action for the card if available.
/// </summary>
public void AddExecutor(ExecutorType type, int cardId)
{
Executors.Add(new CardExecutor(type, cardId, null));
}
/// <summary>
/// Do the action for every card if func return true.
/// </summary>
public void AddExecutor(ExecutorType type, Func<bool> func)
{
Executors.Add(new CardExecutor(type, -1, func));
}
/// <summary>
/// Do the action for every card if no other Executor is added to it.
/// </summary>
public void AddExecutor(ExecutorType type)
{
Executors.Add(new CardExecutor(type, -1, DefaultNoExecutor));
......
......@@ -75,6 +75,7 @@ namespace WindBot.Game
/// </summary>
public void OnNewTurn()
{
Executor.OnNewTurn();
}
/// <summary>
......@@ -91,7 +92,6 @@ namespace WindBot.Game
if (Duel.Player == 0 && Duel.Phase == DuelPhase.Draw)
{
_dialogs.SendNewTurn();
Executor.OnNewTurn();
}
}
......@@ -102,10 +102,6 @@ namespace WindBot.Game
{
_dialogs.SendOnDirectAttack(card.Name);
}
public void OnDirectAttack()
{
_dialogs.SendOnDirectAttack();
}
/// <summary>
/// Called when a chain is executed.
......@@ -369,13 +365,13 @@ namespace WindBot.Game
}
/// <summary>
/// Called when the AI has to tribute for a synchro monster.
/// Called when the AI has to tribute for a synchro monster or ritual monster.
/// </summary>
/// <param name="cards">Available cards.</param>
/// <param name="sum">Result of the operation.</param>
/// <param name="min">Minimum cards.</param>
/// <param name="max">Maximum cards.</param>
/// <param name="mode">True for equal.</param>
/// <param name="mode">True for exact equal.</param>
/// <returns></returns>
public IList<ClientCard> OnSelectSum(IList<ClientCard> cards, int sum, int min, int max, bool mode)
{
......
......@@ -11,7 +11,7 @@ namespace WindBot
{
public class Program
{
// in safe mode, all errors will be catched instead of causing the program to crash.
// In safe mode, all errors will be catched instead of causing the program to crash.
#if DEBUG
public static bool SafeMode = false;
#else
......@@ -34,11 +34,13 @@ namespace WindBot
if (serverMode)
{
// Run in server mode, provide a http interface to create bot.
int serverPort = Config.GetInt("ServerPort", 2399);
RunAsServer(serverPort);
}
else
{
// Join the host specified on the command line.
if (args.Length == 0)
{
Logger.WriteLine("=== WARN ===");
......@@ -55,6 +57,7 @@ namespace WindBot
DecksManager.Init();
string absolutePath = Path.GetFullPath(databasePath);
if (!File.Exists(absolutePath))
// In case windbot is placed in a folder under ygopro folder
absolutePath = Path.GetFullPath("../" + databasePath);
if (!File.Exists(absolutePath))
Logger.WriteErrorLine("Can't find cards database file. Please place cards.cdb next to WindBot.exe .");
......
......@@ -121,6 +121,8 @@ The parameters are same as commandlines, but low cased.
* `AI.SelectMaterials` which select a set of cards for F/S/X/L summon
* `AI.SelectTribute`
* Better new master rule support
* More default common cards executor
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