git ssb

4+

Dominic / nomic



Add simple state

%iDGGPF3wn7QRm+e99fKxkl953bKhb/kpEkIRXUMgIEg=.sha256
Open mixmix wants to merge commits into master from state
printTurn.jsadded
state.jsadded
printTurn.jsView
@@ -1,0 +1,32 @@
1 +const { players, currentTurn } = require('./state')
2 +
3 +printTurn()
4 +
5 +function printTurn () {
6 + const orderedPlayers = alphabetize(players)
7 + const currentPlayer = getCurrentTurnPlayer(orderedPlayers, currentTurn)
8 +
9 + orderedPlayers
10 + .forEach((p, index) => {
11 +
12 + const symbol = p.key === currentPlayer.key
13 + ? '> '
14 + : ' '
15 + process.stdout.write(`${symbol} ${p.name}\n`)
16 + })
17 +}
18 +
19 +function alphabetize (players) {
20 + return Object.keys(players)
21 + .map(k => Object.assign({}, players[k], { key: k }))
22 + .sort((a, b) => a.surname > b.surname ? 1 : -1)
23 +}
24 +
25 +function getCurrentTurnPlayer (orderedPlayers, currentTurn) {
26 + return orderedPlayers[(currentTurn - 1) % orderedPlayers.length]
27 +
28 + // This is going to break real bad when:
29 + // - people join the game
30 + // - people are 'inactive' in some capacity
31 +}
32 +
state.jsView
@@ -1,0 +1,46 @@
1 +module.exports = {
2 + currentTurn: 2,
3 + players: {
4 + '@3PGWnoMIY5ebs6sJjkwc7DKjxrgcrOeIUC2YegkMtIY=.ed25519': {
5 + name: 'soggypretzels',
6 + surname: 'B'
7 + },
8 + '@z8aJVHJTc6MM8FwaNE2GIS3AYYt2HYFNWQUO8/iydNw=.ed25519': {
9 + name: 'ktorn',
10 + surname: 'F'
11 + },
12 + '@+D0ku/LReK6kqd3PSrcVCfbLYbDtTmS4Bd21rqhpYNA=.ed25519': {
13 + name: 'nanomonkey',
14 + surname: 'G'
15 + },
16 + '@ye+QM09iPcDJD6YvQYjoQc7sLF/IFhmNbEqgdzQo3lQ=.ed25519': {
17 + name: 'mix',
18 + surname: 'I'
19 + },
20 + '@TXKFQehlyoSn8UJAIVP/k2BjFINC591MlBC2e2d24mA=.ed25519': {
21 + name: 'dangerousbeans',
22 + surname: 'K'
23 + },
24 + '@ZqH7Mctu/7DNInxuwl12ECjfrAKUX2tBLq1rOldNhg0=.ed25519': {
25 + name: 'zach!',
26 + surname: 'Man'
27 + },
28 + '@RJ09Kfs3neEZPrbpbWVDxkN92x9moe3aPusOMOc4S2I=.ed25519': {
29 + name: 'happy0',
30 + surname: 'Mar'
31 + },
32 + '@EMovhfIrFk4NihAKnRNhrfRaqIhBv1Wj8pTxJNgvCCY=.ed25519': {
33 + name: 'dominic',
34 + surname: 'T'
35 + },
36 + '@6ilZq3kN0F+dXFHAPjAwMm87JEb/VdB+LC9eIMW3sa0=.ed25519': {
37 + name: 'dinosaur',
38 + surname: 'W'
39 + },
40 + '@ZcjYF92reFjUtEYdoJ8ulOI6N6klwAAaIkghEEHdvSE=.ed25519': {
41 + name: 'alanz',
42 + surname: 'Z'
43 + }
44 + }
45 +}
46 +

Built with git-ssb-web