Commit d18e943d authored by mercury233's avatar mercury233

add ExecutorType.Surrender

parent 3feb38fe
......@@ -64,5 +64,11 @@
"Before you do that, I'll chain {0}!",
"Nice try, but I have {0}!",
"Didn't expect {0}, did you?"
],
"surrender": [
"I surrender.",
"You win this time.",
"I can't win this duel.",
"Good game."
]
}
\ No newline at end of file
......@@ -55,5 +55,10 @@
"但我鸽了",
"无此服务",
"可怕"
],
"surrender": [
"太可怕了(跑路",
"这游戏好难玩(跑路",
"还好我不玩游戏王(跑路"
]
}
......@@ -71,5 +71,9 @@
"我不认同。{0},发动!",
"看样子你忘了我的{0}!",
"你考虑过我有{0}吗?"
],
"surrender": [
"我认输。",
"我承认你的胜利。"
]
}
using System;
using System;
using System.IO;
using System.Collections.Generic;
using System.Runtime.Serialization;
......@@ -36,6 +36,8 @@ namespace WindBot.Game.AI
[DataMember]
public string[] chaining { get; set; }
[DataMember]
public string[] surrender { get; set; }
[DataMember]
public string[] custom { get; set; }
}
public class Dialogs
......@@ -55,6 +57,7 @@ namespace WindBot.Game.AI
private string[] _summon;
private string[] _setmonster;
private string[] _chaining;
private string[] _surrender;
private string[] _custom;
public Dialogs(GameClient game)
......@@ -78,6 +81,7 @@ namespace WindBot.Game.AI
_summon = data.summon;
_setmonster = data.setmonster;
_chaining = data.chaining;
_surrender = data.surrender;
_custom = data.custom;
}
}
......@@ -162,6 +166,11 @@ namespace WindBot.Game.AI
InternalSendMessage(_chaining, card);
}
public void SendSurrender()
{
InternalSendMessage(_surrender);
}
private void InternalSendMessage(IList<string> array, params object[] opts)
{
if (!_game._chat)
......
......@@ -11,6 +11,7 @@
SummonOrSet,
GoToBattlePhase,
GoToMainPhase2,
GoToEndPhase
GoToEndPhase,
Surrender
}
}
\ No newline at end of file
......@@ -25,6 +25,18 @@ namespace WindBot.Game
_activatedCards = new Dictionary<int, int>();
}
private void CheckSurrender()
{
foreach (CardExecutor exec in Executor.Executors)
{
if (exec.Type == ExecutorType.Surrender && exec.Func())
{
_dialogs.SendSurrender();
Game.Surrender();
}
}
}
/// <summary>
/// Called when the AI got the error message.
/// </summary>
......@@ -117,6 +129,7 @@ namespace WindBot.Game
_dialogs.SendNewTurn();
}
Executor.OnNewPhase();
CheckSurrender();
}
public void OnMove(ClientCard card, int previousControler, int previousLocation, int currentControler, int currentLocation)
......@@ -130,6 +143,7 @@ namespace WindBot.Game
public void OnDirectAttack(ClientCard card)
{
_dialogs.SendOnDirectAttack(card.Name);
CheckSurrender();
}
/// <summary>
......@@ -155,6 +169,7 @@ namespace WindBot.Game
m_selector.Clear();
m_selector_pointer = -1;
Executor.OnChainEnd();
CheckSurrender();
}
/// <summary>
......@@ -422,6 +437,7 @@ namespace WindBot.Game
public MainPhaseAction OnSelectIdleCmd(MainPhase main)
{
Executor.SetMain(main);
CheckSurrender();
foreach (CardExecutor exec in Executor.Executors)
{
if (exec.Type == ExecutorType.GoToEndPhase && main.CanEndPhase && exec.Func()) // check if should enter end phase directly
......
......@@ -90,6 +90,11 @@ namespace WindBot.Game
Connection.Send(chat);
}
public void Surrender()
{
Connection.Send(CtosMessage.Surrender);
}
private void OnPacketReceived(BinaryReader reader)
{
_behavior.OnPacket(reader);
......
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