aboutsummaryrefslogtreecommitdiff
path: root/examples/macros/mystery-box.tsx
blob: 9e72ee1c033f1475ad847876c47e9f386a0078b8 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
// macro code:
export function mysteryBox(node) {
  const dice = Math.round(Math.random() * 100);
  if (dice < 25) {
    return <number value={5} />;
  } else if (dice < 50) {
    return <true />;
  } else if (dice < 75) {
    return <false />;
  } else if (dice < 90) {
    return <string value="a string" />;
  } else {
    return <string value={"a very rare string " + dice.toString(10)} />;
  }
}