メインコンテンツへスキップ

コードフレームワーク

レシピ: ラベル付きの選択肢

選択肢にはわかりやすい名前を表示し、ルールでは短い値を使い続けます。

目標

プレイヤーが Lantern guard か Lantern scout を選べるようにします。ルールとシナリオでは、引き続き Guard と Scout を使います。

変更内容

schemas/keeper.json
    "calling": {
      "label": "Calling",
      "options": ["Guard", "Scout"],
      "defaultValue": "Guard",
      "optionLabels": { "Guard": "Lantern guard", "Scout": "Lantern scout" }
    }
  1. 11 行目 保存される値です。ルールとシナリオはこれを使います。
  2. 13 行目 optionLabels は、各 option をプレイヤーに見えるテキストに対応付けます。

ラベルは options を持つ入力のものです。options がないと、検証で拒否されます。

declares optionLabels, but it has no options.

テストする

シナリオは、これまでどおり Guard のような option そのものを渡します。ほかは変わりません。

次へ