client var -> item

This commit is contained in:
ntr 2019-05-20 12:31:37 +10:00
parent ad702c8901
commit 331844f904
12 changed files with 54 additions and 54 deletions

View File

@ -53,7 +53,7 @@ export const SET_ACTIVE_CRYP = 'SET_ACTIVE_CRYP';
export const setActiveCryp = value => ({ type: SET_ACTIVE_CRYP, value });
export const SET_ACTIVE_VAR = 'SET_ACTIVE_VAR';
export const setActiveVar = value => ({ type: SET_ACTIVE_VAR, value });
export const setActiveItem = value => ({ type: SET_ACTIVE_VAR, value });
export const SET_INFO = 'SET_INFO';
export const setInfo = value => ({ type: SET_INFO, value });

View File

@ -2,7 +2,7 @@ const preact = require('preact');
const range = require('lodash/range');
const { ITEMS: { SKILLS, COLOURS, SPECS: SPEC_CONSTANT } } = require('./../constants');
const { COLOUR_ICONS, STATS, SPECS, convertVar, crypAvatar } = require('../utils');
const { COLOUR_ICONS, STATS, SPECS, convertItem, crypAvatar } = require('../utils');
const shapes = require('./shapes');
const InfoCryp = require('./info.cryp');
@ -19,7 +19,7 @@ function Info(args) {
vboxHidden,
} = args;
function CrypVar() {
function CrypItem() {
if (!info) return false;
const [type, value] = info;
if (!type) return false;
@ -48,7 +48,7 @@ function Info(args) {
return console.warn('UNHANLDED VAR', value);
}
return (
<div className="info-var">
<div className="info-item">
{value} - {itemDetails.description}
</div>
);
@ -175,8 +175,8 @@ function Info(args) {
<tbody>
{filteredCombos.map((c, i) =>
<tr key={i} >
<td className="highlight" >{convertVar(c.var)}</td>
{c.units.map((u, j) => <td key={j}>{convertVar(u)}</td>)}
<td className="highlight" >{convertItem(c.item)}</td>
{c.units.map((u, j) => <td key={j}>{convertItem(u)}</td>)}
</tr>
)}
</tbody>
@ -190,8 +190,8 @@ function Info(args) {
<tbody>
{vboxCombos.map((c, i) =>
<tr key={i} >
<td className="highlight" >{convertVar(c.var)}</td>
{c.units.map((u, j) => <td key={j} >{convertVar(u)}</td>)}
<td className="highlight" >{convertItem(c.item)}</td>
{c.units.map((u, j) => <td key={j} >{convertItem(u)}</td>)}
</tr>
)}
</tbody>
@ -207,7 +207,7 @@ function Info(args) {
return (
<div className={classes} >
<CrypVar />
<CrypItem />
<Combos />
</div>
);

View File

@ -52,8 +52,8 @@ function InfoCryp(args) {
if (!cryp) return false;
function setHighlight(type) {
if (type === 'skill') return setVboxHighlight(vboxInfo.vars.filter(v => v.skill).map(v => v.v));
if (type === 'spec') return setVboxHighlight(vboxInfo.vars.filter(v => v.spec).map(v => v.v));
if (type === 'skill') return setVboxHighlight(vboxInfo.items.filter(v => v.skill).map(v => v.v));
if (type === 'spec') return setVboxHighlight(vboxInfo.items.filter(v => v.spec).map(v => v.v));
return false;
}

View File

@ -6,7 +6,7 @@ const Instance = require('./instance.component');
const addState = connect(
function receiveState(state) {
const { ws, instance, player, account, activeVar, vboxHidden } = state;
const { ws, instance, player, account, activeItem, vboxHidden } = state;
function sendInstanceReady() {
return ws.sendInstanceReady(instance.id);
@ -16,7 +16,7 @@ const addState = connect(
return ws.sendVboxApply(instance.id, crypId, i);
}
return { instance, player, account, sendInstanceReady, sendVboxApply, activeVar, vboxHidden };
return { instance, player, account, sendInstanceReady, sendVboxApply, activeItem, vboxHidden };
},
function receiveDispatch(dispatch) {

View File

@ -8,7 +8,7 @@ const actions = require('../actions');
const addState = connect(
function receiveState(state) {
const { ws, instance, player, account, vboxHidden, vboxInfo, activeVar, activeCryp } = state;
const { ws, instance, player, account, vboxHidden, vboxInfo, activeItem, activeCryp } = state;
function sendInstanceReady() {
return ws.sendInstanceReady(instance.id);
@ -18,7 +18,7 @@ const addState = connect(
return ws.sendVboxApply(instance.id, crypId, i);
}
return { instance, player, account, sendInstanceReady, sendVboxApply, vboxHidden, vboxInfo, activeVar, activeCryp };
return { instance, player, account, sendInstanceReady, sendVboxApply, vboxHidden, vboxInfo, activeItem, activeCryp };
},
function receiveDispatch(dispatch) {
@ -50,7 +50,7 @@ const addState = connect(
function Cryp(props) {
const {
activeCryp,
activeVar,
activeItem,
cryp,
player,
sendVboxApply,
@ -61,21 +61,21 @@ function Cryp(props) {
} = props;
function setHighlight(type) {
if (type === 'skill') return setVboxHighlight(vboxInfo.vars.filter(v => v.skill).map(v => v.v));
if (type === 'spec') return setVboxHighlight(vboxInfo.vars.filter(v => v.spec).map(v => v.v));
if (type === 'skill') return setVboxHighlight(vboxInfo.items.filter(v => v.skill).map(v => v.v));
if (type === 'spec') return setVboxHighlight(vboxInfo.items.filter(v => v.spec).map(v => v.v));
return false;
}
function onClick(e) {
e.stopPropagation();
e.preventDefault();
if (activeVar !== null) sendVboxApply(cryp.id, activeVar);
if (activeItem !== null) sendVboxApply(cryp.id, activeItem);
return setActiveCryp(cryp);
}
const { vbox } = player;
const skillList = vboxInfo.vars.filter(v => v.skill).map(v => v.v);
const specList = vboxInfo.vars.filter(v => v.spec).map(v => v.v);
const skillList = vboxInfo.items.filter(v => v.skill).map(v => v.v);
const specList = vboxInfo.items.filter(v => v.spec).map(v => v.v);
const skills = range(0, 3).map(i => {
const skill = cryp.skills[i];
@ -84,7 +84,7 @@ function Cryp(props) {
: (<span className="gray">+</span>);
function skillClick(e) {
if (!skill && activeVar !== null) return sendVboxApply(cryp.id, activeVar);
if (!skill && activeItem !== null) return sendVboxApply(cryp.id, activeItem);
if (!skill) setHighlight('skill');
else setInfo('skill', { skill: skill.skill, cryp });
e.stopPropagation();
@ -92,7 +92,7 @@ function Cryp(props) {
}
const action = skill ? '' : 'action';
const equip = skillList.includes(vbox.bound[activeVar]) && !skill ? 'equip' : '';
const equip = skillList.includes(vbox.bound[activeItem]) && !skill ? 'equip' : '';
const classes = `right ${action} ${equip}`;
return (
<button key={i} className={classes} onClick={skillClick} >{s}</button>
@ -104,13 +104,13 @@ function Cryp(props) {
function blankSpecClick(e) {
e.stopPropagation();
if (activeVar !== null) return sendVboxApply(cryp.id, activeVar);
if (activeItem !== null) return sendVboxApply(cryp.id, activeItem);
setHighlight('spec');
return setActiveCryp(cryp);
}
if (!s) {
const equip = specList.includes(vbox.bound[activeVar]) ? 'equip-spec' : 'gray';
const equip = specList.includes(vbox.bound[activeItem]) ? 'equip-spec' : 'gray';
return (
<figure key={i} onClick={blankSpecClick} className={equip} >
{shapes.diamond(`stat-icon ${equip}`)}
@ -185,7 +185,7 @@ function Cryp(props) {
function InstanceCryps(props) {
const {
activeCryp,
activeVar,
activeItem,
player,
instance,
// clearInfo,
@ -202,7 +202,7 @@ function InstanceCryps(props) {
if (instance.phase === 'Lobby') return false;
const cryps = player.cryps.map((c, i) => Cryp({
activeCryp, activeVar, cryp: c, player, sendVboxApply, setInfo, setActiveCryp, vboxInfo, setVboxHighlight,
activeCryp, activeItem, cryp: c, player, sendVboxApply, setInfo, setActiveCryp, vboxInfo, setVboxHighlight,
}));
const classes = `cryp-list ${vboxHidden ? '' : 'hidden'}`;

View File

@ -3,7 +3,7 @@ const preact = require('preact');
const range = require('lodash/range');
const actions = require('../actions');
const { convertVar, SPECS } = require('./../utils');
const { convertItem, SPECS } = require('./../utils');
const addState = connect(
function receiveState(state) {
@ -25,11 +25,11 @@ const addState = connect(
return dispatch(actions.setInfo([]));
}
function setActiveVar(v) {
return dispatch(actions.setActiveVar(v));
function setActiveItem(v) {
return dispatch(actions.setActiveItem(v));
}
return { setInfo, setActiveVar, clearInfo };
return { setInfo, setActiveItem, clearInfo };
}
);
@ -41,7 +41,7 @@ function Equipment(props) {
vboxInfo,
sendUnequip,
setInfo,
setActiveVar,
setActiveItem,
} = props;
const { vbox } = player;
@ -51,7 +51,7 @@ function Equipment(props) {
function boundClick(e, i) {
const value = vbox.bound[i];
setInfo('item', value);
setActiveVar(i);
setActiveItem(i);
return false;
}
@ -70,12 +70,12 @@ function Equipment(props) {
const specClass = infoType === 'spec' ? 'specs highlight' : 'specs';
// const classes = `right ${skill ? '' : 'action'}`;
const skillList = vboxInfo.vars.filter(v => v.skill).map(v => v.v);
const specList = vboxInfo.vars.filter(v => v.spec).map(v => v.v);
const skillList = vboxInfo.items.filter(v => v.skill).map(v => v.v);
const specList = vboxInfo.items.filter(v => v.spec).map(v => v.v);
const skills = range(0, 9).map(i => {
const item = convertVar(vbox.bound[i]);
const item = convertItem(vbox.bound[i]);
if (skillList.includes(item)) {
return (
<button key={i} className={''} onClick={e => boundClick(e, i)}>
@ -86,7 +86,7 @@ function Equipment(props) {
});
const specs = range(0, 9).map(i => {
const item = convertVar(vbox.bound[i]);
const item = convertItem(vbox.bound[i]);
if (specList.includes(item)) {
return (
<figure key={i} onClick={e => boundClick(e, i)}>

View File

@ -3,7 +3,7 @@ const range = require('lodash/range');
const shapes = require('./shapes');
const { convertVar } = require('./../utils');
const { convertItem } = require('./../utils');
function Vbox(args) {
const {
@ -42,7 +42,7 @@ function Vbox(args) {
const filteredCombos = vboxInfo.combos
.filter(combo => combinerValues.every(u => combo.units.includes(u)));
const comboValues = vboxInfo.vars.filter(v => {
const comboValues = vboxInfo.items.filter(v => {
if (!filteredCombos.some(c => c.units.includes(v.v))) return false;
if (!['Red', 'Green', 'Blue'].includes(v.v) && combinerValues.includes(v.v)) return false;
return true;
@ -104,7 +104,7 @@ function Vbox(args) {
onClick={freeClick}
onDblClick={() => sendVboxAccept(j, i) }
>
{convertVar(c)}
{convertItem(c)}
</td>;
});
@ -154,7 +154,7 @@ function Vbox(args) {
key={i}
className={`${highlighted ? 'highlight' : ''}`}
onClick={e => boundClick(e, i, highlighted) }>
{convertVar(value)}
{convertItem(value)}
</td>
);
});
@ -189,13 +189,13 @@ function Vbox(args) {
<tbody>
<tr>
<td onClick={() => combinerRmv(0)}>
{combiner[0] !== null ? convertVar(vbox.bound[combiner[0]]) : shapes.vboxColour('gray')}
{combiner[0] !== null ? convertItem(vbox.bound[combiner[0]]) : shapes.vboxColour('gray')}
</td>
<td onClick={() => combinerRmv(1)}>
{combiner[1] !== null ? convertVar(vbox.bound[combiner[1]]) : shapes.vboxColour('gray')}
{combiner[1] !== null ? convertItem(vbox.bound[combiner[1]]) : shapes.vboxColour('gray')}
</td>
<td onClick={() => combinerRmv(2)}>
{convertVar(vbox.bound[combiner[2]])}
{convertItem(vbox.bound[combiner[2]])}
</td>
</tr>
</tbody>

View File

@ -12,7 +12,7 @@ const addState = connect(
player,
combiner,
reclaiming,
activeVar,
activeItem,
activeCryp,
info,
vboxHidden,
@ -45,7 +45,7 @@ const addState = connect(
player,
combiner,
reclaiming,
activeVar,
activeItem,
activeCryp,
info,
vboxInfo,

View File

@ -112,8 +112,8 @@ function registerEvents(store) {
store.dispatch(actions.setActiveSkill(skill));
}
function setActiveVar(v) {
store.dispatch(actions.setActiveVar(v));
function setActiveItem(v) {
store.dispatch(actions.setActiveItem(v));
}
function clearInfo(info) {
@ -206,7 +206,7 @@ function registerEvents(store) {
clearCombiner,
setAccount,
setActiveSkill,
setActiveVar,
setActiveItem,
setCryps,
setCrypList,
setGame,

View File

@ -16,7 +16,7 @@ module.exports = {
account: createReducer(null, actions.SET_ACCOUNT),
activeCryp: createReducer(null, actions.SET_ACTIVE_CRYP),
activeSkill: createReducer(null, actions.SET_ACTIVE_SKILL),
activeVar: createReducer(null, actions.SET_ACTIVE_VAR),
activeItem: createReducer(null, actions.SET_ACTIVE_VAR),
combiner: createReducer([null, null, null], actions.SET_COMBINER),
cryps: createReducer([], actions.SET_CRYPS),
game: createReducer(null, actions.SET_GAME),
@ -33,6 +33,6 @@ module.exports = {
showLog: createReducer(false, actions.SET_SHOW_LOG),
vboxHidden: createReducer(false, actions.SET_VBOX_HIDDEN),
vboxHighlight: createReducer([], actions.SET_VBOX_HIGHLIGHT),
vboxInfo: createReducer({ combos: [], vars: [] }, actions.SET_VBOX_INFO),
vboxInfo: createReducer({ combos: [], items: [] }, actions.SET_VBOX_INFO),
ws: createReducer(null, actions.SET_WS),
};

View File

@ -93,7 +93,7 @@ function createSocket(events) {
function sendVboxApply(instanceId, crypId, index) {
send({ method: 'player_vbox_apply', params: { instance_id: instanceId, cryp_id: crypId, index } });
events.setActiveVar(null);
events.setActiveItem(null);
}
function sendVboxUnequip(instanceId, crypId, target) {

View File

@ -374,7 +374,7 @@ function getCombatText(cryp, resolution) {
return '';
}
function convertVar(v) {
function convertItem(v) {
if (['Red', 'Green', 'Blue'].includes(v)) {
return (
shapes.vboxColour(v.toLowerCase())
@ -390,7 +390,7 @@ function convertVar(v) {
module.exports = {
stringSort,
convertVar,
convertItem,
numSort,
genAvatar,
crypAvatar,