private void HandleDuelRequest(string command) { if (InvokeRequired) { Invoke(new Action<string>(HandleDuelRequest), command); } else { string[] args = command.Split(new string[] { "||" }, StringSplitOptions.None); string cmd = args[0]; if (cmd == "START") { LauncherHelper.GenerateConfig("ygopro:/" + Program.Config.ServerAddress + "/" + Program.Config.GamePort + "/" + args[1]); LauncherHelper.RunGame("-j"); } else if (cmd == "REQUEST") { if (Program.Config.RefuseDuelRequests) { server.SendPacket("REFUSEDUEL||" + args[1]); return; } RoomInfos info = RoomInfos.FromName(args[2], "", false); DuelRequest_frm request = new DuelRequest_frm(args[1] + " has challenged you to a ranked duel! Do you accept?" + Environment.NewLine + "Type: " + RoomInfos.GameMode(info.Mode) + " Rules: " + RoomInfos.GameRule(info.Rule) + " Banlist: " + LauncherHelper.GetBanListFromInt(info.BanList)); if (request.ShowDialog() == System.Windows.Forms.DialogResult.Yes) { NewMessage(new ChatMessage(MessageType.System, CurrentChatWindow().Name, "You accepted " + args[1] + " duel request.")); server.SendPacket("ACCEPTDUEL||" + args[1] + "||" + args[2]); } else { NewMessage(new ChatMessage(MessageType.System, CurrentChatWindow().Name, "You refused " + args[1] + " duel request.")); server.SendPacket("REFUSEDUEL||" + args[1]); } } else if (cmd == "REFUSE") { NewMessage(new ChatMessage(MessageType.System, CurrentChatWindow().Name, args[1] + " refused your duel request.")); } } }
private void HandleDuelRequest(string command) { if (InvokeRequired) { Invoke(new Action<string>(HandleDuelRequest), command); return; } string[] args = command.Split(new[] { "||" }, StringSplitOptions.None); string cmd = args[0]; switch (cmd) { case "START": LauncherHelper.GenerateConfig("ygopro:/" + Program.Config.ServerAddress + "/" + Program.Config.GamePort + "/" + args[1]); LauncherHelper.RunGame("-j"); break; case "REQUEST": if (Program.Config.RefuseDuelRequests) { Program.ChatServer.SendPacket("REFUSEDUEL||" + args[1]); return; } RoomInfos info = RoomInfos.FromName(args[2], false); var request = new DuelRequest_frm( args[1] + Program.LanguageManager.Translation.DuelReqestMessage + Environment.NewLine + Program.LanguageManager.Translation.DuelRequestMode + RoomInfos.GameMode(info.mode) + Program.LanguageManager.Translation.DuelRequestRules + RoomInfos.GameRule(info.rule) + Program.LanguageManager.Translation.DuelRequestBanlist + LauncherHelper.GetBanListFromInt(info.banListType)); if (request.ShowDialog() == DialogResult.Yes) { WriteMessage(new ChatMessage(MessageType.System, CommandType.None, null, "You accepted " + args[1] + " duel request.")); Program.ChatServer.SendPacket("ACCEPTDUEL||" + args[1] + "||" + args[2]); } else { WriteMessage(new ChatMessage(MessageType.System, CommandType.None, null, "You refused " + args[1] + " duel request.")); Program.ChatServer.SendPacket("REFUSEDUEL||" + args[1]); } break; case "REFUSE": WriteMessage(new ChatMessage(MessageType.System, CommandType.None, null, args[1] + " refused your duel request.")); break; } }