Skip to content

Instantly share code, notes, and snippets.

@pvinis
Created March 20, 2020 23:47
Show Gist options
  • Save pvinis/463a54294433298b6b065c45f6329b89 to your computer and use it in GitHub Desktop.
Save pvinis/463a54294433298b6b065c45f6329b89 to your computer and use it in GitHub Desktop.
Generated by XState Viz: https://xstate.js.org/viz
const tichuMachine = Machine({
id: "tichu",
initial: "init",
context: {
grandTichu: []
},
states: {
init: {
on: {
DEAL_FIRST: "grandTichus",
}
},
grandTichus: {
on: {
DEAL_REST: "trade",
DECLARE_GRAND_TICHU_0: {
target: "grandTichus",
cond: (context, event) => !context.grandTichu.includes("0"),
actions: assign({
grandTichu: (context, event) => context.grandTichu.push("0")
})
},
DECLARE_GRAND_TICHU_1: {
target: "grandTichus",
cond: (context, event) => !context.grandTichu.includes("1"),
actions: assign({
grandTichu: (context, event) => context.grandTichu.push("1")
})
}
}
},
trade: {
type: "final"
}
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment