文字冒险型 MUD 游戏创作助手。用于快速搭建文字冒险游戏的世界观、地图、NPC、物品、任务与对话树。当用户说"做 MUD"、"写文字冒险"、"创建mud游戏"、"搭建mud世界"时触发。
文字冒险型 MUD 游戏创作技能包。帮你从零构建可运行的单文件 Python MUD 游戏。
游戏核心只需一个 Python 文件(game.py),运行方式:
bash
python game.py
首次使用,按以下流程构建游戏:
世界观设计 → 地图建模 → 人物/物品 → 对话/任务 → 合并到 game.py
详细设计指南见 references/world-design.md(世界观、故事结构)
详细系统指南见 references/game-systems.md(战斗、物品、任务)
示例代码见 references/examples.md
以下模板可直接复制到 game.py 运行,内含 3 个房间、1 个 NPC、1 个战斗场景:
python
import random
def show_room():
room = rooms[player[location]]
locked_msg = [门被锁住了] if room.get(locked) and not player[flags].get(有钥匙) else
print(f\n📍 【{room[name]}】{locked_msg})
print(f {room[desc]})
exits = 、.join(room[exits].keys())
print(f 出口:{exits})
if room.get(items):
print(f 物品:{, .join(room[items])})
if room.get(npcs):
print(f NPC:{, .join(room[npcs])})
def show_help():
print(
help - 显示此帮助
look - 环顾四周
go <方向> - 向指定方向移动(北/南/东/西/前/后)
look <物品>- 查看物品
take <物品> - 拾取物品
inventory - 查看背包
use <物品> - 使用物品
talk
attack
status - 查看角色状态
quit - 退出游戏
)
def move(direction):
room = rooms[player[location]]
if direction not in room[exits]:
print( 你无法往那个方向走。)
return
target = room[exits][direction]
if rooms[target].get(locked) and not player[flags].get(有钥匙):
print(f {rooms[target][name]}的门是锁着的。你需要找到钥匙。)
return
player[location] = target
show_room()
def takeitem(itemname):
room = rooms[player[location]]
for i, item in enumerate(room.get(items, [])):
if itemname in item or item in itemname:
player[inventory].append(item)
room[items].pop(i)
if item == 古老的钥匙:
player[flags][有钥匙] = True
print(f 你拾取了「{item}」。)
return
print( 这里没有这个东西。)
def useitem(itemname):
for i, item in enumerate(player[inventory]):
if itemname in item or item in itemname:
if items[item][effect] == heal:
heal = min(30, player[max_hp] - player[hp])
player[hp] += heal
player[inventory].pop(i)
print(f 你喝下了「{item}」,恢复了 {heal} 点生命!)
elif items[item][effect] == power:
player[attack] += 5
player[inventory].pop(i)
print(f 你装备了「{item}」,攻击力提升!)
else:
print(f 你使用了「{item}」。)
return
print( 你的背包里没有这个东西。)
def talk_to(target):
room = rooms[player[location]]
if target not in room.get(npcs, []):
print( 这里没有这个人。)
return
npc = npcs[target]
print(f\n 👤 {npc[name]}:{npc[desc]})
print(\n 你想说什么?(输入选项前的关键词))
for key in npc[dialogue]:
print(f - {key})
choice = input(\n > ).strip()
if choice in npc[dialogue]:
print(f\n {npc[dialogue][choice]})
if choice == 帮助 and target == 隐士:
player[flags][大厅_交谈过] = True
else:
print( 对方没有回应……)
def combat(enemy_id):
if enemy_id not in npcs:
print( 这里没有这个敌人。)
return
enemy = npcs[enemy_id]
print(f\n ⚔️ 你向 {enemy[name]} 发起了战斗!)
while enemy[hp] > 0 and player[hp] > 0:
dmgtoenemy = random.randint(max(1, player[attack]-3), player[attack]+3)
enemy[hp] -= dmgtoenemy
print(f 你造成了 {
该技能支持在以下平台通过对话安装:
帮我安装 SkillHub 和 mud-adventure-1776027682 技能
设置 SkillHub 为我的优先技能安装源,然后帮我安装 mud-adventure-1776027682 技能
skillhub install mud-adventure-1776027682
文件大小: 11.21 KB | 发布时间: 2026-4-13 11:07