more mobile

This commit is contained in:
ntr 2019-04-05 13:49:10 +11:00
parent f3e2ed06a9
commit 312e3f109a
7 changed files with 146 additions and 66 deletions

View File

@ -529,6 +529,10 @@ header {
flex: 1; flex: 1;
} }
.mobile-skills {
display: none;
}
@media (max-width: 1000px) { @media (max-width: 1000px) {
.selected-skills { .selected-skills {
display: none; display: none;
@ -542,6 +546,23 @@ header {
justify-content: space-between; justify-content: space-between;
} }
main.game {
flex-flow: column-reverse;
}
main.game .instance-hdr {
order: 99;
}
.header-username {
display: none;
}
.menu-instance-list {
order: -1;
width: 100%;
}
.cryps { .cryps {
font-size: 0.75em; font-size: 0.75em;
padding: 0 1em; padding: 0 1em;
@ -584,11 +605,33 @@ header {
display: none; display: none;
} }
.selected-skills { .selected-skills {
display: block; display: block;
} }
.mobile-skills {
display: flex;
flex-flow: row;
width: 100%;
}
.cryp-skill-btn {
flex: 1;
font-size: 16pt;
border-width: 1px;
padding: 0;
margin: 0;
border-bottom-width: 0px;
border-left-width: 0px;
border-top-width: 1px;
border-right-width: 1px;
}
.cryp-skill-btn:first-child {
border-top-width: 1px;
}
.cryp-box .stats figure { .cryp-box .stats figure {
padding: 0.2em 0; padding: 0.2em 0;
} }

View File

@ -22,12 +22,12 @@ export const setCombiner = value => ({ type: SET_COMBINER, value: Array.from(val
export const SET_SELECTED_CRYPS = 'SET_SELECTED_CRYPS'; export const SET_SELECTED_CRYPS = 'SET_SELECTED_CRYPS';
export const setSelectedCryps = value => ({ type: SET_SELECTED_CRYPS, value: Array.from(value) }); export const setSelectedCryps = value => ({ type: SET_SELECTED_CRYPS, value: Array.from(value) });
export const SET_ACTIVE_INCOMING = 'SET_ACTIVE_INCOMING';
export const setActiveIncoming = value => ({ type: SET_ACTIVE_INCOMING, value });
export const SET_ACTIVE_SKILL = 'SET_ACTIVE_SKILL'; export const SET_ACTIVE_SKILL = 'SET_ACTIVE_SKILL';
export const setActiveSkill = (crypId, skill) => ({ type: SET_ACTIVE_SKILL, value: crypId ? { crypId, skill } : null }); 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_INFO = 'SET_INFO'; export const SET_INFO = 'SET_INFO';
export const setInfo = value => ({ type: SET_INFO, value }); export const setInfo = value => ({ type: SET_INFO, value });

View File

@ -12,7 +12,9 @@ function GamePanel(props) {
game, game,
activeSkill, activeSkill,
setActiveSkill, setActiveSkill,
setActiveCryp,
selectSkillTarget, selectSkillTarget,
activeCryp,
account, account,
showLog, showLog,
toggleLog, toggleLog,
@ -42,7 +44,7 @@ function GamePanel(props) {
if (showLog) { if (showLog) {
const logs = game.log.map((l, i) => (<div key={i}>{l}</div>)).reverse(); const logs = game.log.map((l, i) => (<div key={i}>{l}</div>)).reverse();
return ( return (
<main> <main className="game">
{header} {header}
<div className="logs"> <div className="logs">
{logs} {logs}
@ -80,41 +82,45 @@ function GamePanel(props) {
); );
} }
function Skill(cryp, i) {
const ko = cryp.hp.value === 0 ? 'ko' : '';
const s = cryp.skills[i];
if (!s) {
return (
<button
disabled='true'
key={i}
className='cryp-skill-btn disabled'>
<span>&nbsp;</span>
</button>
);
}
const cdText = cryp.skills[i].cd > 0
? `- ${s.cd}`
: '';
const highlight = activeSkill
? activeSkill.crypId === cryp.id && activeSkill.skill === s
: false;
return (
<button
key={i}
disabled={!!cdText || ko}
className={`cryp-skill-btn right ${highlight ? 'active' : ''}`}
type="submit"
onClick={() => setActiveSkill(cryp.id, s.skill)}>
{s.skill} {cdText}
</button>
);
}
function Cryp(cryp) { function Cryp(cryp) {
const ko = cryp.hp.value === 0 ? 'ko' : ''; const ko = cryp.hp.value === 0 ? 'ko' : '';
const skills = range(0, 4).map(i => { const skills = range(0, 4).map(i => Skill(cryp, i));
const s = cryp.skills[i];
if (!s) {
return (
<button
disabled='true'
key={i}
className='cryp-skill-btn disabled'>
<span>&nbsp;</span>
</button>
);
}
const cdText = cryp.skills[i].cd > 0
? `- ${s.cd}`
: '';
const highlight = activeSkill
? activeSkill.crypId === cryp.id && activeSkill.skill === s
: false;
return (
<button
key={i}
disabled={!!cdText || ko}
className={`cryp-skill-btn right ${highlight ? 'active' : ''}`}
type="submit"
onClick={() => setActiveSkill(cryp.id, s.skill)}>
{s.skill} {cdText}
</button>
);
});
const stats = [STATS.hp, STATS.redShield, STATS.blueShield].map((s, j) => ( const stats = [STATS.hp, STATS.redShield, STATS.blueShield].map((s, j) => (
<figure key={j} alt={s.stat}> <figure key={j} alt={s.stat}>
@ -124,10 +130,16 @@ function GamePanel(props) {
)); ));
function onClick(e) {
e.stopPropagation();
return setActiveCryp(cryp);
}
return ( return (
<div <div
key={cryp.id} key={cryp.id}
style={ activeSkill ? { cursor: 'pointer' } : {}} style={ activeSkill ? { cursor: 'pointer' } : {}}
onClick={onClick}
className={`cryp-box ${ko}`} > className={`cryp-box ${ko}`} >
<div className="cryp-box-top"> <div className="cryp-box-top">
<figure <figure
@ -196,11 +208,17 @@ function GamePanel(props) {
const selectedSkills = playerTeam.cryps.map((c, i) => stackElement(c, i)); const selectedSkills = playerTeam.cryps.map((c, i) => stackElement(c, i));
const mobileSkills = activeCryp
? range(0, 4).map(i => Skill(activeCryp, i))
: (<div/>);
return ( return (
<main> <main className="game" onClick={() => setActiveCryp(null)} >
{header} {header}
{PlayerTeam(playerTeam, setActiveSkill)} {PlayerTeam(playerTeam, setActiveSkill)}
<div className="mobile-skills">
{mobileSkills}
</div>
<div className="selected-skills"> <div className="selected-skills">
{selectedSkills} {selectedSkills}
</div> </div>

View File

@ -1,17 +1,24 @@
import 'particles.js/particles'; // import 'particles.js/particles';
const { connect } = require('preact-redux'); const { connect } = require('preact-redux');
const actions = require('../actions'); const actions = require('../actions');
const Game = require('./game.component'); const Game = require('./game.component');
const config = require('./particles.config'); // const config = require('./particles.config');
const particlesJS = window.particlesJS; // const particlesJS = window.particlesJS;
const addState = connect( const addState = connect(
function receiveState(state) { function receiveState(state) {
const { ws, game, account, showLog, activeSkill, activeIncoming } = state; const {
ws,
game,
account,
showLog,
activeSkill,
activeCryp,
} = state;
function selectSkillTarget(targetCrypId) { function selectSkillTarget(targetCrypId) {
if (activeSkill) { if (activeSkill) {
@ -25,14 +32,14 @@ const addState = connect(
ws.sendGameSkill(game.id, activeSkill.crypId, null, activeSkill.skill.skill); ws.sendGameSkill(game.id, activeSkill.crypId, null, activeSkill.skill.skill);
} }
function selectIncomingTarget(crypId) { return {
if (activeIncoming) { game,
return ws.sendGameTarget(game.id, crypId, activeIncoming); showLog,
} account,
return false; activeSkill,
} activeCryp,
selectSkillTarget,
return { game, showLog, account, activeSkill, activeIncoming, selectSkillTarget, selectIncomingTarget }; };
}, },
function receiveDispatch(dispatch) { function receiveDispatch(dispatch) {
@ -41,8 +48,8 @@ const addState = connect(
// particlesJS(`particles-${crypId}`, config); // particlesJS(`particles-${crypId}`, config);
} }
function setActiveIncoming(skillId) { function setActiveCryp(cryp) {
dispatch(actions.setActiveIncoming(skillId)); dispatch(actions.setActiveCryp(cryp));
} }
function quit() { function quit() {
@ -54,7 +61,7 @@ const addState = connect(
} }
return { setActiveSkill, setActiveIncoming, quit, toggleLog }; return { setActiveSkill, setActiveCryp, quit, toggleLog };
} }
); );

View File

@ -35,19 +35,19 @@ function Vbox(args) {
free.push([vbox.free[0][i], vbox.free[1][i], vbox.free[2][i]]); free.push([vbox.free[0][i], vbox.free[1][i], vbox.free[2][i]]);
} }
let freeDbl = false; let freeDbl = -1;
function freeClick(e, i, j) { function freeClick(e, i, j) {
// touch + double handling // touch + double handling
if (!freeDbl) { if (freeDbl !== j) {
freeDbl = true; freeDbl = j;
setTimeout(() => { setTimeout(() => {
freeDbl = false; freeDbl = -1;
if (free[i][j]) setInfo('item', free[i][j]); if (free[i][j]) setInfo('item', free[i][j]);
}, 300); }, 300);
return false; return false;
} }
e.preventDefault(); e.preventDefault();
freeDbl = false; freeDbl = -1;
return sendVboxAccept(j, i); return sendVboxAccept(j, i);
} }
@ -73,16 +73,16 @@ function Vbox(args) {
// INVENTORY // INVENTORY
// //
// lots of rubbish to make it flow nice // lots of rubbish to make it flow nice
let boundDbl = false; let boundDbl = -1;
function boundClick(e, i) { function boundClick(e, i) {
// touch + double handling // touch + double handling
if (!boundDbl) { if (boundDbl !== i) {
boundDbl = true; boundDbl = i;
setTimeout(() => boundDbl = false, 300); setTimeout(() => boundDbl = -1, 300);
return false; return false;
} }
e.preventDefault(); e.preventDefault();
boundDbl = false; boundDbl = -1;
// action // action
if (reclaiming && i) { if (reclaiming && i) {
@ -158,7 +158,7 @@ function Vbox(args) {
return ( return (
<div className="vbox" onClick={() => setReclaiming(false)} > <div className="vbox" onClick={() => setReclaiming(false)} >
<div className="vbox-hdr"> <div className="vbox-hdr">
<div>VBOX</div> <div onTouchStart={e => e.target.scrollIntoView(true)}>VBOX</div>
<div className="bits" >{vbox.bits}b</div> <div className="bits" >{vbox.bits}b</div>
</div> </div>
<button <button
@ -182,7 +182,7 @@ function Vbox(args) {
{boundRows} {boundRows}
</tbody> </tbody>
</table> </table>
<span>I-COMBINATOR</span> <span onTouchStart={e => e.target.scrollIntoView(true)}>I-COMBINATOR</span>
<button <button
className="instance-btn instance-ui-btn vbox-btn" className="instance-btn instance-ui-btn vbox-btn"
onClick={() => sendVboxCombine()}> onClick={() => sendVboxCombine()}>

View File

@ -18,6 +18,7 @@ const store = createStore(
combineReducers({ combineReducers({
account: reducers.accountReducer, account: reducers.accountReducer,
activeSkill: reducers.activeSkillReducer, activeSkill: reducers.activeSkillReducer,
activeCryp: reducers.activeCrypReducer,
combiner: reducers.combinerReducer, combiner: reducers.combinerReducer,
cryps: reducers.crypsReducer, cryps: reducers.crypsReducer,
game: reducers.gameReducer, game: reducers.gameReducer,

View File

@ -20,6 +20,16 @@ function activeSkillReducer(state = defaultActiveSkill, action) {
} }
} }
const defaultActiveCryp = null;
function activeCrypReducer(state = defaultActiveCryp, action) {
switch (action.type) {
case actions.SET_ACTIVE_CRYP:
return action.value;
default:
return state;
}
}
const defaultCryps = null; const defaultCryps = null;
function crypsReducer(state = defaultCryps, action) { function crypsReducer(state = defaultCryps, action) {
switch (action.type) { switch (action.type) {
@ -123,6 +133,7 @@ function infoReducer(state = defaultInfo, action) {
module.exports = { module.exports = {
accountReducer, accountReducer,
activeSkillReducer, activeSkillReducer,
activeCrypReducer,
combinerReducer, combinerReducer,
crypsReducer, crypsReducer,
gameReducer, gameReducer,