milimoe 0ed458fb77
匹配房间功能 (#25)
* 匹配房间 第一部分

* elo匹配

* 设置匹配结束标记

* 传输的room对象错误

* 修复错误的UpdateRoom; 添加SQLMode开关

* 删除创建房间时重复的加入房间代码

* 添加在加入房间时检查是否存在房间

---------

Co-authored-by: yeziuku <yezi@wrss.org>
2023-10-25 00:10:34 +08:00

86 lines
3.3 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

using Milimoe.FunGame.Core.Interface.Base;
using Milimoe.FunGame.Core.Library.Common.Network;
using Milimoe.FunGame.Server.Others;
using Milimoe.FunGame.Server.Utility;
namespace Milimoe.FunGame.Server.Model
{
public class ConsoleModel
{
public static void Order(ServerSocket? server, string order)
{
try
{
switch (order)
{
case OrderDictionary.Kick:
{
ServerHelper.Write("输入需要踢出的客户端名称:");
string client = Console.ReadLine() ?? "";
if (client != "" && server != null)
{
((ServerModel)server.GetClient(client))?.Kick("您已被服务器管理员踢出此服务器。");
}
break;
}
case OrderDictionary.Logout:
{
ServerHelper.Write("输入需要强制下线的玩家ID");
string user = Console.ReadLine() ?? "";
if (user != "" && server != null)
{
((ServerModel)server.GetUser(user))?.ForceLogOut("您已被服务器管理员强制下线。");
}
break;
}
case OrderDictionary.ShowList:
ShowClients(server);
ShowUsers(server);
break;
case OrderDictionary.ShowClients1:
case OrderDictionary.ShowClients2:
ShowClients(server);
break;
case OrderDictionary.ShowUsers1:
case OrderDictionary.ShowUsers2:
ShowUsers(server);
break;
case OrderDictionary.Help:
ServerHelper.WriteLine("Milimoe -> 帮助");
break;
}
}
catch (Exception e)
{
ServerHelper.Error(e);
}
}
private static void ShowClients(ServerSocket? server)
{
if (server != null)
{
ServerHelper.WriteLine("显示在线客户端列表");
int index = 1;
foreach (IServerModel client in server.ClientList)
{
ServerHelper.WriteLine(index++ + ". " + client.ClientName + (client.User.Id != 0 ? " (已登录为:" + client.User.Username + ")" : ""));
}
}
}
private static void ShowUsers(ServerSocket? server)
{
if (server != null)
{
ServerHelper.WriteLine("显示在线玩家列表");
int index = 1;
foreach (IServerModel user in server.UserList.Where(u => u.User.Id != 0))
{
ServerHelper.WriteLine(index++ + ". " + (user.User.Username) + " (客户端:" + user.ClientName + ")");
}
}
}
}
}