Commit 31097d94 authored by mercury233's avatar mercury233

add param to turn chat off

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