test instance

This commit is contained in:
ntr
2019-05-16 21:07:33 +10:00
parent 0a44f7b950
commit bda53462b8
9 changed files with 5767 additions and 142 deletions
+31 -1
View File
@@ -2,10 +2,14 @@ const { connect } = require('preact-redux');
const preact = require('preact');
const actions = require('../actions');
const testGame = require('./../test.game');
const testInstance = require('./../test.instance');
const addState = connect(
function receiveState(state) {
const {
ws,
account,
instances,
cryps,
} = state;
@@ -15,17 +19,36 @@ const addState = connect(
}
return {
account,
instances,
sendInstanceState,
};
},
function receiveDispatch(dispatch) {
function setTestGame(id) {
return dispatch(actions.setGame(testGame(id)));
}
function setTestInstance(id) {
return dispatch(actions.setInstance(testInstance(id)));
}
return {
setTestGame,
setTestInstance,
};
}
);
function Nav(args) {
const {
account,
sendInstanceState,
instances,
} = args;
setTestGame,
setTestInstance,
} = args;
const joined = instances.map((i, j) => (
<button key={j} onClick={() => sendInstanceState(i)} >{i.name}</button>
@@ -33,10 +56,17 @@ function Nav(args) {
return (
<nav>
<h2>Team</h2>
<button>spawn</button>
<button>select</button>
<h2>Instances</h2>
<button>list</button>
<button>new</button>
<hr />
{joined}
<h2>Hax</h2>
<button onClick={() => setTestGame(account.id)}>Test Game</button>
<button onClick={() => setTestInstance(account.id)}>Test Instance</button>
</nav>
);
}
+3 -5
View File
@@ -1,8 +1,8 @@
const preact = require('preact');
const logger = require('redux-diff-logger');
// const logger = require('redux-diff-logger');
const { Provider } = require('preact-redux');
const { createStore, combineReducers, applyMiddleware } = require('redux');
const { createStore, combineReducers } = require('redux');
const reducers = require('./reducers');
const actions = require('./actions');
@@ -15,8 +15,7 @@ const Body = require('./components/body.component');
const Nav = require('./components/nav');
// Redux Store
const createStoreWithMiddleware = applyMiddleware(logger)(createStore);
const store = createStoreWithMiddleware(
const store = createStore(
combineReducers({
account: reducers.accountReducer,
activeCryp: reducers.activeCrypReducer,
@@ -41,7 +40,6 @@ const store = createStoreWithMiddleware(
})
);
document.fonts.load('16pt "Jura"').then(() => {
const events = registerEvents(store);
store.subscribe(() => console.log(store.getState()));
-4
View File
@@ -1,8 +1,6 @@
const toast = require('izitoast');
const cbor = require('borc');
const testGame = require('./test.game');
const SOCKET_URL = process.env.NODE_ENV === 'production' ? 'wss://cryps.gg/ws' : 'ws://localhost:40000';
function errorToast(err) {
@@ -311,8 +309,6 @@ function createSocket(events) {
events.setAccount(account);
sendAccountInstances();
sendAccountCryps();
// events.setGame(testGame(account.id));
// clearGameStateTimeout();
}
sendPing();
+7 -6
View File
@@ -1,3 +1,4 @@
/* eslint-disable */
function testGame(uuid) {
return {
"id": "667ad344-dc76-40b9-bb9c-0d20f0f7f5d2",
@@ -297,7 +298,7 @@ function testGame(uuid) {
"cryps": [
{
"id": "3aa0f284-1e1b-4054-b38a-b2d50db471bd",
"account": "ec936c53-8eab-44e7-953f-9739531cee24",
"account": uuid,
"red_damage": {
"base": 256,
"value": Math.floor(Math.random() * 10000),
@@ -383,7 +384,7 @@ function testGame(uuid) {
},
{
"id": "50e5d94e-8ebe-495c-a916-3eb509ff4683",
"account": "ec936c53-8eab-44e7-953f-9739531cee24",
"account": uuid,
"red_damage": {
"base": 256,
"value": Math.floor(Math.random() * 10000),
@@ -463,7 +464,7 @@ function testGame(uuid) {
},
{
"id": "5d49fe65-27f0-4372-90a3-334ef906a0f5",
"account": "ec936c53-8eab-44e7-953f-9739531cee24",
"account": uuid,
"red_damage": {
"base": 256,
"value": Math.floor(Math.random() * 10000),
@@ -568,7 +569,7 @@ function testGame(uuid) {
},
{
"id": "6bc9c3ce-587e-4bbe-ac81-2bc536ebbce4",
"source_player_id": "ec936c53-8eab-44e7-953f-9739531cee24",
"source_player_id": uuid,
"source_cryp_id": "5d49fe65-27f0-4372-90a3-334ef906a0f5",
"target_cryp_id": "82e8b940-411c-42a1-8fc2-484ec7207734",
"skill": "Attack",
@@ -577,7 +578,7 @@ function testGame(uuid) {
},
{
"id": "9d2fc857-51c7-4640-a17c-a08496480830",
"source_player_id": "ec936c53-8eab-44e7-953f-9739531cee24",
"source_player_id": uuid,
"source_cryp_id": "3aa0f284-1e1b-4054-b38a-b2d50db471bd",
"target_cryp_id": "50e5d94e-8ebe-495c-a916-3eb509ff4683",
"skill": "Attack",
@@ -586,7 +587,7 @@ function testGame(uuid) {
},
{
"id": "e1bd2d77-181a-4f2d-a4f6-78c9ad3c5b3b",
"source_player_id": "ec936c53-8eab-44e7-953f-9739531cee24",
"source_player_id": uuid,
"source_cryp_id": "50e5d94e-8ebe-495c-a916-3eb509ff4683",
"target_cryp_id": "96ca4a0e-fed2-4ea2-9ec5-ae308f8dde4b",
"skill": "Attack",
File diff suppressed because it is too large Load Diff