diff --git a/client/assets/styles/styles.css b/client/assets/styles/styles.css index 86959360..216a8856 100644 --- a/client/assets/styles/styles.css +++ b/client/assets/styles/styles.css @@ -481,7 +481,7 @@ main .top { /*box-shadow: inset -0.5em 0 0 0 forestgreen;*/ } -.ready { +.ready, .instance-btn.ready { color: forestgreen; border-color: forestgreen; box-shadow: inset -0.5em 0 0 0 forestgreen; diff --git a/client/src/actions.jsx b/client/src/actions.jsx index bf584a5f..8002fc6c 100644 --- a/client/src/actions.jsx +++ b/client/src/actions.jsx @@ -1,65 +1,24 @@ -export const SET_ACCOUNT = 'SET_ACCOUNT'; -export const setAccount = value => ({ type: SET_ACCOUNT, value }); - -export const SET_CRYPS = 'SET_CRYPS'; -export const setCryps = value => ({ type: SET_CRYPS, value }); - -export const SET_ITEM_INFO = 'SET_ITEM_INFO'; -export const setItemInfo = value => ({ type: SET_ITEM_INFO, value }); - -export const SET_SKIP = 'SET_SKIP'; -export const setSkip = value => ({ type: SET_SKIP, value }); - -export const SET_VBOX_HIGHLIGHT = 'SET_VBOX_HIGHLIGHT'; -export const setVboxHighlight = value => ({ type: SET_VBOX_HIGHLIGHT, value }); - -export const SET_VBOX_HIDDEN = 'SET_VBOX_HIDDEN'; -export const setVboxHidden = value => ({ type: SET_VBOX_HIDDEN, value }); - -export const SET_INSTANCES = 'SET_INSTANCES'; -export const setInstances = value => ({ type: SET_INSTANCES, value }); - -export const SET_NAV = 'SET_NAV'; -export const setNav = value => ({ type: SET_NAV, value }); - -export const SET_INSTANCE = 'SET_INSTANCE'; -export const setInstance = value => ({ type: SET_INSTANCE, value }); - -export const SET_PLAYER = 'SET_PLAYER'; -export const setPlayer = value => ({ type: SET_PLAYER, value }); - -export const SET_PING = 'SET_PING'; -export const setPing = value => ({ type: SET_PING, value }); - -export const SET_GAME = 'SET_GAME'; -export const setGame = value => ({ type: SET_GAME, value }); - -export const SET_RESOLUTION = 'SET_RESOLUTION'; -export const setResolution = value => ({ type: SET_RESOLUTION, value }); - -export const SET_SHOW_LOG = 'SET_SHOW_LOG'; -export const setShowLog = value => ({ type: SET_SHOW_LOG, value }); - -export const SET_COMBINER = 'SET_COMBINER'; -export const setCombiner = value => ({ type: SET_COMBINER, value: Array.from(value) }); - -export const SET_SELECTED_CRYPS = 'SET_SELECTED_CRYPS'; -export const setTeam = value => ({ type: SET_SELECTED_CRYPS, value: Array.from(value) }); - -export const SET_ACTIVE_SKILL = 'SET_ACTIVE_SKILL'; -export const setActiveSkill = (crypId, skill) => ({ type: SET_ACTIVE_SKILL, value: crypId ? { crypId, skill } : null }); - -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 setActiveItem = value => ({ type: SET_ACTIVE_VAR, value }); - -export const SET_INFO = 'SET_INFO'; -export const setInfo = value => ({ type: SET_INFO, value }); - -export const SET_RECLAIMING = 'SET_RECLAIMING'; -export const setReclaiming = value => ({ type: SET_RECLAIMING, value }); - -export const SET_WS = 'SET_WS'; -export const setWs = value => ({ type: SET_WS, value }); +export const setAccount = value => ({ type: 'SET_ACCOUNT', value }); +export const setCryps = value => ({ type: 'SET_CRYPS', value }); +export const setItemInfo = value => ({ type: 'SET_ITEM_INFO', value }); +export const setSkip = value => ({ type: 'SET_SKIP', value }); +export const setVboxHighlight = value => ({ type: 'SET_VBOX_HIGHLIGHT', value }); +export const setVboxHidden = value => ({ type: 'SET_VBOX_HIDDEN', value }); +export const setInstances = value => ({ type: 'SET_INSTANCES', value }); +export const setNav = value => ({ type: 'SET_NAV', value }); +export const setInstance = value => ({ type: 'SET_INSTANCE', value }); +export const setPlayer = value => ({ type: 'SET_PLAYER', value }); +export const setPing = value => ({ type: 'SET_PING', value }); +export const setGame = value => ({ type: 'SET_GAME', value }); +export const setResolution = value => ({ type: 'SET_RESOLUTION', value }); +export const setShowLog = value => ({ type: 'SET_SHOW_LOG', value }); +export const setCombiner = value => ({ type: 'SET_COMBINER', value: Array.from(value) }); +export const setTeam = value => ({ type: 'SET_SELECTED_CRYPS', value: Array.from(value) }); +export const setActiveSkill = (crypId, skill) => ({ type: 'SET_ACTIVE_SKILL', value: crypId ? { crypId, skill } : null }); +export const setActiveCryp = value => ({ type: 'SET_ACTIVE_CRYP', value }); +export const setActiveItem = value => ({ type: 'SET_ACTIVE_VAR', value }); +export const setInfo = value => ({ type: 'SET_INFO', value }); +export const setItemEquip = value => ({ type: 'SET_ITEM_EQUIP', value }); +export const setItemUnequip = value => ({ type: 'SET_ITEM_UNEQUIP', value }); +export const setReclaiming = value => ({ type: 'SET_RECLAIMING', value }); +export const setWs = value => ({ type: 'SET_WS', value }); diff --git a/client/src/components/game.component.jsx b/client/src/components/game.component.jsx index e297bc01..557d3bae 100644 --- a/client/src/components/game.component.jsx +++ b/client/src/components/game.component.jsx @@ -55,14 +55,19 @@ function GamePanel(props) { return sendGameReady(); } + const otherTeams = game.players.filter(t => t.id !== account.id); + const playerTeam = game.players.find(t => t.id === account.id); + let actionText = 'Ready'; + let actionStyles = 'instance-btn instance-ui-btn right'; if (game.phase === 'Finish') actionText = 'Done'; if (resolution) actionText = 'Skip'; + if (actionText === 'Ready' && playerTeam.ready) actionStyles += ' ready'; const header = (
@@ -75,8 +80,6 @@ function GamePanel(props) { return null; } - const otherTeams = game.players.filter(t => t.id !== account.id); - const playerTeam = game.players.find(t => t.id === account.id); const zero = Date.parse(game.phase_end) - (1000 * 60); const now = Date.now(); diff --git a/client/src/components/header.component.jsx b/client/src/components/header.component.jsx index f6cc34a4..1a5077bd 100644 --- a/client/src/components/header.component.jsx +++ b/client/src/components/header.component.jsx @@ -12,8 +12,8 @@ function pingColour(ping) { function renderHeader(args) { const { account, ping } = args; - const accountStatus = account ? - (
+ const accountStatus = account + ? (

{account.name}

{saw(pingColour(ping))}
{ping}ms
diff --git a/client/src/components/info.component.jsx b/client/src/components/info.component.jsx index 27b0e95e..1ae989bf 100644 --- a/client/src/components/info.component.jsx +++ b/client/src/components/info.component.jsx @@ -5,24 +5,27 @@ const { ITEMS: { SKILLS, COLOURS, SPECS: SPEC_CONSTANT } } = require('./../const const { COLOUR_ICONS, STATS, SPECS, convertItem, crypAvatar } = require('../utils'); const shapes = require('./shapes'); -const InfoCryp = require('./info.cryp'); - function Info(args) { const { activeCryp, + info, + infoCryp, + itemInfo, + combiner, sendUnequip, instance, player, - itemInfo, vboxHidden, } = args; function CrypItem() { if (!info) return false; - const [type, value] = info; - if (!type) return false; + const fullInfo = itemInfo.items.find(i => i.item === info); + if (!fullInfo) return false; + const isSkill = fullInfo.skill; + const isSpec = fullInfo.spec; let red = 0; let blue = 0; @@ -34,44 +37,23 @@ function Info(args) { }); const teamColours = { red, blue, green }; - if (type === 'item') { - let itemDetails; - if (SKILLS[value]) { - itemDetails = SKILLS[value]; - } else if (SPEC_CONSTANT[value]) { - itemDetails = SPEC_CONSTANT[value]; - } else if (COLOURS[value]) { - itemDetails = COLOURS[value]; - } + const unequipBtn = activeCryp + ? + : null; - if (!itemDetails) { - return console.warn('UNHANLDED VAR', value); - } - return ( -
- {value} - {itemDetails.description} -
- ); - } - - if (type === 'skill') { - const skillInfo = SKILLS[value.skill]; - const description = skillInfo ? skillInfo.description : '?????'; + if (isSkill) { return (
-
{value.skill}
-
{description}
- +
{fullInfo.item}
+
{fullInfo.description}
+ {unequipBtn}
); } - if (type === 'spec') { - const { spec } = value; - const breaks = SPEC_CONSTANT[value.spec].thresholds; - const colourReqs = SPEC_CONSTANT[spec].colours || []; + if (isSpec) { + const breaks = SPEC_CONSTANT[info].thresholds; + const colourReqs = SPEC_CONSTANT[info].colours || []; const thresholdEl = colourReqs.map((c, i) => { const numIcons = Math.max(...breaks); @@ -102,17 +84,21 @@ function Info(args) { return (
-
{value.spec}
-
{SPEC_CONSTANT[value.spec].description}
+
{info}
+
{fullInfo.description}
{thresholdEl}
- + {unequipBtn}
); } + + return ( +
+ {fullInfo.item} - {fullInfo.description} +
+ ); } function playerRound(id) { @@ -161,7 +147,7 @@ function Info(args) { } function Combos() { - if (!info[0]) return false; + if (info) return false; if (activeCryp) return false; if (!player) return false; @@ -183,7 +169,7 @@ function Info(args) { ); } - const vboxCombos = itemInfo.combos.filter(c => c.units.includes(info[1])); + const vboxCombos = itemInfo.combos.filter(c => c.units.includes(info)); if (vboxCombos.length > 6) return false; return ( @@ -212,7 +198,7 @@ function Info(args) { ); } -// not required anymore + // Takes up too much space maybe a context switch module.exports = Info; diff --git a/client/src/components/info.cryp.jsx b/client/src/components/info.cryp.jsx deleted file mode 100644 index 5b2e2bba..00000000 --- a/client/src/components/info.cryp.jsx +++ /dev/null @@ -1,134 +0,0 @@ -const preact = require('preact'); -const range = require('lodash/range'); -const { connect } = require('preact-redux'); - -const actions = require('../actions'); -const { STATS, SPECS, crypAvatar } = require('../utils'); -const shapes = require('./shapes'); - -const addState = connect( - function receiveState(state) { - const { activeCryp, player, itemInfo } = state; - return { activeCryp, player, itemInfo }; - }, - - function receiveDispatch(dispatch) { - function setInfo(item, value) { - dispatch(actions.setInfo([item, value])); - } - - function setActiveCryp(value) { - dispatch(actions.setActiveCryp(value)); - } - - function setVboxHidden(value) { - dispatch(actions.setVboxHidden(value)); - } - - function setVboxHighlight(v) { - dispatch(actions.setVboxHighlight(v)); - } - - return { setInfo, setActiveCryp, setVboxHidden, setVboxHighlight }; - } - -); - -function InfoCryp(args) { - const { - activeCryp, - player, - itemInfo, - - setVboxHidden, - setInfo, - setActiveCryp, - setVboxHighlight, - } = args; - - if (!activeCryp) return false; - const cryp = player.cryps.find(c => c.id === activeCryp.id); - - if (!cryp) return false; - - function setHighlight(type) { - if (type === 'skill') return setVboxHighlight(itemInfo.items.filter(v => v.skill).map(v => v.v)); - if (type === 'spec') return setVboxHighlight(itemInfo.items.filter(v => v.spec).map(v => v.v)); - return false; - } - - // onClick={() => setInfo('skill', { skill: s, cryp })} - const skills = range(0, 3).map(i => { - const skill = cryp.skills[i]; - - function skillClick(e) { - if (!skill) { - setVboxHidden(false); - setHighlight('skill'); - } else setInfo('skill', { skill: skill.skill, cryp }); - e.stopPropagation(); - return setActiveCryp(cryp); - } - - const s = cryp.skills[i] - ? cryp.skills[i].skill - : ( ); - return ; - }); - - const stats = Object.values(STATS).map((s, j) => ( -
- {s.svg(`stat-icon ${s.colour}`)} -
{cryp[s.stat].value}
-
- )); - - const specs = range(0, 6).map(i => { - const s = cryp.specs[i]; - - function blankSpecClick(e) { - e.stopPropagation(); - setActiveCryp(cryp); - setHighlight('spec'); - setVboxHidden(true); - } - - if (!s) { - return ( -
- {shapes.diamond('stat-icon gray')} -
 
-
- ); - } - - function specClick(e) { - e.stopPropagation(); - setActiveCryp(cryp); - setInfo('spec', { spec: s, cryp }); - } - - return ( -
- {SPECS[s].svg(`stat-icon ${SPECS[s].colour}`)} -
{SPECS[s].caption}
-
- ); - }); - - return ( -
-
- {stats} -
-
- {specs} -
-
- {skills} -
-
- ); -} - -module.exports = addState(InfoCryp); diff --git a/client/src/components/instance.component.jsx b/client/src/components/instance.component.jsx index ea0d753f..7c6fcb8d 100644 --- a/client/src/components/instance.component.jsx +++ b/client/src/components/instance.component.jsx @@ -9,11 +9,7 @@ function InstanceComponent(args) { const { instance, player, - quit, sendInstanceReady, - - vboxHidden, - setVboxHidden, } = args; if (!instance) return false; diff --git a/client/src/components/instance.container.jsx b/client/src/components/instance.container.jsx index 206333e9..3f518bd5 100644 --- a/client/src/components/instance.container.jsx +++ b/client/src/components/instance.container.jsx @@ -6,43 +6,14 @@ const Instance = require('./instance.component'); const addState = connect( function receiveState(state) { - const { ws, instance, player, account, activeItem, vboxHidden } = state; + const { ws, instance, player } = state; function sendInstanceReady() { return ws.sendInstanceReady(instance.id); } - function sendVboxApply(crypId, i) { - return ws.sendVboxApply(instance.id, crypId, i); - } - - return { instance, player, account, sendInstanceReady, sendVboxApply, activeItem, vboxHidden }; + return { instance, player, sendInstanceReady }; }, - - function receiveDispatch(dispatch) { - function quit() { - dispatch(actions.setInstance(null)); - } - - function setInfo(item, value) { - dispatch(actions.setInfo([item, value])); - } - - function setVboxHidden(v) { - dispatch(actions.setVboxHidden(v)); - } - - function setActiveCryp(value) { - dispatch(actions.setActiveCryp(value)); - } - - function clearInfo() { - return dispatch(actions.setInfo([])); - } - - return { quit, clearInfo, setInfo, setVboxHidden, setActiveCryp }; - } - ); module.exports = addState(Instance); diff --git a/client/src/components/instance.cryps.jsx b/client/src/components/instance.cryps.jsx index f2aabd96..3ccea696 100644 --- a/client/src/components/instance.cryps.jsx +++ b/client/src/components/instance.cryps.jsx @@ -8,7 +8,7 @@ const actions = require('../actions'); const addState = connect( function receiveState(state) { - const { ws, instance, player, account, vboxHidden, itemInfo, activeItem, activeCryp } = state; + const { ws, instance, player, account, vboxHidden, itemInfo, itemEquip, 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, itemInfo, activeItem, activeCryp }; + return { instance, player, account, sendInstanceReady, sendVboxApply, vboxHidden, itemInfo, itemEquip, activeCryp }; }, function receiveDispatch(dispatch) { @@ -26,8 +26,8 @@ const addState = connect( dispatch(actions.setInstance(null)); } - function setInfo(item, value) { - dispatch(actions.setInfo([item, value])); + function setInfo(item) { + dispatch(actions.setInfo(item)); } function setActiveCryp(value) { @@ -35,14 +35,22 @@ const addState = connect( } function clearInfo() { - return dispatch(actions.setInfo([])); + return dispatch(actions.setInfo(null)); } function setVboxHighlight(v) { dispatch(actions.setVboxHighlight(v)); } - return { quit, clearInfo, setInfo, setActiveCryp, setVboxHighlight }; + function setItemEquip(v) { + return dispatch(actions.setItemEquip(v)); + } + + function setItemUnequip(v) { + return dispatch(actions.setItemUnequip(v)); + } + + return { quit, clearInfo, setInfo, setActiveCryp, setItemUnequip, setItemEquip, setVboxHighlight }; } ); @@ -50,32 +58,34 @@ const addState = connect( function Cryp(props) { const { activeCryp, - activeItem, + itemEquip, cryp, player, sendVboxApply, - setInfo, setActiveCryp, + setItemUnequip, + setItemEquip, setVboxHighlight, itemInfo, } = props; function setHighlight(type) { - if (type === 'skill') return setVboxHighlight(itemInfo.items.filter(v => v.skill).map(v => v.v)); - if (type === 'spec') return setVboxHighlight(itemInfo.items.filter(v => v.spec).map(v => v.v)); + if (type === 'skill') return setVboxHighlight(itemInfo.items.filter(v => v.skill).map(v => v.item)); + if (type === 'spec') return setVboxHighlight(itemInfo.items.filter(v => v.spec).map(v => v.item)); return false; } function onClick(e) { e.stopPropagation(); e.preventDefault(); - if (activeItem !== null) sendVboxApply(cryp.id, activeItem); + if (itemEquip !== null) sendVboxApply(cryp.id, itemEquip); + setItemEquip(null); return setActiveCryp(cryp); } const { vbox } = player; - const skillList = itemInfo.items.filter(v => v.skill).map(v => v.v); - const specList = itemInfo.items.filter(v => v.spec).map(v => v.v); + const skillList = itemInfo.items.filter(v => v.skill).map(v => v.item); + const specList = itemInfo.items.filter(v => v.spec).map(v => v.item); const skills = range(0, 3).map(i => { const skill = cryp.skills[i]; @@ -84,15 +94,15 @@ function Cryp(props) { : (+); function skillClick(e) { - if (!skill && activeItem !== null) return sendVboxApply(cryp.id, activeItem); - if (!skill) setHighlight('skill'); - else setInfo('skill', { skill: skill.skill, cryp }); + if (!skill) return false; + setItemUnequip(skill.skill); + setActiveCryp(cryp); e.stopPropagation(); - return setActiveCryp(cryp); + return true; } const action = skill ? '' : 'action'; - const equip = skillList.includes(vbox.bound[activeItem]) && !skill ? 'equip' : ''; + const equip = skillList.includes(vbox.bound[itemEquip]) && !skill ? 'equip' : ''; const classes = `right ${action} ${equip}`; return ( @@ -104,13 +114,13 @@ function Cryp(props) { function blankSpecClick(e) { e.stopPropagation(); - if (activeItem !== null) return sendVboxApply(cryp.id, activeItem); + if (itemEquip !== null) return sendVboxApply(cryp.id, itemEquip); setHighlight('spec'); return setActiveCryp(cryp); } if (!s) { - const equip = specList.includes(vbox.bound[activeItem]) ? 'equip-spec' : 'gray'; + const equip = specList.includes(vbox.bound[itemEquip]) ? 'equip-spec' : 'gray'; return (
{shapes.diamond(`stat-icon ${equip}`)} @@ -120,8 +130,8 @@ function Cryp(props) { function specClick(e) { e.stopPropagation(); + setItemUnequip(s); setActiveCryp(cryp); - setInfo('spec', { spec: s, cryp }); } return ( @@ -185,7 +195,7 @@ function Cryp(props) { function InstanceCryps(props) { const { activeCryp, - activeItem, + itemEquip, player, instance, // clearInfo, @@ -196,13 +206,25 @@ function InstanceCryps(props) { vboxHidden, itemInfo, setVboxHighlight, + setItemUnequip, + setItemEquip, } = props; if (!player) return false; if (instance.phase === 'Lobby') return false; const cryps = player.cryps.map((c, i) => Cryp({ - activeCryp, activeItem, cryp: c, player, sendVboxApply, setInfo, setActiveCryp, itemInfo, setVboxHighlight, + activeCryp, + itemEquip, + setItemUnequip, + setItemEquip, + cryp: c, + player, + sendVboxApply, + setInfo, + setActiveCryp, + itemInfo, + setVboxHighlight, })); const classes = `cryp-list ${vboxHidden ? '' : 'hidden'}`; diff --git a/client/src/components/instance.equip.jsx b/client/src/components/instance.equip.jsx index 636c75c1..867e044e 100644 --- a/client/src/components/instance.equip.jsx +++ b/client/src/components/instance.equip.jsx @@ -7,29 +7,33 @@ const { convertItem, SPECS } = require('./../utils'); const addState = connect( function receiveState(state) { - const { player, itemInfo, info, ws, instance } = state; + const { player, activeCryp, itemInfo, info, ws, instance, itemUnequip } = state; function sendUnequip(crypId, item) { return ws.sendVboxUnequip(instance.id, crypId, item); } - return { player, itemInfo, info, sendUnequip }; + return { player, itemInfo, info, sendUnequip, activeCryp, itemUnequip }; }, function receiveDispatch(dispatch) { - function setInfo(item, value) { - dispatch(actions.setInfo([item, value])); + function setInfo(item) { + dispatch(actions.setInfo(item)); } function clearInfo() { - return dispatch(actions.setInfo([])); + return dispatch(actions.setInfo(null)); } - function setActiveItem(v) { - return dispatch(actions.setActiveItem(v)); + function setItemEquip(v) { + return dispatch(actions.setItemEquip(v)); } - return { setInfo, setActiveItem, clearInfo }; + function setItemUnequip(v) { + return dispatch(actions.setItemUnequip(v)); + } + + return { setInfo, setItemEquip, setItemUnequip, clearInfo }; } ); @@ -37,48 +41,47 @@ const addState = connect( function Equipment(props) { const { player, - info, + + itemUnequip, + setItemEquip, + setItemUnequip, + activeCryp, + itemInfo, sendUnequip, - setInfo, - setActiveItem, } = props; const { vbox } = player; - const infoType = info ? info[0] : false; - const infoValue = info ? info[1] : false; + + const fullInfo = itemInfo.items.find(i => i.item === itemUnequip); + const isSkill = fullInfo && fullInfo.skill; + const isSpec = fullInfo && fullInfo.spec; function boundClick(e, i) { const value = vbox.bound[i]; - setInfo('item', value); - setActiveItem(i); + setItemEquip(i); return false; } - function skillUnequip(e) { + function unequipClick(e) { e.stopPropagation(); - if (infoType === 'skill') sendUnequip(infoValue.cryp.id, infoValue.skill); - return true; + if (!itemUnequip) return false; + if (!activeCryp) return false; + setItemUnequip(null); + return sendUnequip(activeCryp.id, itemUnequip); } - function specUnequip(e) { - e.stopPropagation(); - if (infoType === 'spec') sendUnequip(infoValue.cryp.id, infoValue.spec); - return true; - } - const skillClass = infoType === 'skill' ? 'skills highlight' : 'skills'; - const specClass = infoType === 'spec' ? 'specs highlight' : 'specs'; - - // const classes = `right ${skill ? '' : 'action'}`; - const skillList = itemInfo.items.filter(v => v.skill).map(v => v.v); - const specList = itemInfo.items.filter(v => v.spec).map(v => v.v); + const skillClass = isSkill ? 'skills highlight' : 'skills'; + const specClass = isSpec ? 'specs highlight' : 'specs'; + const skillList = itemInfo.items.filter(v => v.skill).map(v => v.item); + const specList = itemInfo.items.filter(v => v.spec).map(v => v.item); const skills = range(0, 9).map(i => { const item = convertItem(vbox.bound[i]); if (skillList.includes(item)) { return ( - ); @@ -99,13 +102,13 @@ function Equipment(props) { return (
-
skillUnequip(e)}> +
unequipClick(e)}>

Skills

{skills}
-
specUnequip(e)}> +
unequipClick(e)}>

Specs

{specs} diff --git a/client/src/components/nav.jsx b/client/src/components/nav.jsx index f36c6c3e..c2f24989 100644 --- a/client/src/components/nav.jsx +++ b/client/src/components/nav.jsx @@ -80,7 +80,8 @@ function Nav(args) {

Team

{teamElements}

Instances

- + +
{joined}

Hax

diff --git a/client/src/components/team.jsx b/client/src/components/team.jsx index e88572b4..0af80d00 100644 --- a/client/src/components/team.jsx +++ b/client/src/components/team.jsx @@ -113,7 +113,7 @@ function Team(args) { disabled={team.some(c => !c)} className="instance-btn instance-ui-btn right" onClick={() => navToList()}> - Join an Instance + Join Instance
); diff --git a/client/src/components/vbox.component.jsx b/client/src/components/vbox.component.jsx index 3b01595f..9a77cf61 100644 --- a/client/src/components/vbox.component.jsx +++ b/client/src/components/vbox.component.jsx @@ -89,7 +89,7 @@ function Vbox(args) { function freeClick() { if (c) { setActiveCryp(null); - return setInfo('item', c); + return setInfo(c); } return false; } @@ -129,7 +129,7 @@ function Vbox(args) { const insert = combiner.findIndex(j => j === null); if (insert === -1) return combinerChange([i, null, null]); combiner[insert] = i; - setInfo('item', value); + setInfo(value); setActiveCryp(null); return combinerChange(combiner); } diff --git a/client/src/components/vbox.container.jsx b/client/src/components/vbox.container.jsx index c61fbfe4..1bb628cd 100644 --- a/client/src/components/vbox.container.jsx +++ b/client/src/components/vbox.container.jsx @@ -68,8 +68,8 @@ const addState = connect( return dispatch(actions.setReclaiming(v)); } - function setInfo(type, info) { - return dispatch(actions.setInfo([type, info])); + function setInfo(item) { + return dispatch(actions.setInfo(item)); } function setActiveCryp(v) { @@ -81,7 +81,7 @@ const addState = connect( } function showTeam() { - dispatch(actions.setInfo([null, null])); + dispatch(actions.setInfo(null)); dispatch(actions.setVboxHidden(true)); return true; } diff --git a/client/src/events.jsx b/client/src/events.jsx index 98260585..2f2eb5fc 100644 --- a/client/src/events.jsx +++ b/client/src/events.jsx @@ -116,8 +116,9 @@ function registerEvents(store) { store.dispatch(actions.setActiveItem(v)); } - function clearInfo(info) { - store.dispatch(actions.setInfo([])); + function clearInfo() { + store.dispatch(actions.setInfo(null)); + store.dispatch(actions.setActiveCryp(null)); console.log('event clear item'); } diff --git a/client/src/keyboard.jsx b/client/src/keyboard.jsx index 647b4db0..43aa04e1 100644 --- a/client/src/keyboard.jsx +++ b/client/src/keyboard.jsx @@ -8,7 +8,9 @@ function setupKeys(store) { key('esc', () => store.dispatch(actions.setReclaiming(false))); key('esc', () => store.dispatch(actions.setActiveSkill(null))); key('esc', () => store.dispatch(actions.setActiveCryp(null))); - key('esc', () => store.dispatch(actions.setInfo([null, null]))); + key('esc', () => store.dispatch(actions.setInfo(null))); + key('esc', () => store.dispatch(actions.setItemEquip(null))); + key('esc', () => store.dispatch(actions.setItemUnequip(null))); key('esc', () => store.dispatch(actions.setVboxHighlight([]))); } diff --git a/client/src/reducers.jsx b/client/src/reducers.jsx index 10097444..7e3e0bfd 100644 --- a/client/src/reducers.jsx +++ b/client/src/reducers.jsx @@ -1,5 +1,3 @@ -const actions = require('./actions'); - function createReducer(defaultState, actionType) { return function reducer(state = defaultState, action) { switch (action.type) { @@ -13,26 +11,28 @@ function createReducer(defaultState, actionType) { /* eslint-disable key-spacing */ module.exports = { - account: createReducer(null, actions.SET_ACCOUNT), - activeCryp: createReducer(null, actions.SET_ACTIVE_CRYP), - activeSkill: createReducer(null, actions.SET_ACTIVE_SKILL), - 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), - info: createReducer([null, null], actions.SET_INFO), - instance: createReducer(null, actions.SET_INSTANCE), - instances: createReducer([], actions.SET_INSTANCES), - skip: createReducer(false, actions.SET_SKIP), - nav: createReducer(null, actions.SET_NAV), - ping: createReducer(null, actions.SET_PING), - player: createReducer(null, actions.SET_PLAYER), - reclaiming: createReducer(false, actions.SET_RECLAIMING), - resolution: createReducer(null, actions.SET_RESOLUTION), - team: createReducer([null, null, null], actions.SET_SELECTED_CRYPS), - showLog: createReducer(false, actions.SET_SHOW_LOG), - vboxHidden: createReducer(false, actions.SET_VBOX_HIDDEN), - vboxHighlight: createReducer([], actions.SET_VBOX_HIGHLIGHT), - itemInfo: createReducer({ combos: [], items: [] }, actions.SET_VBOX_INFO), - ws: createReducer(null, actions.SET_WS), + account: createReducer(null, 'SET_ACCOUNT'), + activeCryp: createReducer(null, 'SET_ACTIVE_CRYP'), + activeSkill: createReducer(null, 'SET_ACTIVE_SKILL'), + activeItem: createReducer(null, 'SET_ACTIVE_VAR'), + combiner: createReducer([null, null, null], 'SET_COMBINER'), + cryps: createReducer([], 'SET_CRYPS'), + game: createReducer(null, 'SET_GAME'), + info: createReducer(null, 'SET_INFO'), + itemEquip: createReducer(null, 'SET_ITEM_EQUIP'), + itemUnequip: createReducer(null, 'SET_ITEM_UNEQUIP'), + instance: createReducer(null, 'SET_INSTANCE'), + instances: createReducer([], 'SET_INSTANCES'), + skip: createReducer(false, 'SET_SKIP'), + nav: createReducer(null, 'SET_NAV'), + ping: createReducer(null, 'SET_PING'), + player: createReducer(null, 'SET_PLAYER'), + reclaiming: createReducer(false, 'SET_RECLAIMING'), + resolution: createReducer(null, 'SET_RESOLUTION'), + team: createReducer([null, null, null], 'SET_SELECTED_CRYPS'), + showLog: createReducer(false, 'SET_SHOW_LOG'), + vboxHidden: createReducer(false, 'SET_VBOX_HIDDEN'), + vboxHighlight: createReducer([], 'SET_VBOX_HIGHLIGHT'), + itemInfo: createReducer({ combos: [], items: [] }, 'SET_ITEM_INFO'), + ws: createReducer(null, 'SET_WS'), }; diff --git a/client/src/socket.jsx b/client/src/socket.jsx index 793b3d0f..48b1917f 100644 --- a/client/src/socket.jsx +++ b/client/src/socket.jsx @@ -177,7 +177,6 @@ function createSocket(events) { function accountInstanceList(res) { const [struct, playerList] = res; - sendItemInfo(); events.setInstanceList(playerList); } @@ -309,6 +308,7 @@ function createSocket(events) { events.setAccount(account); sendAccountInstances(); sendAccountCryps(); + sendItemInfo(); } sendPing(); diff --git a/server/src/item.rs b/server/src/item.rs index 830f5f9f..3e57e659 100644 --- a/server/src/item.rs +++ b/server/src/item.rs @@ -242,6 +242,88 @@ impl Item { _ => None, } } + + pub fn into_description(&self) -> String { + match self { + // colours + Item::Blue => format!("Combine with skills and specs to create upgraded items. \n Deterrents and destruction."), + Item::Green => format!("Combine with skills and specs to create upgraded items.\n Protection and trickery."), + Item::Red => format!("Combine with skills and specs to create upgraded items. \n Speed and chaos."), + + // base skills + Item::Attack => format!("Deal {:?}% RedDamage", self.into_skill().unwrap().multiplier()), + Item::Block => format!("description"), + Item::Stun => format!("description"), + Item::Buff => format!("description"), + Item::Debuff => format!("description"), + + // specs + // Base + Item::Damage => format!("description"), + Item::Life => format!("description"), + Item::Speed => format!("description"), + + // Lifes Upgrades + Item::GreenLifeI => format!("description"), + Item::RedLifeI => format!("description"), + Item::BlueLifeI => format!("description"), + Item::GRLI => format!("description"), + Item::GBLI => format!("description"), + Item::RBLI => format!("description"), + + // Damage Upgrades + Item::RedDamageI => format!("description"), + Item::BlueDamageI => format!("description"), + Item::GreenDamageI => format!("description"), + Item::GRDI => format!("description"), + Item::GBDI => format!("description"), + Item::RBDI => format!("description"), + + // Speed Upgrades + Item::RedSpeedI => format!("description"), + Item::BlueSpeedI => format!("description"), + Item::GreenSpeedI => format!("description"), + Item::GRSpeedI => format!("description"), + Item::GBSpeedI => format!("description"), + Item::RBSpeedI => format!("description"), + + Item::Amplify => format!("description"), + Item::Banish => format!("description"), + Item::Blast => format!("description"), + Item::Chaos => format!("description"), + Item::Clutch => format!("description"), + Item::Corrupt => format!("description"), + Item::Curse => format!("description"), + Item::Decay => format!("description"), + Item::Hostility => format!("description"), + Item::Haste => format!("description"), + Item::Heal => format!("description"), + Item::Hex => format!("description"), + Item::Impurity => format!("description"), + Item::Invert => format!("description"), + Item::Parry => format!("description"), + Item::Purge => format!("description"), + Item::Purify => format!("description"), + Item::Reflect => format!("description"), + Item::Recharge => format!("description"), + Item::Ruin => format!("description"), + Item::Scatter => format!("description"), + Item::Silence => format!("description"), + Item::Slay => format!("description"), + Item::Sleep => format!("description"), + Item::Snare => format!("description"), + Item::Strangle => format!("description"), + Item::Strike => format!("description"), + Item::StrikeII => format!("description"), + Item::StrikeIII => format!("description"), + Item::Siphon => format!("description"), + Item::Taunt => format!("description"), + Item::Throw => format!("description"), + Item::Triage => format!("description"), + + _ => format!("..."), + } + } } impl From for Item { @@ -403,9 +485,10 @@ pub fn get_combos() -> Vec { #[derive(Debug,Clone,Serialize,Deserialize)] pub struct ItemInfo { - pub v: Item, + pub item: Item, pub spec: bool, pub skill: bool, + pub description: String, } @@ -431,9 +514,10 @@ pub fn item_info() -> ItemInfoCtr { let items = items .into_iter() .map(|v| ItemInfo { - v, + item: v, spec: v.into_spec().is_some(), skill: v.into_skill().is_some(), + description: v.into_description(), }) .collect::>(); diff --git a/server/src/net.rs b/server/src/net.rs index 5aa0221f..e55915f9 100644 --- a/server/src/net.rs +++ b/server/src/net.rs @@ -76,14 +76,14 @@ fn print_panic_payload(ctx: &str, payload: &(Any + Send + 'static)) { } pub fn start() { - panic::set_hook(Box::new(|panic_info| { - print_panic_payload("set_hook", panic_info.payload()); - if let Some(location) = panic_info.location() { - info!("LOCATION: {}:{}", location.file(), location.line()); - } else { - info!("NO LOCATION INFORMATION"); - } - })); + // panic::set_hook(Box::new(|panic_info| { + // print_panic_payload("set_hook", panic_info.payload()); + // if let Some(location) = panic_info.location() { + // info!("LOCATION: {}:{}", location.file(), location.line()); + // } else { + // info!("NO LOCATION INFORMATION"); + // } + // })); let database_url = env::var("DATABASE_URL") .expect("DATABASE_URL must be set"); diff --git a/server/src/player.rs b/server/src/player.rs index 11a753fd..50addc8d 100644 --- a/server/src/player.rs +++ b/server/src/player.rs @@ -189,6 +189,10 @@ impl Player { } pub fn vbox_apply(&mut self, index: usize, cryp_id: Uuid) -> Result<&mut Player, Error> { + if self.vbox.bound.get(index).is_none() { + return Err(format_err!("no item at index {:?}", index)); + } + let item = self.vbox.bound.remove(index); match item.effect() { diff --git a/server/src/skill.rs b/server/src/skill.rs index 45756bcd..3839df43 100644 --- a/server/src/skill.rs +++ b/server/src/skill.rs @@ -499,6 +499,8 @@ impl Effect { Effect::Ruin => Category::Debuff, Effect::Curse => Category::Debuff, Effect::Banish => Category::Debuff, // todo randomise + // Effect::Banish => rng.gen_bool(0.5), + Effect::Slow => Category::Debuff, Effect::Haste => Category::Buff, Effect::Hatred => Category::Buff,