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中缺乏知識使我很難獲得好的結果。