Implement highscore/leaderboard top 10 best games and add tests with jest

This commit is contained in:
2019-09-05 22:48:15 +02:00
parent 1af2ceb862
commit 26a869a189
27 changed files with 760 additions and 101 deletions

View File

@@ -19,13 +19,17 @@ export const [SET_FPS, setFps] = module.action("SET_FPS", fps => ({ fps }));
export const [INVOKE_CALLERS, invokeCallers] = module.action("INVOKE_CALLERS");
export const [REGISTER_CALLER, registerCaller] = module.action("REGISTER_CALLER", name => ({ name }));
export const [UNREGISTER_CALLER, unregisterCaller] = module.action("UNREGISTER_CALLER", name => ({ name }));
export const [KEY_PRESS, keyPress] = module.action("KEY_PRESS", ({ key, altKey, ctrlKey, metaKey, shiftKey }) => ({
key,
altKey,
ctrlKey,
metaKey,
shiftKey
}));
export const [KEY_PRESS, keyPress] = module.action(
"KEY_PRESS",
({ key, altKey, ctrlKey, metaKey, shiftKey, target }) => ({
key,
altKey,
ctrlKey,
metaKey,
shiftKey,
target
})
);
export const [SUBSCRIBE_KEY_PRESSED, subscribeKeyPressed] = module.action("SUBSCRIBE_KEY_PRESSED", name => ({ name }));
export const [UNSUBSCRIBE_KEY_PRESSED, unsubscribeKeyPressed] = module.action("UNSUBSCRIBE_KEY_PRESSED", name => ({
name
@@ -100,9 +104,10 @@ module.middleware(INIT, (dispatch, { loopId }) => {
module.middleware(
KEY_PRESS,
(dispatch, { keyPressSubscribers = [], fps }, { key, altKey, ctrlKey, metaKey, shiftKey }) => {
console.log("key", key);
keyPressSubscribers.forEach(subscriber => dispatch({ type: subscriber, key, altKey, ctrlKey, metaKey, shiftKey }));
(dispatch, { keyPressSubscribers = [], fps }, { key, altKey, ctrlKey, metaKey, shiftKey, target }) => {
keyPressSubscribers.forEach(subscriber =>
dispatch({ type: subscriber, key, altKey, ctrlKey, metaKey, shiftKey, target })
);
if (key === keys.PLUS || key === keys.EQUAL) {
dispatch(setFps(fps + 1));