0
我是新来snakeyaml和yaml一般。我需要它来存储关于“房间”的信息MUD。这是使用YAML的有效方法吗?
为客房的条目会是这个样子:
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中缺乏知识使我很难获得好的结果。