本文へ移動

Taisen Brackets対戦

対戦の一覧から、トーナメント表をSVGで描きます。

対戦(たいせん)は、二者が向かい合って勝負することです。 名前について(英語)

目次

リファレンス · トーナメント表・表・決勝までの道を描く

tallyMedals関数

リファレンスの説明と例は英語です。見出しと目次は日本語です。

Adds up a list of medals into the rows of a table, one row for each name, keeping the first flag, mark, code and note given for it. filter keeps only the medals of one sport, one category or one Games (or a list of them): the same list gives the table of an event, of a sport and of all time. Throws a RangeError for a medal that is not gold, silver or bronze or has no name.

インポート

import { tallyMedals } from "@johnmorrisdotca/taisen-brackets";

定義

function tallyMedals(awards: readonly MedalAward[], filter?: MedalFilter): MedalRow[]

引数

名前型説明
awardsreadonly MedalAward[]

The medals won.

filter (省略可)MedalFilter

Which medals to count: a sport, a category or a Games.

戻り値

MedalRow[]

One row for each name, ready for medalTable.

例

import { medalTable, tallyMedals } from "@johnmorrisdotca/taisen-brackets";

const awards = [
  { name: "France", flag: "FR", medal: "gold", sport: "judo", category: "+100 kg", games: 2024 },
  { name: "Japan", flag: "JP", medal: "silver", sport: "judo", category: "+100 kg", games: 2024 },
  { name: "France", medal: "bronze", sport: "judo", category: "-66 kg", games: 2020 },
  { name: "Japan", medal: "gold", sport: "wrestling", category: "-65 kg", games: 2020 },
] as const;
const judo = tallyMedals(awards, { sport: "judo" });
console.log(judo.map((r) => `${r.name} ${r.gold}-${r.silver}-${r.bronze}`).join(", "), medalTable({ rows: judo }).includes("France"));
France 1-0-1, Japan 0-1-0 true

出力(このページを作ったときに実行した結果)

ソースを見るGitHub で編集@johnmorrisdotca/taisen-brackets 0.20.0 のソースから作成しました。

この日本語は、まだ日本語を母語とする方の確認を受けていません。訂正を歓迎します。