Commit d18e943d authored by mercury233's avatar mercury233

add ExecutorType.Surrender

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