game styles

This commit is contained in:
ntr 2019-03-31 14:01:51 +11:00
parent e466b65819
commit b9175ecc53
5 changed files with 38 additions and 111 deletions

View File

@ -209,35 +209,40 @@ button:hover {
this controls the size of the box this controls the size of the box
as it fills the whole container as it fills the whole container
*/ */
padding: 0 1em 2em 0; margin: 0 1em 1em 0;
border: 1px solid whitesmoke;
} }
/*cheeky one to push them in line with the buttons */ /*cheeky one to push them in line with the buttons */
.cryp-box:first-child { .instance .cryp-box:first-child {
margin-top: -2.5em; margin-top: -2.5em;
} }
.cryp-box figure { .cryp-box figure {
margin: 0; margin: 0;
flex: 1 1 50%; flex: 0 1 50%;
border: 1px solid whitesmoke;
text-align: center; text-align: center;
box-sizing: border-box; box-sizing: border-box;
display: flex; display: flex;
flex-flow: column; flex-flow: column;
} }
.cryp-box figure figcaption { .cryp-box .stats {
display: flex;
width: 100%;
border-top: 1px solid whitesmoke;
} }
.cryp-box .stats figure { .cryp-box .stats figure {
flex: 1 1 0;
border: 0; border: 0;
align-items: center align-items: center;
padding: 0.25em 0;
} }
.cryp-box .stats { .cryp-box .stats svg {
border-top-width: 0; height: 1.5em;
border: 1px solid whitesmoke; stroke-width: 2px;
} }
.cryp-box .skills { .cryp-box .skills {
@ -251,26 +256,11 @@ button:hover {
height: 25%; height: 25%;
padding: 0; padding: 0;
margin: 0; margin: 0;
border-left-width: 0px;
border-bottom-width: 0px; border-bottom-width: 0px;
border-left-width: 1px;
} }
.cryp-skill-btn:last-child { .cryp-skill-btn:first-child {
border-bottom-width: 1px;
}
.cryp-box .stats {
display: flex;
width: 100%;
text-align: center;
}
.cryp-box .stats figure {
border-top-width: 0; border-top-width: 0;
flex: 1 1 0;
} }
.cryp-box .stats svg {
height: 1em;
stroke-width: 2px;
}

View File

@ -1,6 +1,6 @@
const { connect } = require('preact-redux'); const { connect } = require('preact-redux');
const CrypList = require('./cryp.list'); const CrypList = require('./cryp.list.component');
const actions = require('./../actions'); const actions = require('./../actions');
const addState = connect( const addState = connect(

View File

@ -1,57 +0,0 @@
const preact = require('preact');
const { stringSort } = require('./../utils');
const molecule = require('./molecule');
const idSort = stringSort('id');
const COLOURS = [
'#a52a2a',
'#1FF01F',
'#3498db',
];
function CrypList({ cryps, selectedCryps, setSelectedCryps }) {
if (!cryps) return <div>not ready</div>;
// redux limitation + suggested workaround
// so much for dumb components
function selectCryp(id) {
if (selectedCryps.length < 3) {
selectedCryps.push(id);
return setSelectedCryps(selectedCryps);
}
return false;
}
const crypPanels = cryps.sort(idSort).map(cryp => {
const colour = selectedCryps.indexOf(cryp.id);
const selected = colour > -1;
const borderColour = selected ? COLOURS[colour] : '#000000';
return (
<div
key={cryp.id}
className="menu-cryp-ctr">
<div
className="menu-cryp"
style={ { 'border-color': borderColour || 'whitesmoke' } }
onClick={() => selectCryp(cryp.id)} >
<figure className="img">
{molecule}
</figure>
<h2>{cryp.name}</h2>
</div>
</div>
);
});
return (
<div className="menu-cryps">
{crypPanels}
</div>
);
}
module.exports = CrypList;

View File

@ -48,6 +48,7 @@ function GamePanel(props) {
<div className="cryp-box"> <div className="cryp-box">
<figure className="img"> <figure className="img">
{molecule} {molecule}
<figcaption>{cryp.name}</figcaption>
</figure> </figure>
<div className="skills"> <div className="skills">
{skills} {skills}
@ -80,39 +81,34 @@ function GamePanel(props) {
); );
} }
function OpponentCrypCard(cryp) { function OpponentCryp(cryp, i) {
const effects = cryp.effects.map((effect, i) => ( const stats = [
<div key={i}>{effect.effect} for {effect.turns}T</div> { stat: 'hp', colour: '#1FF01F' },
{ stat: 'red_shield', colour: '#a52a2a' },
{ stat: 'blue_shield', colour: '#3498db' },
].map((s, j) => (
<figure key={j} alt={s.stat}>
{saw(s.colour)}
<figcaption>{cryp[s.stat].value} / {cryp[s.stat].max}</figcaption>
</figure>
)); ));
return ( return (
<div <div key={i} className="cryp-box">
style={activeSkill ? { cursor: 'pointer' } : {}} <figure className="img">
onClick={() => selectSkillTarget(cryp.id)} > {molecule}
<div key={cryp.id}> <figcaption>{cryp.name}</figcaption>
<div> </figure>
<div > <div className="stats">
<div> {stats}
<p>{cryp.name}</p>
</div>
<div>
<figure>
<svg width="40" height="40" data-jdenticon-value={cryp.name} />
</figure>
</div>
</div>
<div>{cryp.hp.value} / {cryp.hp.value} HP </div>
<progress value={cryp.hp.value} max={cryp.hp.max}></progress>
</div>
{effects}
</div> </div>
</div> </div>
); );
} }
function OpponentTeam(team) { function OpponentTeam(team) {
const cryps = team.cryps.map(OpponentCrypCard); const cryps = team.cryps.map(OpponentCryp);
return ( return (
<div> <div>
{cryps} {cryps}
@ -138,11 +134,9 @@ function GamePanel(props) {
</div> </div>
<div className="row"> <div className="row">
<div className="four columns"> <div className="four columns">
{playerTeam.id}
{PlayerTeam(playerTeam, setActiveSkill)} {PlayerTeam(playerTeam, setActiveSkill)}
</div> </div>
<div className="four columns"> <div className="four columns">
{otherTeams.id}
{otherTeams.map(OpponentTeam)} {otherTeams.map(OpponentTeam)}
</div> </div>
<div className="four columns"> <div className="four columns">

View File

@ -59,7 +59,7 @@ function InstanceComponent(args) {
const cryps = instance.cryps.map(Cryp); const cryps = instance.cryps.map(Cryp);
return ( return (
<section> <section className="instance" >
<div className="row"> <div className="row">
<div className="three columns"> <div className="three columns">
<button <button