rename battle -> game
This commit is contained in:
@@ -7,8 +7,8 @@ export const setCryps = (value) => ({ type: SET_CRYPS, value });
|
||||
export const SET_ITEMS = 'SET_ITEMS';
|
||||
export const setItems = (value) => ({ type: SET_ITEMS, value });
|
||||
|
||||
export const SET_BATTLE = 'SET_BATTLE';
|
||||
export const setBattle = (value) => ({ type: SET_BATTLE, value });
|
||||
export const SET_GAME = 'SET_GAME';
|
||||
export const setGame = (value) => ({ type: SET_GAME, value });
|
||||
|
||||
export const SET_ACTIVE_CRYP = 'SET_ACTIVE_CRYP';
|
||||
export const setActiveCryp = (value) => ({ type: SET_ACTIVE_CRYP, value });
|
||||
|
||||
@@ -1,19 +0,0 @@
|
||||
const preact = require('preact');
|
||||
|
||||
function CrypPanel({ battle }) {
|
||||
if (!battle) return <div>...</div>;
|
||||
return (
|
||||
<div>{JSON.stringify(battle)}</div>
|
||||
)
|
||||
// return (
|
||||
// <div className="">
|
||||
// <div>{JSON.stringify(battle.a)}</div>
|
||||
// <div>{JSON.stringify(battle.b)}</div>
|
||||
// <div>
|
||||
// {battle.log.map((l, i) => (<p key={i} >{l}</p>))}
|
||||
// </div>
|
||||
// </div>
|
||||
// );
|
||||
}
|
||||
|
||||
module.exports = CrypPanel;
|
||||
@@ -4,7 +4,7 @@ const preact = require('preact');
|
||||
const ItemListContainer = require('./item.list.container');
|
||||
const CrypSpawnContainer = require('./cryp.spawn.container');
|
||||
const CrypListContainer = require('./cryp.list.container');
|
||||
const BattleContainer = require('./battle.container');
|
||||
const GameContainer = require('./game.container');
|
||||
|
||||
function renderBody() {
|
||||
return (
|
||||
@@ -25,7 +25,7 @@ function renderBody() {
|
||||
</div>
|
||||
</div>
|
||||
<div className="column">
|
||||
<BattleContainer />
|
||||
<GameContainer />
|
||||
</div>
|
||||
</section>
|
||||
);
|
||||
|
||||
@@ -1,16 +1,16 @@
|
||||
const { connect } = require('preact-redux');
|
||||
|
||||
const Battle = require('./battle');
|
||||
const Game = require('./game');
|
||||
|
||||
const addState = connect(
|
||||
function receiveState(state) {
|
||||
const { battle } = state;
|
||||
const { game } = state;
|
||||
// function sendCombatPve(crypId) {
|
||||
// return ws.sendCombatPve(crypId);
|
||||
// }
|
||||
|
||||
return { battle };
|
||||
return { game };
|
||||
}
|
||||
);
|
||||
|
||||
module.exports = addState(Battle);
|
||||
module.exports = addState(Game);
|
||||
@@ -0,0 +1,19 @@
|
||||
const preact = require('preact');
|
||||
|
||||
function GamePanel({ game }) {
|
||||
if (!game) return <div>...</div>;
|
||||
return (
|
||||
<div>{JSON.stringify(game)}</div>
|
||||
)
|
||||
// return (
|
||||
// <div className="">
|
||||
// <div>{JSON.stringify(game.a)}</div>
|
||||
// <div>{JSON.stringify(game.b)}</div>
|
||||
// <div>
|
||||
// {game.log.map((l, i) => (<p key={i} >{l}</p>))}
|
||||
// </div>
|
||||
// </div>
|
||||
// );
|
||||
}
|
||||
|
||||
module.exports = GamePanel;
|
||||
+1
-1
@@ -18,7 +18,7 @@ const store = createStore(
|
||||
combineReducers({
|
||||
activeItem: reducers.activeItemReducer,
|
||||
account: reducers.accountReducer,
|
||||
battle: reducers.battleReducer,
|
||||
game: reducers.gameReducer,
|
||||
cryps: reducers.crypsReducer,
|
||||
items: reducers.itemsReducer,
|
||||
ws: reducers.wsReducer,
|
||||
|
||||
@@ -40,10 +40,10 @@ function activeItemReducer(state = defaultActiveItem, action) {
|
||||
}
|
||||
}
|
||||
|
||||
const defaultBattle = null;
|
||||
function battleReducer(state = defaultBattle, action) {
|
||||
const defaultGame = null;
|
||||
function gameReducer(state = defaultGame, action) {
|
||||
switch (action.type) {
|
||||
case actions.SET_BATTLE:
|
||||
case actions.SET_GAME:
|
||||
return action.value;
|
||||
default:
|
||||
return state;
|
||||
@@ -62,7 +62,7 @@ function wsReducer(state = defaultWs, action) {
|
||||
|
||||
module.exports = {
|
||||
activeItemReducer,
|
||||
battleReducer,
|
||||
gameReducer,
|
||||
accountReducer,
|
||||
crypsReducer,
|
||||
itemsReducer,
|
||||
|
||||
@@ -69,9 +69,9 @@ function createSocket(store) {
|
||||
console.log('got my cryps', cryps);
|
||||
}
|
||||
|
||||
function battleState(response) {
|
||||
const [structName, battle] = response;
|
||||
store.dispatch(actions.setBattle(battle));
|
||||
function gameState(response) {
|
||||
const [structName, game] = response;
|
||||
store.dispatch(actions.setGame(game));
|
||||
}
|
||||
|
||||
function crypSpawn(response) {
|
||||
@@ -80,8 +80,8 @@ function createSocket(store) {
|
||||
}
|
||||
|
||||
function combatPve(response) {
|
||||
const [structName, battle] = response;
|
||||
console.log('got a new battle', battle);
|
||||
const [structName, game] = response;
|
||||
console.log('got a new game', game);
|
||||
}
|
||||
|
||||
function itemList(response) {
|
||||
@@ -124,7 +124,7 @@ function createSocket(store) {
|
||||
const handlers = {
|
||||
cryp_spawn: crypSpawn,
|
||||
combat_pve: combatPve,
|
||||
battle_state: battleState,
|
||||
game_state: gameState,
|
||||
account_login: accountLogin,
|
||||
account_create: accountLogin,
|
||||
account_cryps: accountCryps,
|
||||
|
||||
Reference in New Issue
Block a user