我一般是snakeyaml和yaml的新手。我需要它来存储有关MUD的“房间”的信息。
房间的条目将如下所示:
room:
id: 12
entry: "Long string"
description: "Longer more precise string"
objects:
ids: 1,23
object:
id: 1
name: "chest"
description: "looks pretty damn old"
on-text: "the chest has been opened!"
off-text: "the chest has been closed!"
基本上,每个房间都有一个id
和一些文本要在玩家进入/搜索时显示给玩家。它还有一个“对象”数组,它们本身在同一个 yaml 文件中声明。
我的 yaml 文件中的这种配置是否可行?另外,我需要将每个房间和每个对象提取到数组中,所以它看起来像这样:
[12, "long string", "Longer more precise string", [1, "chest", "looks pretty damn old", "the chest has been opened!", "the chest has been closed!"], [ ... item 23 ... ]]
这种配置使我可以轻松地解析文件并通过创建一个循环并通过数组位置引用每个值来创建 GenericRoom 和 GenericObject 类。这是 SnakeYAML 可以为我做的事情吗?我一直在玩一些例子,但我对实际 YAML 缺乏了解,这让我很难得到好的结果。