Merge branch 'return-of-react' of ssh://cryps.gg:40022/~/cryps into return-of-react

This commit is contained in:
ntr 2019-03-29 15:36:43 +11:00
commit c42cc73707
11 changed files with 50 additions and 56 deletions

2
html-client/src/components/body.component.jsx Executable file → Normal file
View File

@ -39,7 +39,7 @@ function renderBody(props) {
type="submit"
onClick={() => setGame(null)}
>
Return to Main Menu
Back to instance
</button>
</div>
);

0
html-client/src/components/cryp.list.jsx Executable file → Normal file
View File

View File

@ -8,9 +8,9 @@ const addState = connect(
function receiveState(state) {
const { ws, game, account, activeSkill, activeIncoming } = state;
function selectSkillTarget(targetTeamId) {
function selectSkillTarget(targetCrypId) {
if (activeSkill) {
return ws.sendGameSkill(game.id, activeSkill.crypId, targetTeamId, activeSkill.skill.skill);
return ws.sendGameSkill(game.id, activeSkill.crypId, targetCrypId, activeSkill.skill.skill);
}
return false;
}

85
html-client/src/components/game.jsx Executable file → Normal file
View File

@ -69,7 +69,6 @@ function GamePanel(props) {
<div className="columns" >
<div className="column is-10">
<p className="title">{cryp.name}</p>
<p className="subtitle">Level {cryp.lvl}</p>
</div>
<div className="column">
<figure className="image">
@ -78,11 +77,9 @@ function GamePanel(props) {
</div>
</div>
<div className="has-text-centered">{cryp.hp.value} / {cryp.stam.value} HP </div>
<progress className="progress is-dark" value={cryp.hp.value} max={cryp.stam.value}></progress>
<div className="has-text-centered">{cryp.hp.value} / {cryp.hp.max} HP </div>
<progress className="progress is-dark" value={cryp.hp.value} max={cryp.hp.max}></progress>
<div className="has-text-centered">{cryp.xp} / {Math.pow(2, cryp.lvl + 1)} XP </div>
<progress className="progress is-dark" value={cryp.xp} max={Math.pow(2, cryp.lvl + 1)}></progress>
</div>
{effects}
{skills}
@ -106,28 +103,28 @@ function GamePanel(props) {
));
return (
<div key={cryp.id} className="tile is-vertical">
<div className="tile is-child">
<div className="columns" >
<div className="column is-10">
<p className="title">{cryp.name}</p>
<p className="subtitle">Level {cryp.lvl}</p>
</div>
<div className="column">
<figure className="image">
<svg width="40" height="40" data-jdenticon-value={cryp.name} />
</figure>
<div className="tile"
style={activeSkill ? { cursor: 'pointer' } : {}}
onClick={() => selectSkillTarget(cryp.id)} >
<div key={cryp.id} className="tile is-vertical">
<div className="tile is-child">
<div className="columns" >
<div className="column is-10">
<p className="title">{cryp.name}</p>
</div>
<div className="column">
<figure className="image">
<svg width="40" height="40" data-jdenticon-value={cryp.name} />
</figure>
</div>
</div>
<div className="has-text-centered">{cryp.hp.value} / {cryp.hp.value} HP </div>
<progress className="progress is-dark" value={cryp.hp.value} max={cryp.hp.max}></progress>
</div>
<div className="has-text-centered">{cryp.hp.value} / {cryp.stam.value} HP </div>
<progress className="progress is-dark" value={cryp.hp.value} max={cryp.stam.value}></progress>
<div className="has-text-centered">{cryp.xp} / {Math.pow(2, cryp.lvl + 1)} XP </div>
<progress className="progress is-dark" value={cryp.xp} max={Math.pow(2, cryp.lvl + 1)}></progress>
{effects}
</div>
{effects}
</div>
);
}
@ -135,46 +132,30 @@ function GamePanel(props) {
function OpponentTeam(team) {
const cryps = team.cryps.map(OpponentCrypCard);
return (
<div
className="tile"
style={activeSkill ? { cursor: 'pointer' } : {}}
onClick={() => selectSkillTarget(team.id)} >
<div>
{cryps}
</div>
);
}
// style={{ "min-height": "100%" }}
function phaseText(phase) {
switch (phase) {
case 'Skill':
return 'Choose abilities';
case 'Target':
return 'Block abilities';
case 'Finish':
return 'Game over';
}
}
const logs = game.log.reverse().map((l, i) => (<div key={i}>{l}</div>));
return (
<section className="columns">
<div className="column is-2 title is-1">
{phaseText(game.phase)}
</div>
<div className="column is-4">
{PlayerTeam(playerTeam, setActiveSkill)}
</div>
<div className="column is-4">
<div>
<section>
<div className="row">
<div className="three columns">
{playerTeam.id}
{PlayerTeam(playerTeam, setActiveSkill)}
</div>
<div className="six columns" align="center">
Round X
</div>
<div className="three columns">
{otherTeams.id}
{otherTeams.map(OpponentTeam)}
</div>
<div>
{incoming}
</div>
</div>
<div className="column is-2">
<div className="row">
<div className="title is-4">{logs}</div>
</div>
</section>

0
html-client/src/components/login.component.jsx Executable file → Normal file
View File

0
html-client/src/components/login.container.jsx Executable file → Normal file
View File

View File

@ -16,7 +16,8 @@ function registerEvents(store) {
}
function setGame(game) {
return console.log('EVENT ->', 'game', game);
store.dispatch(actions.setGame(game));
// return console.log('EVENT ->', 'game', game);
}
function setAccount(account) {

0
html-client/src/keyboard.jsx Executable file → Normal file
View File

1
html-client/src/main.jsx Executable file → Normal file
View File

@ -17,6 +17,7 @@ const Body = require('./components/body.component');
const store = createStore(
combineReducers({
account: reducers.accountReducer,
activeSkill: reducers.activeSkillReducer,
combiner: reducers.combinerReducer,
game: reducers.gameReducer,
cryps: reducers.crypsReducer,

View File

@ -10,6 +10,16 @@ function accountReducer(state = defaultAccount, action) {
}
}
const defaultActiveSkill = null;
function activeSkillReducer(state = defaultActiveSkill, action) {
switch (action.type) {
case actions.SET_ACTIVE_SKILL:
return action.value;
default:
return state;
}
}
const defaultCryps = null;
function crypsReducer(state = defaultCryps, action) {
switch (action.type) {
@ -72,6 +82,7 @@ function wsReducer(state = defaultWs, action) {
module.exports = {
accountReducer,
activeSkillReducer,
combinerReducer,
crypsReducer,
gameReducer,

0
html-client/src/socket.jsx Executable file → Normal file
View File