From 2cea9fd8fa96e07beda8015eb9be789c53307b83 Mon Sep 17 00:00:00 2001 From: Mashy Date: Mon, 9 Sep 2019 16:03:33 +1000 Subject: [PATCH 01/47] clear skills --- client/src/components/game.ctrl.jsx | 10 ++++++++-- client/src/components/player.box.jsx | 9 ++++++--- client/src/socket.jsx | 6 ++++++ server/src/game.rs | 25 +++++++++++++++++++++++++ server/src/rpc.rs | 6 +++++- 5 files changed, 50 insertions(+), 6 deletions(-) diff --git a/client/src/components/game.ctrl.jsx b/client/src/components/game.ctrl.jsx index 9fd5b07a..f251770a 100644 --- a/client/src/components/game.ctrl.jsx +++ b/client/src/components/game.ctrl.jsx @@ -23,8 +23,13 @@ const addState = connect( return ws.sendInstanceState(game.instance); } + function sendGameSkillClear() { + return ws.sendGameSkillClear(game.id); + } + return { game, + sendGameSkillClear, sendReady, account, getInstanceState, @@ -48,9 +53,10 @@ function Controls(args) { account, game, animating, + sendGameSkillClear, sendReady, - quit, getInstanceState, + quit, } = args; if (!game) return false; @@ -98,7 +104,7 @@ function Controls(args) {
{game.phase === 'Finish' ? quitBtn : readyBtn} - +
); diff --git a/client/src/components/player.box.jsx b/client/src/components/player.box.jsx index 4b626171..62184f3f 100644 --- a/client/src/components/player.box.jsx +++ b/client/src/components/player.box.jsx @@ -3,9 +3,9 @@ const preact = require('preact'); function Scoreboard(args) { const { isPlayer, - ready, player, - + isGame, + clear, leave, } = args; @@ -37,7 +37,10 @@ function Scoreboard(args) {
{player.name}
-
+
+ {(isPlayer && isGame) ? : null} +
+
{leave ? : null}
diff --git a/client/src/socket.jsx b/client/src/socket.jsx index d3f91ff4..a2ab9217 100644 --- a/client/src/socket.jsx +++ b/client/src/socket.jsx @@ -108,6 +108,11 @@ function createSocket(events) { events.setActiveSkill(null); } + function sendGameSkillClear(gameId) { + send(['GameSkillClear', { game_id: gameId }]); + events.setActiveSkill(null); + } + function sendGameTarget(gameId, constructId, skillId) { send(['GameTarget', { game_id: gameId, construct_id: constructId, skill_id: skillId }]); events.setActiveSkill(null); @@ -316,6 +321,7 @@ function createSocket(events) { sendGameState, sendGameReady, sendGameSkill, + sendGameSkillClear, sendGameTarget, sendInstanceReady, diff --git a/server/src/game.rs b/server/src/game.rs index 5b2191c4..6e5207dd 100644 --- a/server/src/game.rs +++ b/server/src/game.rs @@ -322,6 +322,17 @@ impl Game { return Ok(self); } + fn clear_skill(&mut self, player_id: Uuid) -> Result<&mut Game, Error> { + self.player_by_id(player_id)?; + if self.phase != Phase::Skill { + return Err(err_msg("game not in skill phase")); + } + let mut game_state = self.clone(); + self.stack.retain(|s| game_state.construct_by_id(s.source_construct_id).unwrap().account == player_id); + + return Ok(self); + } + fn player_ready(&mut self, player_id: Uuid) -> Result<&mut Game, Error> { if self.phase != Phase::Skill { return Err(err_msg("game not in skill phase")); @@ -877,6 +888,20 @@ pub fn game_skill(tx: &mut Transaction, account: &Account, game_id: Uuid, constr Ok(game) } +pub fn game_skill_clear(tx: &mut Transaction, account: &Account, game_id: Uuid) -> Result { + let mut game = game_get(tx, game_id)?; + + game.clear_skill(account.id)?; + + if game.skill_phase_finished() { + game = game.resolve_phase_start(); + } + + game_update(tx, &game)?; + + Ok(game) +} + pub fn game_ready(tx: &mut Transaction, account: &Account, id: Uuid) -> Result { let mut game = game_get(tx, id)?; diff --git a/server/src/rpc.rs b/server/src/rpc.rs index 54408bd2..d8ce6405 100644 --- a/server/src/rpc.rs +++ b/server/src/rpc.rs @@ -20,7 +20,7 @@ use account::{Account}; use account; use construct::{Construct}; use events::{Event}; -use game::{Game, game_state, game_skill, game_ready}; +use game::{Game, game_state, game_skill, game_skill_clear, game_ready}; use instance::{Instance, instance_state, instance_practice, instance_ready}; use item::{Item, ItemInfoCtr, item_info}; use mtx; @@ -75,6 +75,7 @@ enum RpcRequest { GameState { id: Uuid }, GameReady { id: Uuid }, GameSkill { game_id: Uuid, construct_id: Uuid, target_construct_id: Option, skill: Skill }, + GameSkillClear { game_id: Uuid }, AccountState {}, AccountShop {}, @@ -169,6 +170,9 @@ impl Connection { RpcRequest::GameSkill { game_id, construct_id, target_construct_id, skill } => Ok(RpcMessage::GameState(game_skill(&mut tx, account, game_id, construct_id, target_construct_id, skill)?)), + RpcRequest::GameSkillClear { game_id } => + Ok(RpcMessage::GameState(game_skill_clear(&mut tx, account, game_id)?)), + RpcRequest::GameReady { id } => Ok(RpcMessage::GameState(game_ready(&mut tx, account, id)?)), From 65c69199b9d1907e7546f022438b58d0e871da4f Mon Sep 17 00:00:00 2001 From: ntr Date: Mon, 9 Sep 2019 16:49:52 +1000 Subject: [PATCH 02/47] demo init --- WORKLOG.md | 1 - client/assets/styles/menu.less | 4 ++ client/assets/styles/styles.less | 8 --- client/src/components/demo.jsx | 91 ++++++++++++++++++++++++++++++ client/src/components/molecule.jsx | 23 +++----- client/src/components/welcome.jsx | 2 + 6 files changed, 105 insertions(+), 24 deletions(-) create mode 100644 client/src/components/demo.jsx diff --git a/WORKLOG.md b/WORKLOG.md index 066e89c0..65799897 100644 --- a/WORKLOG.md +++ b/WORKLOG.md @@ -19,7 +19,6 @@ * msg pane * game invites -* change score to enum * pct based translates for combat animation * add speed to descriptions diff --git a/client/assets/styles/menu.less b/client/assets/styles/menu.less index 49a312fa..7efd2b7a 100644 --- a/client/assets/styles/menu.less +++ b/client/assets/styles/menu.less @@ -108,4 +108,8 @@ section { display: flex; flex-flow: column; } +} + +.demo { + margin-top: 5em; } \ No newline at end of file diff --git a/client/assets/styles/styles.less b/client/assets/styles/styles.less index f64f48fa..cec86633 100644 --- a/client/assets/styles/styles.less +++ b/client/assets/styles/styles.less @@ -272,14 +272,6 @@ header { color: @white; box-shadow: inset 0px 5px 0px 0px @white; border: 0; - &:first-child { - border-left: 1px solid #444; - } - - &:last-child { - border-right: 1px solid #444; - } - } border: 1px solid #444; diff --git a/client/src/components/demo.jsx b/client/src/components/demo.jsx new file mode 100644 index 00000000..59ba8943 --- /dev/null +++ b/client/src/components/demo.jsx @@ -0,0 +1,91 @@ +const preact = require('preact'); +const shapes = require('./shapes'); +const molecule = require('./molecule'); + +function Demo(args) { + const vboxDemo = () => { + const phase = this.state.phase || 'vbox'; + const items = this.state.items || ['Red', 'Red', 'Attack']; + const combiner = this.state.combiner || []; + + console.log(combiner, this.state); + + function inventoryBtn(i, j) { + const highlighted = combiner.indexOf(j) > -1; + const classes = `${highlighted ? 'highlight' : ''}`; + + if (shapes[i]) { + return ; + } + + return ; + } + + function combinerBtn() { + let text = ''; + + if (combiner.length < 3) { + for (let i = 0; i < 3; i++) { + if (combiner.length > i) { + text += '■ '; + } else { + text += '▫ '; + } + } + } else { + text = 'combine'; + } + + return ( + + ); + } + + function inventoryElement() { + return ( +
+
+ {items.map((i, j) => inventoryBtn(i, j))} +
+ {combinerBtn()} +
+ ); + } + + // progress + setTimeout(() => { + if (items.length === 1) { + this.setState({ combiner: [], items: ['Red', 'Red', 'Attack'], phase: 'game' }); + return true; + } + + if (combiner.length === 3) { + this.setState({ combiner: [], items: ['Strike'] }); + return true; + } + + combiner.push(combiner.length); + this.setState({ combiner }); + return true; + }, 2000); + + return ( +
+ {inventoryElement()} +
+ ); + }; + + return ( +
+ {vboxDemo()} +
+
+ ); +} + +module.exports = Demo; diff --git a/client/src/components/molecule.jsx b/client/src/components/molecule.jsx index 2be0cfc3..8054a844 100644 --- a/client/src/components/molecule.jsx +++ b/client/src/components/molecule.jsx @@ -1,18 +1,11 @@ const preact = require('preact'); -module.exports = function molecule(combatText) { - const text = combatText - ? - {combatText} - - - - : ''; - - return ( - - - - {text} - ); +module.exports = function molecule() { + return ( + + + + + + ); }; diff --git a/client/src/components/welcome.jsx b/client/src/components/welcome.jsx index 27575d98..194880bb 100644 --- a/client/src/components/welcome.jsx +++ b/client/src/components/welcome.jsx @@ -5,6 +5,7 @@ const Login = require('./welcome.login'); const Register = require('./welcome.register'); const Help = require('./welcome.help'); const About = require('./welcome.about'); +const Demo = require('./demo'); function Welcome() { const page = this.state.page || 'login'; @@ -54,6 +55,7 @@ function Welcome() { {pageEl()} + ); } From 8c0b02e568b2277f1693cd002bf048cac923403c Mon Sep 17 00:00:00 2001 From: ntr Date: Mon, 9 Sep 2019 17:24:58 +1000 Subject: [PATCH 03/47] bout to fix welcome --- client/assets/styles/menu.less | 15 +++++++++++++++ client/src/components/demo.jsx | 9 +++++++++ client/src/components/welcome.jsx | 1 + 3 files changed, 25 insertions(+) diff --git a/client/assets/styles/menu.less b/client/assets/styles/menu.less index 7efd2b7a..dabdce28 100644 --- a/client/assets/styles/menu.less +++ b/client/assets/styles/menu.less @@ -112,4 +112,19 @@ section { .demo { margin-top: 5em; + + .colour-info { + display: grid; + grid-template-columns: 2fr 1fr; + + div { + display: flex; + } + } + + svg { + flex: 1; + display: inline; + } + } \ No newline at end of file diff --git a/client/src/components/demo.jsx b/client/src/components/demo.jsx index 59ba8943..9e40b4c3 100644 --- a/client/src/components/demo.jsx +++ b/client/src/components/demo.jsx @@ -48,6 +48,15 @@ function Demo(args) { function inventoryElement() { return (
+

VBOX PHASE

+
+

+ combine the colour base items with an array of skills and specialisations to build powerful variants. +

+
+ {shapes.Red()} {shapes.Green()} {shapes.Blue()} +
+
{items.map((i, j) => inventoryBtn(i, j))}
diff --git a/client/src/components/welcome.jsx b/client/src/components/welcome.jsx index 194880bb..759a6b88 100644 --- a/client/src/components/welcome.jsx +++ b/client/src/components/welcome.jsx @@ -55,6 +55,7 @@ function Welcome() {
{pageEl()} +
); From 7dbf8e2c8996beb8427947c6b50c9350f3e0530a Mon Sep 17 00:00:00 2001 From: ntr Date: Mon, 9 Sep 2019 17:47:57 +1000 Subject: [PATCH 04/47] better welcome --- client/assets/styles/menu.less | 7 ++- client/assets/styles/styles.less | 22 --------- client/src/components/welcome.jsx | 77 +++++++++++++++++-------------- 3 files changed, 48 insertions(+), 58 deletions(-) diff --git a/client/assets/styles/menu.less b/client/assets/styles/menu.less index dabdce28..1d76995f 100644 --- a/client/assets/styles/menu.less +++ b/client/assets/styles/menu.less @@ -77,6 +77,12 @@ } } } + + .login { + display: flex; + flex-flow: column; + margin-bottom: 2em; + } } section { @@ -126,5 +132,4 @@ section { flex: 1; display: inline; } - } \ No newline at end of file diff --git a/client/assets/styles/styles.less b/client/assets/styles/styles.less index cec86633..d6e292e7 100644 --- a/client/assets/styles/styles.less +++ b/client/assets/styles/styles.less @@ -195,28 +195,6 @@ button[disabled] { border-color: #222; } -/* - LOGIN -*/ - -.welcome { - .login { - width: 50%; - display: flex; - flex-flow: column; - margin-bottom: 2em; - } - - .options { - display: flex; - width: 50%; - } - - h2 { - margin-bottom: 0.5em; - } -} - #mnml input, #mnml select { border-color: #222; background-color: #222; diff --git a/client/src/components/welcome.jsx b/client/src/components/welcome.jsx index 759a6b88..df0df4ff 100644 --- a/client/src/components/welcome.jsx +++ b/client/src/components/welcome.jsx @@ -20,42 +20,49 @@ function Welcome() { }; return ( -
-

mnml.gg

-