Commit 31097d94 authored by mercury233's avatar mercury233

add param to turn chat off

parent e29d534d
...@@ -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 != "")
......
...@@ -15,6 +15,7 @@ namespace WindBot.Game ...@@ -15,6 +15,7 @@ namespace WindBot.Game
public string Dialog; public string Dialog;
public int Hand; public int Hand;
public bool _chat;
private string _serverHost; private string _serverHost;
private int _serverPort; private int _serverPort;
private short _proVersion; private short _proVersion;
...@@ -29,6 +30,7 @@ namespace WindBot.Game ...@@ -29,6 +30,7 @@ namespace WindBot.Game
Deck = Info.Deck; Deck = Info.Deck;
Dialog = Info.Dialog; Dialog = Info.Dialog;
Hand = Info.Hand; Hand = Info.Hand;
_chat = Info.Chat;
_serverHost = Info.Host; _serverHost = Info.Host;
_serverPort = Info.Port; _serverPort = Info.Port;
_roomInfo = Info.HostInfo; _roomInfo = Info.HostInfo;
......
...@@ -74,6 +74,7 @@ namespace WindBot ...@@ -74,6 +74,7 @@ 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.Chat = Config.GetBool("Chat", Info.Chat);
Run(Info); Run(Info);
} }
...@@ -114,6 +115,9 @@ namespace WindBot ...@@ -114,6 +115,9 @@ 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 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)
{ {
......
...@@ -13,6 +13,7 @@ namespace WindBot ...@@ -13,6 +13,7 @@ namespace WindBot
public int Version { get; set; } public int Version { get; set; }
public int Hand { get; set; } public int Hand { get; set; }
public bool Chat { get; set; }
public WindBotInfo() public WindBotInfo()
{ {
Name = "WindBot"; Name = "WindBot";
...@@ -23,6 +24,7 @@ namespace WindBot ...@@ -23,6 +24,7 @@ namespace WindBot
HostInfo = ""; HostInfo = "";
Version = 0x1343; Version = 0x1343;
Hand = 0; Hand = 0;
Chat = true;
} }
} }
} }
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