coloured targeting

This commit is contained in:
ntr 2019-06-03 15:46:14 +10:00
parent a81b4ccc2b
commit 6ece2c03cd
6 changed files with 58 additions and 23 deletions

View File

@ -33,9 +33,7 @@
## NOW ## NOW
*CLIENT* *CLIENT*
targeting arrows back?
reconnect based on time delta reconnect based on time delta
dont' nav to list on connect
menu footer menu footer

View File

@ -74,13 +74,11 @@
} }
.game-construct .targeting { .game-construct .targeting {
grid-area: target; grid-area: avatar;
display: flex; position: relative;
flex-flow: column; left: 60%;
justify-content: center; top: 50%;
align-items: flex-start; text-align: center;
width: 100%;
white-space: nowrap;
} }
.game-construct .img { .game-construct .img {

View File

@ -81,8 +81,8 @@ function GamePanel(props) {
); );
function PlayerTeam(team) { function PlayerTeam(team) {
const constructs = team.constructs.map(c => const constructs = team.constructs.map((c, i) =>
<GameConstruct key={c.id} construct={c} player={true} />); <GameConstruct key={c.id} i={i} construct={c} player={true} />);
return ( return (
<div className="team player"> <div className="team player">
{constructs} {constructs}
@ -91,8 +91,8 @@ function GamePanel(props) {
} }
function OpponentTeam(team) { function OpponentTeam(team) {
const constructs = team.constructs.map(c => const constructs = team.constructs.map((c, i) =>
<GameConstruct key={c.id} construct={c} player={false} />); <GameConstruct key={c.id} i={i} construct={c} player={false} />);
return ( return (
<div className="team opponent"> <div className="team opponent">
{constructs} {constructs}

View File

@ -3,12 +3,18 @@ const preact = require('preact');
const range = require('lodash/range'); const range = require('lodash/range');
const actions = require('../actions'); const actions = require('../actions');
const { STATS, eventClasses, getCombatText, ConstructAvatar } = require('../utils'); const { TARGET_COLOURS: COLOURS, STATS, eventClasses, getCombatText, ConstructAvatar } = require('../utils');
const { animationDivs } = require('../animations'); const { animationDivs } = require('../animations');
const shapes = require('./shapes'); const shapes = require('./shapes');
const SkillBtn = require('./skill.btn'); const SkillBtn = require('./skill.btn');
const TARGET_COLOURS = [
COLOURS.PINK,
COLOURS.LBLUE,
COLOURS.GREEN,
];
const addState = connect( const addState = connect(
function receiveState(state) { function receiveState(state) {
const { const {
@ -43,6 +49,7 @@ const addState = connect(
function GameConstruct(props) { function GameConstruct(props) {
const { const {
i,
game, game,
account, account,
construct, construct,
@ -53,6 +60,7 @@ function GameConstruct(props) {
selectSkillTarget, selectSkillTarget,
} = props; } = props;
const ko = construct.green_life.value === 0 ? 'ko' : ''; const ko = construct.green_life.value === 0 ? 'ko' : '';
const classes = eventClasses(resolution, construct); const classes = eventClasses(resolution, construct);
@ -66,7 +74,7 @@ function GameConstruct(props) {
const skills = range(0, 3) const skills = range(0, 3)
.map(i => <SkillBtn key={i} construct={construct} i={i} />); .map(j => <SkillBtn key={j} construct={construct} i={j} j={i} />);
let crypSkills = <div> &nbsp; </div>; let crypSkills = <div> &nbsp; </div>;
if (player) crypSkills = (<div className="skills"> {skills} </div>); if (player) crypSkills = (<div className="skills"> {skills} </div>);
@ -86,7 +94,10 @@ function GameConstruct(props) {
const targeting = game.stack const targeting = game.stack
.filter(s => playerTeamIds.includes(s.source_construct_id) && s.target_construct_id === construct.id) .filter(s => playerTeamIds.includes(s.source_construct_id) && s.target_construct_id === construct.id)
.map((s, i) => <h3 key={i}>{`< ${s.skill}`}</h3>); .map((s, i) => {
const highlightColour = TARGET_COLOURS[playerTeamIds.indexOf(s.source_construct_id)];
return <h3 key={i} style={{ color: highlightColour}} >{`< ${s.skill}`}</h3>
});
const anim = ( const anim = (
<div className="anim-container"> <div className="anim-container">
@ -103,6 +114,7 @@ function GameConstruct(props) {
<div className="stats"> {stats} </div> <div className="stats"> {stats} </div>
<ConstructAvatar name={construct.name} id={construct.id} /> <ConstructAvatar name={construct.name} id={construct.id} />
<div className="effects"> {effects} </div> <div className="effects"> {effects} </div>
<div className="targeting"> {targeting} </div>
</div> </div>
); );
} }

View File

@ -3,6 +3,15 @@ const { connect } = require('preact-redux');
const actions = require('../actions'); const actions = require('../actions');
const { TARGET_COLOURS } = require('./../utils');
const TC_MAP = [
TARGET_COLOURS.PINK,
TARGET_COLOURS.LBLUE,
TARGET_COLOURS.GREEN,
];
const addState = connect( const addState = connect(
function receiveState(state) { function receiveState(state) {
const { const {
@ -31,6 +40,7 @@ function Skill(props) {
construct, construct,
game, game,
i, i,
j,
mobile, mobile,
activeSkill, activeSkill,
setActiveSkill, setActiveSkill,
@ -44,14 +54,16 @@ function Skill(props) {
<button <button
disabled='true' disabled='true'
className='construct-skill-btn disabled'> className='construct-skill-btn disabled'>
&nbsp;
</button> </button>
); );
} }
const side = mobile const skillChosen = game.stack.some(stack => stack.source_construct_id === construct.id);
? 'top' const targeting = game.stack.some(stack => stack.source_construct_id === construct.id && stack.skill === s.skill);
: '';
if (skillChosen && !targeting) {
return false;
}
const cdText = construct.skills[i].cd > 0 const cdText = construct.skills[i].cd > 0
? `- ${s.cd}T` ? `- ${s.cd}T`
@ -61,18 +73,19 @@ function Skill(props) {
? activeSkill.constructId === construct.id && activeSkill.skill === s.skill ? activeSkill.constructId === construct.id && activeSkill.skill === s.skill
: false; : false;
const highlightColour = TC_MAP[j];
function onClick(e) { function onClick(e) {
e.stopPropagation(); e.stopPropagation();
return setActiveSkill(construct.id, s.skill); return setActiveSkill(construct.id, s.skill);
} }
const targeting = game.stack.some(stack => stack.source_construct_id === construct.id && stack.skill === s.skill);
return ( return (
<button <button
disabled={cdText || s.disabled || ko} disabled={cdText || s.disabled || ko}
className={`construct-skill-btn ${side} ${(targeting || highlight) ? 'active' : ''}`} className={`construct-skill-btn ${(targeting || highlight) ? 'active' : ''}`}
type="submit" type="submit"
style={ targeting ? { color: highlightColour } : false}
onClick={onClick}> onClick={onClick}>
{s.skill} {cdText} {s.skill} {cdText}
</button> </button>

View File

@ -408,6 +408,19 @@ const COLOURS = [
'#3498db', '#3498db',
]; ];
const TARGET_COLOURS = {
BLUE: '#004bfe',
CYAN: '#27e7c0',
PURPLE: '#61008c',
YELLOW: '#fdfe02',
ORANGE: '#ff9215',
PINK: '#e766b6',
GRAY: '#9d9ea0',
LBLUE: '#87c6f2',
GREEN: '#166c4f',
BROWN: '#583108',
};
module.exports = { module.exports = {
animateConstruct, animateConstruct,
stringSort, stringSort,
@ -423,4 +436,5 @@ module.exports = {
NULL_UUID, NULL_UUID,
STATS, STATS,
COLOURS, COLOURS,
TARGET_COLOURS,
}; };