@1hko/mtg 中文文档教程

发布于 3年前 浏览 24 更新于 3年前

mtg

parseDeck - 将套牌列表解析为[{ board, count, name, set, collector_number }]。 当输入行无效时抛出 Error { board, lineno, line }

const decklist = `
  1 Ulamog, the Infinite Gyre (mm2) 6
  4 Urza's Mine (atq) 83c
  4 Urza's Power Plant (atq) 84a
  4 Urza's Tower (atq) 85a
  4 Wall of Tanglecord (som) 222

  SIDEBOARD:
  1 Channel the Suns (5dn) 84
  4 Cloudpost (mrd) 280
`

parseDeck(decklist)
[
  { board: "main", "count": 1, "set": "mm2", "collector_number": "6" },
  { board: "main", "count": 4, "set": "atq", "collector_number": "83c" },
  { board: "main", "count": 4, "set": "atq", "collector_number": "84a" },
  { board: "main", "count": 4, "set": "atq", "collector_number": "85a" },
  { board: "main", "count": 4, "set": "som", "collector_number": "222" },
  { board: "side", "count": 1, "set": "5dn", "collector_number": "84" },
  { board: "side", "count": 4, "set": "mrd", "collector_number": "280" }
]

mtg

parseDeck - parse a decklist to [{ board, count, name, set, collector_number }]. Throws Error { board, lineno, line } when an input line is invalid.

const decklist = `
  1 Ulamog, the Infinite Gyre (mm2) 6
  4 Urza's Mine (atq) 83c
  4 Urza's Power Plant (atq) 84a
  4 Urza's Tower (atq) 85a
  4 Wall of Tanglecord (som) 222

  SIDEBOARD:
  1 Channel the Suns (5dn) 84
  4 Cloudpost (mrd) 280
`

parseDeck(decklist)
[
  { board: "main", "count": 1, "set": "mm2", "collector_number": "6" },
  { board: "main", "count": 4, "set": "atq", "collector_number": "83c" },
  { board: "main", "count": 4, "set": "atq", "collector_number": "84a" },
  { board: "main", "count": 4, "set": "atq", "collector_number": "85a" },
  { board: "main", "count": 4, "set": "som", "collector_number": "222" },
  { board: "side", "count": 1, "set": "5dn", "collector_number": "84" },
  { board: "side", "count": 4, "set": "mrd", "collector_number": "280" }
]
    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文