如何让多个玩家能够连接到我的 MUD?
我最近创建了一个简短的多用户地下城。我制作的东西是游戏的引擎和实际的MUD本身,所以当我点击文件时你就可以玩MUD。我遇到的问题是,我不知道如何连接它以便多个玩家可以玩。你是否将它连接到服务器或其他东西?我不知道该怎么办,因为我是 Python 和 MUD 的新手。有人可以通过提供一些示例来帮助我解决代码以及如何连接和启动并运行此游戏吗?
I've recently created a short and simple Multi-User Dungeon. The things I've made are the engine of the game and the actual MUD itself, so when i click on the file it you can play the MUD. The problem I have is, I don't know how to connect it so that more than one player can play. Do you connect it to a server or something? I don't know what to do as I am new to Python and MUDs. Can some help me out by giving some examples to help me out with code and how to connect and get this game up and running?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您的 MUD 应该是服务器。
首先,您要确保您的引擎可以处理多人同时更改地牢状态。
接下来看看如何创建服务器。您可能想查看 SocketServer 类,对于 MUD,您可能需要以下之一TCP 子类。
每个用户都会打开与您的服务器的连接。通常,每个连接将由一个进程或一个线程处理(查看 ThreadingMixin )。该线程内部将是连接的用户界面代码(从用户读取一行,将其传递到引擎,将结果打印给用户)。
您的引擎可能会在单独的线程/进程中运行并维护地牢状态(房间、用户、项目的列表)。
祝你好运!
Your MUD should be the server.
First, you want to make sure that your engine can handle multiple people changing the dungeon state at the same time.
Next, take a look at how to create a server. You probably want to look at the SocketServer class, for MUDs you probably want one of the TCP subclasses.
Each user will open a connection to your server. Normally, each connection will be handled by either a process or a thread (check out the
ThreadingMixin
). Inside that thread will be the user interface code for a connection (read a line from the user, pass that onto the engine, print out results to the user).Your engine will probably run in a separate thread / process and maintain the dungeon state (list of rooms, users, items).
Good luck!
通常,您的 MUD 服务器代码会处理套接字连接,并通过命令解析器将它们连接到内部玩家对象。您可能想查看 SocketMUD;它是一个用于 MUD 使用的简单套接字处理架构,并且可能正是您所需要的。
The usual thing is that your MUD server code handles the socket connections and connects them to internal player objects through a command parser. You might want to look at SocketMUD; it's a bare-bones socket handling architecture intended for MUD use, and may be just what you need.