@cardcore/game
Advanced tools
Comparing version 0.0.1-1f746c46 to 0.0.1-e610b5ce
@@ -6,2 +6,3 @@ "use strict"; | ||
}); | ||
exports.gameReducer = undefined; | ||
@@ -163,8 +164,18 @@ var _attack = require("./attack"); | ||
}); | ||
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } | ||
var gameReducer = exports.gameReducer = function gameReducer(state, action) { | ||
// initialization | ||
if (action.type === "@@INIT") { | ||
// On this one, clear out both the nextActions queue and the players list... this is the first | ||
// person joining. Everyone else joins with JOIN_GAME | ||
if (action.type === _startGame.CREATE_GAME) { | ||
return Object.assign({}, state, { | ||
game: { | ||
nextActions: [], | ||
startTime: action.startTime, | ||
nextActions: [{ | ||
action: { type: _startGame.JOIN_GAME }, | ||
// lol lol lol hack hack hack | ||
notPlayerId: action._sender | ||
}], | ||
allowedActions: {}, | ||
@@ -176,3 +187,3 @@ playerOrder: [], | ||
started: false, | ||
players: {}, | ||
players: _defineProperty({}, action._sender, {}), | ||
units: {}, | ||
@@ -185,6 +196,6 @@ randoSeeds: {}, | ||
if (action._prev) { | ||
if (action.prev) { | ||
return Object.assign({}, state, { | ||
game: Object.assign({}, state.game, { | ||
prev: action._prev | ||
prev: action.prev | ||
}) | ||
@@ -191,0 +202,0 @@ }); |
@@ -12,3 +12,3 @@ "use strict"; | ||
var _ssbKeys = require("ssb-keys"); | ||
var _ssbKeys = require("@streamplace/ssb-keys"); | ||
@@ -15,0 +15,0 @@ var _ssbKeys2 = _interopRequireDefault(_ssbKeys); |
@@ -12,3 +12,3 @@ "use strict"; | ||
var _ssbKeys = require("ssb-keys"); | ||
var _ssbKeys = require("@streamplace/ssb-keys"); | ||
@@ -15,0 +15,0 @@ var _ssbKeys2 = _interopRequireDefault(_ssbKeys); |
@@ -16,3 +16,3 @@ "use strict"; | ||
var _ssbKeys = require("ssb-keys"); | ||
var _ssbKeys = require("@streamplace/ssb-keys"); | ||
@@ -19,0 +19,0 @@ var _ssbKeys2 = _interopRequireDefault(_ssbKeys); |
@@ -6,3 +6,3 @@ "use strict"; | ||
}); | ||
exports.START_GAME = exports.ORDER_PLAYERS = exports.JOIN_GAME_ACCEPT = exports.joinGameStart = exports.JOIN_GAME_START = undefined; | ||
exports.createGame = exports.CREATE_GAME = exports.START_GAME = exports.ORDER_PLAYERS = exports.JOIN_GAME = undefined; | ||
exports.startGameReducer = startGameReducer; | ||
@@ -22,15 +22,16 @@ | ||
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } | ||
function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } } | ||
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } | ||
var JOIN_GAME_START = exports.JOIN_GAME_START = "JOIN_GAME_START"; | ||
var joinGameStart = exports.joinGameStart = function joinGameStart() { | ||
var JOIN_GAME = exports.JOIN_GAME = "JOIN_GAME"; | ||
var ORDER_PLAYERS = exports.ORDER_PLAYERS = "ORDER_PLAYERS"; | ||
var START_GAME = exports.START_GAME = "START_GAME"; | ||
var CREATE_GAME = exports.CREATE_GAME = "CREATE_GAME"; | ||
var createGame = exports.createGame = function createGame() { | ||
return { | ||
type: JOIN_GAME_START | ||
type: CREATE_GAME, | ||
startTime: Date.now() | ||
}; | ||
}; | ||
var JOIN_GAME_ACCEPT = exports.JOIN_GAME_ACCEPT = "JOIN_GAME_ACCEPT"; | ||
var ORDER_PLAYERS = exports.ORDER_PLAYERS = "ORDER_PLAYERS"; | ||
var START_GAME = exports.START_GAME = "START_GAME"; | ||
@@ -47,18 +48,3 @@ var INITIAL_PLAYER = { | ||
function startGameReducer(state, action) { | ||
if (action.type === JOIN_GAME_START) { | ||
// On this one, clear out both the nextActions queue and the players list... this is the first | ||
// person joining. Everyone else joins with JOIN_GAME_ACCEPT | ||
return Object.assign({}, state, { | ||
game: Object.assign({}, state.game, { | ||
players: _defineProperty({}, action._sender, {}), | ||
nextActions: [{ | ||
action: { type: JOIN_GAME_ACCEPT }, | ||
// lol lol lol hack hack hack | ||
notPlayerId: action._sender | ||
}] | ||
}) | ||
}); | ||
} | ||
if (action.type === JOIN_GAME_ACCEPT) { | ||
if (action.type === JOIN_GAME) { | ||
var lexicalPlayers = [].concat(_toConsumableArray(Object.keys(state.game.players)), [action._sender]).sort(); | ||
@@ -65,0 +51,0 @@ return Object.assign({}, state, { |
{ | ||
"name": "@cardcore/game", | ||
"version": "0.0.1-1f746c46", | ||
"version": "0.0.1-e610b5ce", | ||
"description": "base rules for the Streamplace card game", | ||
@@ -13,3 +13,6 @@ "main": "dist/index.js", | ||
}, | ||
"gitHead": "1f746c46c9911e36a1e9be89edf6da902e8ff20f" | ||
"dependencies": { | ||
"@streamplace/ssb-keys": "^7.0.16" | ||
}, | ||
"gitHead": "e610b5ce494b91bf26736417e3c8ba011f27ae84" | ||
} |
@@ -15,9 +15,20 @@ export * from "./attack"; | ||
import { CREATE_GAME, JOIN_GAME } from "./start-game"; | ||
export const gameReducer = (state, action) => { | ||
// initialization | ||
if (action.type === "@@INIT") { | ||
// On this one, clear out both the nextActions queue and the players list... this is the first | ||
// person joining. Everyone else joins with JOIN_GAME | ||
if (action.type === CREATE_GAME) { | ||
return { | ||
...state, | ||
game: { | ||
nextActions: [], | ||
startTime: action.startTime, | ||
nextActions: [ | ||
{ | ||
action: { type: JOIN_GAME }, | ||
// lol lol lol hack hack hack | ||
notPlayerId: action._sender | ||
} | ||
], | ||
allowedActions: {}, | ||
@@ -29,3 +40,5 @@ playerOrder: [], | ||
started: false, | ||
players: {}, | ||
players: { | ||
[action._sender]: {} | ||
}, | ||
units: {}, | ||
@@ -38,3 +51,3 @@ randoSeeds: {}, | ||
if (action._prev) { | ||
if (action.prev) { | ||
return { | ||
@@ -44,3 +57,3 @@ ...state, | ||
...state.game, | ||
prev: action._prev | ||
prev: action.prev | ||
} | ||
@@ -47,0 +60,0 @@ }; |
@@ -1,2 +0,2 @@ | ||
import ssbKeys from "ssb-keys"; | ||
import ssbKeys from "@streamplace/ssb-keys"; | ||
import { SEED_RNG } from "./seed-rng"; | ||
@@ -3,0 +3,0 @@ import { CHECK_DEATH } from "./check-death"; |
@@ -1,2 +0,2 @@ | ||
import ssbKeys from "ssb-keys"; | ||
import ssbKeys from "@streamplace/ssb-keys"; | ||
import { clientGenerateKey } from "@cardcore/client"; | ||
@@ -3,0 +3,0 @@ import { rando } from "@cardcore/util"; |
import { rotateArray, shuffle } from "@cardcore/util"; | ||
import { clientGenerateKey, clientBox } from "@cardcore/client"; | ||
import ssbKeys from "ssb-keys"; | ||
import ssbKeys from "@streamplace/ssb-keys"; | ||
@@ -5,0 +5,0 @@ export const SHUFFLE_DECK = "SHUFFLE_DECK"; |
@@ -8,11 +8,12 @@ import { SEED_RNG } from "./seed-rng"; | ||
export const JOIN_GAME_START = "JOIN_GAME_START"; | ||
export const joinGameStart = () => { | ||
export const JOIN_GAME = "JOIN_GAME"; | ||
export const ORDER_PLAYERS = "ORDER_PLAYERS"; | ||
export const START_GAME = "START_GAME"; | ||
export const CREATE_GAME = "CREATE_GAME"; | ||
export const createGame = () => { | ||
return { | ||
type: JOIN_GAME_START | ||
type: CREATE_GAME, | ||
startTime: Date.now() | ||
}; | ||
}; | ||
export const JOIN_GAME_ACCEPT = "JOIN_GAME_ACCEPT"; | ||
export const ORDER_PLAYERS = "ORDER_PLAYERS"; | ||
export const START_GAME = "START_GAME"; | ||
@@ -29,24 +30,3 @@ const INITIAL_PLAYER = { | ||
export function startGameReducer(state, action) { | ||
if (action.type === JOIN_GAME_START) { | ||
// On this one, clear out both the nextActions queue and the players list... this is the first | ||
// person joining. Everyone else joins with JOIN_GAME_ACCEPT | ||
return { | ||
...state, | ||
game: { | ||
...state.game, | ||
players: { | ||
[action._sender]: {} | ||
}, | ||
nextActions: [ | ||
{ | ||
action: { type: JOIN_GAME_ACCEPT }, | ||
// lol lol lol hack hack hack | ||
notPlayerId: action._sender | ||
} | ||
] | ||
} | ||
}; | ||
} | ||
if (action.type === JOIN_GAME_ACCEPT) { | ||
if (action.type === JOIN_GAME) { | ||
let lexicalPlayers = [ | ||
@@ -53,0 +33,0 @@ ...Object.keys(state.game.players), |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
140557
1
2464
+ Added@streamplace/chloride@2.2.12(transitive)
+ Added@streamplace/private-box@0.2.1(transitive)
+ Added@streamplace/ssb-keys@7.0.21(transitive)
+ Addedcall-bind@1.0.8(transitive)
+ Addedcall-bind-apply-helpers@1.0.1(transitive)
+ Addedcall-bound@1.0.3(transitive)
+ Addedchloride-test@1.2.4(transitive)
+ Addeddefine-data-property@1.1.4(transitive)
+ Addeddunder-proto@1.0.1(transitive)
+ Addeded2curve@0.1.4(transitive)
+ Addedes-define-property@1.0.1(transitive)
+ Addedes-errors@1.3.0(transitive)
+ Addedes-object-atoms@1.0.0(transitive)
+ Addedfunction-bind@1.1.2(transitive)
+ Addedget-intrinsic@1.2.7(transitive)
+ Addedget-proto@1.0.1(transitive)
+ Addedgopd@1.2.0(transitive)
+ Addedhas-property-descriptors@1.0.2(transitive)
+ Addedhas-symbols@1.1.0(transitive)
+ Addedhasown@2.0.2(transitive)
+ Addedinherits@2.0.4(transitive)
+ Addedis-electron@2.2.2(transitive)
+ Addedisarray@2.0.5(transitive)
+ Addedjson-buffer@2.0.11(transitive)
+ Addedjson-stable-stringify@1.2.1(transitive)
+ Addedjsonify@0.0.1(transitive)
+ Addedlibsodium@0.7.15(transitive)
+ Addedlibsodium-wrappers@0.7.15(transitive)
+ Addedmath-intrinsics@1.1.0(transitive)
+ Addedminimist@1.2.8(transitive)
+ Addedmkdirp@0.5.6(transitive)
+ Addedobject-keys@1.1.1(transitive)
+ Addedsafe-buffer@5.2.1(transitive)
+ Addedset-function-length@1.2.2(transitive)
+ Addedsha.js@2.4.112.4.5(transitive)
+ Addedsodium-browserify@1.3.0(transitive)
+ Addedsodium-browserify-tweetnacl@0.2.6(transitive)
+ Addedsodium-chloride@1.1.2(transitive)
+ Addedtweetnacl@0.14.51.0.3(transitive)
+ Addedtweetnacl-auth@0.3.1(transitive)