Created
March 20, 2020 23:47
-
-
Save pvinis/463a54294433298b6b065c45f6329b89 to your computer and use it in GitHub Desktop.
Generated by XState Viz: https://xstate.js.org/viz
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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