From b45778955fd1e47287dd675cacf41d4d29c8dff6 Mon Sep 17 00:00:00 2001 From: Mashy Date: Mon, 13 Jan 2020 11:35:52 +1000 Subject: [PATCH 01/38] disable stash during tutorial first stage, misc text improvements --- client/src/components/vbox.stash.jsx | 10 +++++++--- client/src/tutorial.utils.jsx | 24 ++++++++++-------------- 2 files changed, 17 insertions(+), 17 deletions(-) diff --git a/client/src/components/vbox.stash.jsx b/client/src/components/vbox.stash.jsx index cec94686..0e737627 100644 --- a/client/src/components/vbox.stash.jsx +++ b/client/src/components/vbox.stash.jsx @@ -9,7 +9,7 @@ const buttons = require('./buttons'); const { removeTier } = require('../utils'); const addState = connect( - ({ itemUnequip, vboxHighlight, vboxSelected }) => ({ itemUnequip, vboxHighlight, vboxSelected })); + ({ itemUnequip, vboxHighlight, vboxSelected, tutorial }) => ({ itemUnequip, vboxHighlight, vboxSelected, tutorial })); class stashElement extends preact.Component { shouldComponentUpdate(newProps) { @@ -23,6 +23,7 @@ class stashElement extends preact.Component { if (newProps.itemUnequip !== this.props.itemUnequip) return true; if (newProps.vboxHighlight !== this.props.vboxHighlight) return true; if (newProps.vboxSelected !== this.props.vboxSelected) return true; + if (newProps.tutorial !== this.props.tutorial) return true; return false; } @@ -39,6 +40,7 @@ class stashElement extends preact.Component { itemUnequip, vboxHighlight, vboxSelected, + tutorial, } = props; const { storeSelect, stashSelect } = vboxSelected; @@ -95,7 +97,7 @@ class stashElement extends preact.Component { : `${border} ${notValidCombo ? 'fade' : ''}`; const invObject = shapes[v] ? shapes[v]() : v; - + const tutorialDisable = tutorial === 1; return ( diff --git a/client/src/tutorial.utils.jsx b/client/src/tutorial.utils.jsx index 90c0ded5..e8bc0578 100644 --- a/client/src/tutorial.utils.jsx +++ b/client/src/tutorial.utils.jsx @@ -116,9 +116,7 @@ function tutorialStage(tutorial, clearTutorial, instance) { return (

Welcome to MNML

-

This is the VBOX Phase tutorial.

-

In the VBOX Phase you customise your constructs' skills and specialisations.

-

Colours are used to create powerful combinations with base items.

+

This is the VBOX Phase where you customise your team.

Buy the two colours from the store to continue.

); @@ -128,8 +126,9 @@ function tutorialStage(tutorial, clearTutorial, instance) { return (

Combining Items

-

You start the game with the base Attack skill item.

-

Highlight the Attack and the two colours then click combine

+

You start the game with the Attack base skill item.

+

Create powerful combinations by combining colours with base items.

+

Select all three items to combine.

); } @@ -141,8 +140,7 @@ function tutorialStage(tutorial, clearTutorial, instance) {

Equipping Items

The first construct on your team is {constructOne}.

Skill items can be equipped to your constructs to be used in the combat phase.

-

Click your new skill from the stash.
- Once selected click the flashing SKILL slot or the construct img to equip the skill.

+

Select your new skill from the stash and then click the flashing SKILL slot or the construct image to equip.

); } @@ -162,11 +160,10 @@ function tutorialStage(tutorial, clearTutorial, instance) { return (

Specialisations

-

Equipping specialisation items will increase the stats of your constructs.

-

These can also be combined with colours for further specialisation.

-

Click the specialisation item in the stash.
- Once selected click the flashing SPEC slot to equip the specialisation.

-

PRO TIP: while selecting an item in the shop, click on your construct to buy and equip in one step.

+

Specialisation items increase the stats of your constructs.
+ They can be combined further with colours to optimise your team strategy.

+

Slect the item in the stash, once selected click the flashing SPEC slot to equip.

+

PRO TIP: While selecting an item in the shop, click on your construct to buy and equip in one step.

); } @@ -178,8 +175,7 @@ function tutorialStage(tutorial, clearTutorial, instance) {

Skills

You have now created a construct with an upgraded skill and base spec.

-

The goal is to create three powerful constructs for combat.

-

Equip your other constructs {constructTwo} and {constructThree} with the Attack skill.
+

Equip your other constructs {constructTwo} and {constructThree} with skills.
Ensure each construct has a single skill to continue.

PRO TIP: Select a skill or spec on a construct and click another construct to swap it.

From 71b7f0b2b4758b22385072cfbd61ab3bdf85c2c1 Mon Sep 17 00:00:00 2001 From: ntr Date: Mon, 13 Jan 2020 16:15:06 +1000 Subject: [PATCH 02/38] remove ko from wiggle event list --- client/src/components/anims/amplify.jsx | 2 +- client/src/components/construct.jsx | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/client/src/components/anims/amplify.jsx b/client/src/components/anims/amplify.jsx index 9dc087a0..6e77cc2c 100644 --- a/client/src/components/anims/amplify.jsx +++ b/client/src/components/anims/amplify.jsx @@ -22,7 +22,7 @@ class Amplify extends Component { xmlns="http://www.w3.org/2000/svg" viewBox="0 0 200 200"> - + diff --git a/client/src/components/construct.jsx b/client/src/components/construct.jsx index ec3d7813..0c979107 100644 --- a/client/src/components/construct.jsx +++ b/client/src/components/construct.jsx @@ -69,7 +69,11 @@ class ConstructAvatar extends Component { const type = resolution.event[0]; // only trigger the wiggle on damage and ko events rather than spam it on everything // also stops wiggle triggering when invert effect is applied - if (['Damage', 'Ko'].includes(type)) return wiggle(construct.id, this.idle); + const wiggleEvents = [ + 'Damage', + // 'Ko' + ]; + if (wiggleEvents.includes(type)) return wiggle(construct.id, this.idle); } // different source object and source construct From 3fc2e7583694c4f2de1320ee483bd6d91e19dffc Mon Sep 17 00:00:00 2001 From: Mashy Date: Mon, 13 Jan 2020 16:31:06 +1000 Subject: [PATCH 03/38] cd increase / decrease event --- client/src/components/game.construct.anim.text.jsx | 2 ++ 1 file changed, 2 insertions(+) diff --git a/client/src/components/game.construct.anim.text.jsx b/client/src/components/game.construct.anim.text.jsx index 8b982cd2..670827d3 100644 --- a/client/src/components/game.construct.anim.text.jsx +++ b/client/src/components/game.construct.anim.text.jsx @@ -63,6 +63,8 @@ class AnimText extends preact.Component { } case 'Ko': return

KO!

; case 'Reflection': return

REFLECT

; + case 'CooldownIncrease': return

+{event.turns}T cooldowns

; + case 'CooldownDecrease': return

-{event.turns}T cooldowns

; default: return false; } }; From de5724de97708b2ebb0e4b63f81de6ae38e76bd6 Mon Sep 17 00:00:00 2001 From: Mashy Date: Mon, 13 Jan 2020 16:45:58 +1000 Subject: [PATCH 04/38] cooldown increase single event --- core/src/construct.rs | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/core/src/construct.rs b/core/src/construct.rs index 2c45b7be..16b13c63 100644 --- a/core/src/construct.rs +++ b/core/src/construct.rs @@ -470,24 +470,26 @@ impl Construct { } pub fn increase_cooldowns(&mut self, turns: usize) -> Vec { - let mut events = vec![]; - + let mut cd_event = false; for skill in self.skills.iter_mut() { if skill.skill.base_cd().is_some() { // if has a cooldown + cd_event = true; match skill.cd { Some(cd) => { skill.cd = Some(cd.saturating_add(turns)); - events.push(Event::CooldownIncrease { construct: self.id, turns }) }, None => { skill.cd = Some(turns); - events.push(Event::CooldownIncrease { construct: self.id, turns }) }, } } } - return events; + if cd_event { + return vec![Event::CooldownIncrease { construct: self.id, turns }]; + } + + return vec![]; } pub fn reduce_cooldowns(&mut self) -> &mut Construct { From 5940be499e22f27ce979692d0fe4976933a8b8c3 Mon Sep 17 00:00:00 2001 From: ntr Date: Mon, 13 Jan 2020 16:58:40 +1000 Subject: [PATCH 05/38] animate all turns that have happened since last game state --- client/src/events.jsx | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/client/src/events.jsx b/client/src/events.jsx index 48028205..e5d3a92b 100644 --- a/client/src/events.jsx +++ b/client/src/events.jsx @@ -77,21 +77,24 @@ function registerEvents(store) { if (game && currentGame) { if (game.resolutions.length !== currentGame.resolutions.length) { + // stop fetching the game state til animations are done store.dispatch(actions.setAnimating(true)); store.dispatch(actions.setGameSkillInfo(null)); - // stop fetching the game state til animations are done - const newRes = game.resolutions[game.resolutions.length - 1]; - return eachSeries(newRes, (r, cb) => { - if (r.delay === 0) return cb(); // TargetKo etc - setAnimations(r, store); - return setTimeout(cb, r.delay); + + const newTurns = game.resolutions.slice(currentGame.resolutions.length); + return eachSeries(newTurns, (turn, turnCb) => { + return eachSeries(turn, (r, cb) => { + if (r.delay === 0) return cb(); // TargetKo etc + setAnimations(r, store); + return setTimeout(cb, r.delay); + }, turnCb); }, err => { if (err) return console.error(err); clearAnimations(store); // set the game state so resolutions don't fire twice store.dispatch(actions.setGame(game)); ws.sendGameState(game.id); - return true; + return false; }); } } From bc0d00fd2be909a7ba50ee81b51115ed04f8e642 Mon Sep 17 00:00:00 2001 From: ntr Date: Tue, 14 Jan 2020 09:26:52 +1000 Subject: [PATCH 06/38] don't start tutorial after registration --- server/src/account.rs | 21 --------------------- server/src/user_authenticated.rs | 4 ---- 2 files changed, 25 deletions(-) diff --git a/server/src/account.rs b/server/src/account.rs index f180cf70..110f1ce5 100644 --- a/server/src/account.rs +++ b/server/src/account.rs @@ -530,24 +530,3 @@ pub fn img_check(account: &Account) -> Result { } } -pub fn tutorial(tx: &mut Transaction, account: &Account) -> Result, Error> { - let query = " - SELECT count(id) - FROM players - WHERE account = $1; - "; - - let result = tx - .query(query, &[&account.id])?; - - let row = result.iter().next() - .ok_or(format_err!("unable to fetch joined games account={:?}", account))?; - - let count: i64 = row.get(0); - - if count == 0 { - return Ok(Some(instance_practice(tx, account)?)); - } - - return Ok(None); -} \ No newline at end of file diff --git a/server/src/user_authenticated.rs b/server/src/user_authenticated.rs index ce7581a6..6949fe0c 100644 --- a/server/src/user_authenticated.rs +++ b/server/src/user_authenticated.rs @@ -128,10 +128,6 @@ impl User for Authenticated { let wheel = account::chat_wheel(&db, a.id)?; self.ws.send(RpcMessage::ChatWheel(wheel))?; - if let Some(instance) = account::tutorial(&mut tx, &a)? { - self.ws.send(RpcMessage::InstanceState(instance))?; - } - // tx should do nothing tx.commit()?; From 92c0921254416f296e5000e1ea9db03e6de4965f Mon Sep 17 00:00:00 2001 From: ntr Date: Tue, 14 Jan 2020 09:27:23 +1000 Subject: [PATCH 07/38] v1.12.2 --- VERSION | 2 +- acp/package.json | 2 +- client/package.json | 2 +- core/Cargo.toml | 2 +- ops/package.json | 2 +- server/Cargo.toml | 2 +- studios/package.json | 2 +- 7 files changed, 7 insertions(+), 7 deletions(-) diff --git a/VERSION b/VERSION index 6f165bc1..69669de6 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -1.12.1 \ No newline at end of file +1.12.2 \ No newline at end of file diff --git a/acp/package.json b/acp/package.json index c375cc2f..cb7abeda 100644 --- a/acp/package.json +++ b/acp/package.json @@ -1,6 +1,6 @@ { "name": "mnml-client", - "version": "1.12.1", + "version": "1.12.2", "description": "", "main": "index.js", "scripts": { diff --git a/client/package.json b/client/package.json index b6ace460..977344f7 100644 --- a/client/package.json +++ b/client/package.json @@ -1,6 +1,6 @@ { "name": "mnml-client", - "version": "1.12.1", + "version": "1.12.2", "description": "", "main": "index.js", "scripts": { diff --git a/core/Cargo.toml b/core/Cargo.toml index febac315..4f9ed720 100644 --- a/core/Cargo.toml +++ b/core/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "mnml_core" -version = "1.12.1" +version = "1.12.2" authors = ["ntr ", "mashy "] [dependencies] diff --git a/ops/package.json b/ops/package.json index 01e81dc9..d1d30272 100644 --- a/ops/package.json +++ b/ops/package.json @@ -1,6 +1,6 @@ { "name": "mnml-ops", - "version": "1.12.1", + "version": "1.12.2", "description": "", "main": "index.js", "scripts": { diff --git a/server/Cargo.toml b/server/Cargo.toml index a89622ea..76a849df 100644 --- a/server/Cargo.toml +++ b/server/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "mnml" -version = "1.12.1" +version = "1.12.2" authors = ["ntr "] [dependencies] diff --git a/studios/package.json b/studios/package.json index 08c5353e..93382d32 100644 --- a/studios/package.json +++ b/studios/package.json @@ -1,6 +1,6 @@ { "name": "mnml-studios", - "version": "1.12.1", + "version": "1.12.2", "description": "", "main": "index.js", "scripts": { From e7e8e39acbb52e9be7178bde7f8dd1a0b535499c Mon Sep 17 00:00:00 2001 From: ntr Date: Tue, 14 Jan 2020 09:27:53 +1000 Subject: [PATCH 08/38] auto commit version number --- bin/version.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/bin/version.sh b/bin/version.sh index 673f5e76..d659bd40 100755 --- a/bin/version.sh +++ b/bin/version.sh @@ -15,3 +15,5 @@ cd $MNML_PATH/ops && npm --allow-same-version --no-git-tag-version version "$VER cd $MNML_PATH/client && npm --allow-same-version --no-git-tag-version version "$VERSION" cd $MNML_PATH/acp && npm --allow-same-version --no-git-tag-version version "$VERSION" cd $MNML_PATH/studios && npm --allow-same-version --no-git-tag-version version "$VERSION" + +git commit -am "v$VERSION" \ No newline at end of file From c42d895e598887f3f4b62f261722546d3bec7df7 Mon Sep 17 00:00:00 2001 From: ntr Date: Tue, 14 Jan 2020 10:09:19 +1000 Subject: [PATCH 09/38] fix disconnect bug" --- server/src/account.rs | 2 +- server/src/rpc.rs | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/server/src/account.rs b/server/src/account.rs index 110f1ce5..83a7d7e4 100644 --- a/server/src/account.rs +++ b/server/src/account.rs @@ -18,7 +18,7 @@ use mnml_core::player::{Player}; use http::MnmlHttpError; use names::{name as generate_name}; use mtx::{Mtx, FREE_MTX}; -use pg::{Db, instance_delete, construct_spawn, instance_practice}; +use pg::{Db, instance_delete, construct_spawn}; use img; static PASSWORD_MIN_LEN: usize = 3; diff --git a/server/src/rpc.rs b/server/src/rpc.rs index 2eca2452..216d8702 100644 --- a/server/src/rpc.rs +++ b/server/src/rpc.rs @@ -198,7 +198,10 @@ impl Handler for Connection { if cookie.name() == TOKEN_HEADER { let db = self.pool.get().unwrap(); match account::from_token(&db, &cookie.value().to_string()) { - Ok(a) => self.user = Box::new(Authenticated::new(a, self.ws.clone(), self.events.clone(), self.pool.clone())), + Ok(a) => { + self.id = a.id; + self.user = Box::new(Authenticated::new(a, self.ws.clone(), self.events.clone(), self.pool.clone())); + }, Err(_) => return unauth(), } } From 2a2102ceaac78497b129d6f7e10c6fc0864a92b1 Mon Sep 17 00:00:00 2001 From: ntr Date: Tue, 14 Jan 2020 10:21:46 +1000 Subject: [PATCH 10/38] reload on register to make sure they get properly redirected into menu" --- client/src/components/welcome.register.jsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/src/components/welcome.register.jsx b/client/src/components/welcome.register.jsx index 68b6fedb..4ea4d3f6 100644 --- a/client/src/components/welcome.register.jsx +++ b/client/src/components/welcome.register.jsx @@ -18,7 +18,7 @@ const addState = connect( .then(data => { if (data.error) return errorToast(data.error); infoToast(data.message); - ws.connect(); + window.location.reload(); }) .catch(error => errorToast(error)); } From 469a757646c123b10150b9b8306570e2118efdc4 Mon Sep 17 00:00:00 2001 From: ntr Date: Tue, 14 Jan 2020 17:42:04 +1000 Subject: [PATCH 11/38] samesite none so people can login from iframe --- server/src/http.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/src/http.rs b/server/src/http.rs index 34b3b994..cb245e7f 100644 --- a/server/src/http.rs +++ b/server/src/http.rs @@ -354,7 +354,7 @@ fn recover(req: &mut Request) -> IronResult { let v = Cookie::build(TOKEN_HEADER, token) .http_only(true) - .same_site(SameSite::Strict) + .same_site(SameSite::None) .path("/") .max_age(Duration::weeks(1)) // 1 week aligns with db set .finish(); From a1e3f446cdb064ebe19bfee82f3bbbdfac02f04c Mon Sep 17 00:00:00 2001 From: ntr Date: Tue, 14 Jan 2020 17:48:56 +1000 Subject: [PATCH 12/38] revert cause it didn't work --- server/src/http.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/src/http.rs b/server/src/http.rs index cb245e7f..34b3b994 100644 --- a/server/src/http.rs +++ b/server/src/http.rs @@ -354,7 +354,7 @@ fn recover(req: &mut Request) -> IronResult { let v = Cookie::build(TOKEN_HEADER, token) .http_only(true) - .same_site(SameSite::None) + .same_site(SameSite::Strict) .path("/") .max_age(Duration::weeks(1)) // 1 week aligns with db set .finish(); From c43f3f8e0e7bf538ed631447fe667e4e8cb2ace2 Mon Sep 17 00:00:00 2001 From: ntr Date: Wed, 15 Jan 2020 08:26:21 +1000 Subject: [PATCH 13/38] no samesite? --- server/src/http.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/src/http.rs b/server/src/http.rs index 34b3b994..cc61496f 100644 --- a/server/src/http.rs +++ b/server/src/http.rs @@ -354,7 +354,7 @@ fn recover(req: &mut Request) -> IronResult { let v = Cookie::build(TOKEN_HEADER, token) .http_only(true) - .same_site(SameSite::Strict) + // .same_site(SameSite::Strict) .path("/") .max_age(Duration::weeks(1)) // 1 week aligns with db set .finish(); From deb327e79122be58aaf3e15a31125b469017b897 Mon Sep 17 00:00:00 2001 From: ntr Date: Wed, 15 Jan 2020 08:27:43 +1000 Subject: [PATCH 14/38] samesite::none --- server/src/http.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/server/src/http.rs b/server/src/http.rs index cc61496f..bb0d443d 100644 --- a/server/src/http.rs +++ b/server/src/http.rs @@ -25,7 +25,7 @@ use payments::{stripe}; pub const TOKEN_HEADER: &str = "x-auth-token"; pub const AUTH_CLEAR: &str = - "x-auth-token=; HttpOnly; SameSite=Strict; Path=/; Max-Age=-1;"; + "x-auth-token=; HttpOnly; SameSite=None; Path=/; Max-Age=-1;"; #[derive(Clone, Copy, Fail, Debug, Serialize, Deserialize)] pub enum MnmlHttpError { @@ -191,7 +191,7 @@ impl AfterMiddleware for ErrorHandler { fn token_res(token: String) -> Response { let v = Cookie::build(TOKEN_HEADER, token) .http_only(true) - .same_site(SameSite::Strict) + .same_site(SameSite::None) .path("/") .max_age(Duration::weeks(1)) // 1 week aligns with db set .finish(); @@ -354,7 +354,7 @@ fn recover(req: &mut Request) -> IronResult { let v = Cookie::build(TOKEN_HEADER, token) .http_only(true) - // .same_site(SameSite::Strict) + .same_site(SameSite::None) .path("/") .max_age(Duration::weeks(1)) // 1 week aligns with db set .finish(); From e69e5b36e54997bc947d6714882d92fa582cb3d3 Mon Sep 17 00:00:00 2001 From: ntr Date: Wed, 15 Jan 2020 08:43:17 +1000 Subject: [PATCH 15/38] disabled skill btns on finished --- client/src/components/game.construct.skill.btn.jsx | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/client/src/components/game.construct.skill.btn.jsx b/client/src/components/game.construct.skill.btn.jsx index cedf7c33..553bdcc1 100644 --- a/client/src/components/game.construct.skill.btn.jsx +++ b/client/src/components/game.construct.skill.btn.jsx @@ -82,9 +82,11 @@ function Skill(props) { const border = buttons[removeTier(s.skill)] ? buttons[removeTier(s.skill)]() : ''; + const finished = game.phase === 'Finished'; + return ( -
Invite a Friend
+
Play against friend
); From 8e728b77e00e3d06f0dea3705d9587f13e148f96 Mon Sep 17 00:00:00 2001 From: Mashy Date: Fri, 17 Jan 2020 12:55:55 +1000 Subject: [PATCH 26/38] registered accounts tutorial with localstorage, disable instance ready until finish tutorial --- client/src/components/instance.ctrl.btns.jsx | 8 +++++--- client/src/events.jsx | 2 -- client/src/reducers.jsx | 2 +- client/src/tutorial.utils.jsx | 3 ++- 4 files changed, 8 insertions(+), 7 deletions(-) diff --git a/client/src/components/instance.ctrl.btns.jsx b/client/src/components/instance.ctrl.btns.jsx index 45c26e1f..136987c2 100644 --- a/client/src/components/instance.ctrl.btns.jsx +++ b/client/src/components/instance.ctrl.btns.jsx @@ -10,6 +10,7 @@ const addState = connect( chatShow, instance, account, + tutorial, } = state; function sendReady() { @@ -21,6 +22,7 @@ const addState = connect( instance, chatShow, account, + tutorial, sendReady, }; @@ -42,17 +44,17 @@ function InstanceCtrlBtns(args) { instance, chatShow, account, - + tutorial, sendReady, setChatShow, } = args; const finished = instance && instance.phase === 'Finished'; - + const tutorialDisable = tutorial && tutorial < 8; return (
- +
); } diff --git a/client/src/events.jsx b/client/src/events.jsx index e5d3a92b..3d5ddd83 100644 --- a/client/src/events.jsx +++ b/client/src/events.jsx @@ -116,7 +116,6 @@ function registerEvents(store) { } store.dispatch(actions.setAccount(account)); - store.dispatch(actions.setTutorial(null)); store.dispatch(actions.setAuthenticated(true)); } @@ -189,7 +188,6 @@ function registerEvents(store) { } } - return store.dispatch(actions.setInstance(v)); } diff --git a/client/src/reducers.jsx b/client/src/reducers.jsx index 6330f0eb..3c5faf4a 100644 --- a/client/src/reducers.jsx +++ b/client/src/reducers.jsx @@ -53,7 +53,7 @@ module.exports = { teamPage: createReducer(0, 'SET_TEAM_PAGE'), teamSelect: createReducer([null, null, null], 'SET_TEAM_SELECT'), - tutorial: createReducer(1, 'SET_TUTORIAL'), + tutorial: createReducer(localStorage.getItem('tutorial-complete') ? null : 1, 'SET_TUTORIAL'), vboxSelected: createReducer({ storeSelect: [], stashSelect: [] }, 'SET_VBOX_SELECTED'), vboxCombiner: createReducer(null, 'SET_VBOX_COMBINER'), diff --git a/client/src/tutorial.utils.jsx b/client/src/tutorial.utils.jsx index b4f79f0b..d7f296a2 100644 --- a/client/src/tutorial.utils.jsx +++ b/client/src/tutorial.utils.jsx @@ -197,10 +197,10 @@ function tutorialStage(tutorial, clearTutorial, instance) { } if (tutorial === 8) { + localStorage.setItem('tutorial-complete', true); if (window.innerWidth < 1000) { return exit(); } - return (

GLHF

@@ -210,6 +210,7 @@ function tutorialStage(tutorial, clearTutorial, instance) {
); } + return false; }; From 56159aaf89ea6c9364eb599b5e36f4b6d4ee83f6 Mon Sep 17 00:00:00 2001 From: ntr Date: Fri, 17 Jan 2020 15:58:18 +1000 Subject: [PATCH 27/38] auth loggin --- server/src/user_authenticated.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/src/user_authenticated.rs b/server/src/user_authenticated.rs index 23a45f34..27dd4638 100644 --- a/server/src/user_authenticated.rs +++ b/server/src/user_authenticated.rs @@ -135,7 +135,7 @@ impl User for Authenticated { } fn disconnected(&self) -> Result<(), Error> { - info!("user disconnected name={:?}", self.account.name); + info!("user disconnected account={:?}", self.account); Ok(()) } From 5bac39d86caffb34a1408f779a88bba042aac5b9 Mon Sep 17 00:00:00 2001 From: ntr Date: Fri, 17 Jan 2020 16:31:25 +1000 Subject: [PATCH 28/38] Revert "don't start tutorial after registration" This reverts commit bc0d00fd2be909a7ba50ee81b51115ed04f8e642. --- server/src/account.rs | 21 +++++++++++++++++++++ server/src/user_authenticated.rs | 4 ++++ 2 files changed, 25 insertions(+) diff --git a/server/src/account.rs b/server/src/account.rs index 83a7d7e4..60d05de4 100644 --- a/server/src/account.rs +++ b/server/src/account.rs @@ -530,3 +530,24 @@ pub fn img_check(account: &Account) -> Result { } } +pub fn tutorial(tx: &mut Transaction, account: &Account) -> Result, Error> { + let query = " + SELECT count(id) + FROM players + WHERE account = $1; + "; + + let result = tx + .query(query, &[&account.id])?; + + let row = result.iter().next() + .ok_or(format_err!("unable to fetch joined games account={:?}", account))?; + + let count: i64 = row.get(0); + + if count == 0 { + return Ok(Some(instance_practice(tx, account)?)); + } + + return Ok(None); +} \ No newline at end of file diff --git a/server/src/user_authenticated.rs b/server/src/user_authenticated.rs index 27dd4638..a127368b 100644 --- a/server/src/user_authenticated.rs +++ b/server/src/user_authenticated.rs @@ -128,6 +128,10 @@ impl User for Authenticated { let wheel = account::chat_wheel(&db, a.id)?; self.ws.send(RpcMessage::ChatWheel(wheel))?; + if let Some(instance) = account::tutorial(&mut tx, &a)? { + self.ws.send(RpcMessage::InstanceState(instance))?; + } + // tx should do nothing tx.commit()?; From 8f6c8c304ae60983b48b401b0d08ce33a2ff485f Mon Sep 17 00:00:00 2001 From: ntr Date: Fri, 17 Jan 2020 16:36:16 +1000 Subject: [PATCH 29/38] put tutorial first login kick back in --- server/src/account.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/src/account.rs b/server/src/account.rs index 60d05de4..f180cf70 100644 --- a/server/src/account.rs +++ b/server/src/account.rs @@ -18,7 +18,7 @@ use mnml_core::player::{Player}; use http::MnmlHttpError; use names::{name as generate_name}; use mtx::{Mtx, FREE_MTX}; -use pg::{Db, instance_delete, construct_spawn}; +use pg::{Db, instance_delete, construct_spawn, instance_practice}; use img; static PASSWORD_MIN_LEN: usize = 3; From b6267cf2a0fc062daf16c281f9d3df210fbee569 Mon Sep 17 00:00:00 2001 From: ntr Date: Fri, 17 Jan 2020 16:41:22 +1000 Subject: [PATCH 30/38] do client check for tutorial instead of server side --- client/src/events.jsx | 4 ++++ server/src/account.rs | 2 +- server/src/user_authenticated.rs | 6 +++--- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/client/src/events.jsx b/client/src/events.jsx index 3d5ddd83..83c9982d 100644 --- a/client/src/events.jsx +++ b/client/src/events.jsx @@ -107,6 +107,7 @@ function registerEvents(store) { } function setAuthenticated(account) { + if (account && window.Notification) { window.Notification.requestPermission(); } @@ -115,6 +116,9 @@ function registerEvents(store) { LogRocket.identify(account.id, account); } + const { tutorial, ws } = store.getState(); + if (tutorial) ws.sendInstancePractice(); + store.dispatch(actions.setAccount(account)); store.dispatch(actions.setAuthenticated(true)); } diff --git a/server/src/account.rs b/server/src/account.rs index f180cf70..14812bcc 100644 --- a/server/src/account.rs +++ b/server/src/account.rs @@ -530,7 +530,7 @@ pub fn img_check(account: &Account) -> Result { } } -pub fn tutorial(tx: &mut Transaction, account: &Account) -> Result, Error> { +pub fn _tutorial(tx: &mut Transaction, account: &Account) -> Result, Error> { let query = " SELECT count(id) FROM players diff --git a/server/src/user_authenticated.rs b/server/src/user_authenticated.rs index a127368b..eb617178 100644 --- a/server/src/user_authenticated.rs +++ b/server/src/user_authenticated.rs @@ -128,9 +128,9 @@ impl User for Authenticated { let wheel = account::chat_wheel(&db, a.id)?; self.ws.send(RpcMessage::ChatWheel(wheel))?; - if let Some(instance) = account::tutorial(&mut tx, &a)? { - self.ws.send(RpcMessage::InstanceState(instance))?; - } + // if let Some(instance) = account::tutorial(&mut tx, &a)? { + // self.ws.send(RpcMessage::InstanceState(instance))?; + // } // tx should do nothing tx.commit()?; From 8bf6f714fd25d55fb0bf4a86fe733a2e006420f9 Mon Sep 17 00:00:00 2001 From: ntr Date: Fri, 17 Jan 2020 17:03:13 +1000 Subject: [PATCH 31/38] big fucking green buttons --- client/assets/styles/menu.less | 22 +++++----------------- client/assets/styles/styles.less | 13 +++++++++++++ 2 files changed, 18 insertions(+), 17 deletions(-) diff --git a/client/assets/styles/menu.less b/client/assets/styles/menu.less index ff035799..510ede43 100644 --- a/client/assets/styles/menu.less +++ b/client/assets/styles/menu.less @@ -112,9 +112,10 @@ section { figure { letter-spacing: 0.25em; text-transform: uppercase; - font-size: 125%; + font-size: 1.5em; display: flex; flex-flow: column; + height: 5em; } letter-spacing: 0.25em; @@ -138,27 +139,14 @@ section { grid-template-columns: 1fr; } - button.ready:enabled { - color: forestgreen; - border-color: forestgreen; - - &:hover { - background: forestgreen; - color: black; - border-color: forestgreen; - } - } - - // // all green // button.ready:enabled { - // background: forestgreen; - // color: black; + // color: forestgreen; // border-color: forestgreen; // &:hover { - // color: forestgreen; + // background: forestgreen; + // color: black; // border-color: forestgreen; - // background: 0; // } // } } diff --git a/client/assets/styles/styles.less b/client/assets/styles/styles.less index fb8b1072..92ecfa1c 100644 --- a/client/assets/styles/styles.less +++ b/client/assets/styles/styles.less @@ -173,6 +173,19 @@ button, input { // &:active { // filter: url("#noiseFilter"); // } + + // all green + &.ready:enabled { + background: forestgreen; + color: black; + border-color: forestgreen; + + &:hover { + color: forestgreen; + border-color: forestgreen; + background: 0; + } + } } a { From 6a7c2ab0d3c86438cd991f95e8a6455b5c9c5e83 Mon Sep 17 00:00:00 2001 From: ntr Date: Fri, 17 Jan 2020 17:11:36 +1000 Subject: [PATCH 32/38] remove instance practice send --- client/src/events.jsx | 4 ---- 1 file changed, 4 deletions(-) diff --git a/client/src/events.jsx b/client/src/events.jsx index 83c9982d..3d5ddd83 100644 --- a/client/src/events.jsx +++ b/client/src/events.jsx @@ -107,7 +107,6 @@ function registerEvents(store) { } function setAuthenticated(account) { - if (account && window.Notification) { window.Notification.requestPermission(); } @@ -116,9 +115,6 @@ function registerEvents(store) { LogRocket.identify(account.id, account); } - const { tutorial, ws } = store.getState(); - if (tutorial) ws.sendInstancePractice(); - store.dispatch(actions.setAccount(account)); store.dispatch(actions.setAuthenticated(true)); } From b66b053bf0b3a9591fcd4c79761926045d382d23 Mon Sep 17 00:00:00 2001 From: ntr Date: Fri, 17 Jan 2020 17:17:33 +1000 Subject: [PATCH 33/38] biggify buttons --- client/assets/styles/menu.less | 1 - client/src/components/play.jsx | 16 +++++++++------- client/src/components/reshape.jsx | 20 ++++++++++---------- 3 files changed, 19 insertions(+), 18 deletions(-) diff --git a/client/assets/styles/menu.less b/client/assets/styles/menu.less index 510ede43..c9890991 100644 --- a/client/assets/styles/menu.less +++ b/client/assets/styles/menu.less @@ -115,7 +115,6 @@ section { font-size: 1.5em; display: flex; flex-flow: column; - height: 5em; } letter-spacing: 0.25em; diff --git a/client/src/components/play.jsx b/client/src/components/play.jsx index 044d529a..1450a2df 100644 --- a/client/src/components/play.jsx +++ b/client/src/components/play.jsx @@ -221,13 +221,15 @@ function Play(args) {

¤ {account.balance}

- {subscription} - +
{subscription}
+
+ +
Join our Discord server to find opponents and talk to the devs.
diff --git a/client/src/components/reshape.jsx b/client/src/components/reshape.jsx index 835f4a8e..810db6da 100644 --- a/client/src/components/reshape.jsx +++ b/client/src/components/reshape.jsx @@ -106,19 +106,19 @@ function Reshape(args) {

¤ {account.balance}

- {subscription} - -
-
-
+
{subscription}
+
+ +
{shop.owned.map(useMtx)} {shop.available.map(availableMtx)}
+
); From d11b7dcdb304b383a877f8f737de78cdacfa17de Mon Sep 17 00:00:00 2001 From: Mashy Date: Fri, 17 Jan 2020 17:20:22 +1000 Subject: [PATCH 34/38] tutorial client fixes --- client/src/components/vbox.info.jsx | 7 ++++--- client/src/events.jsx | 2 +- client/src/reducers.jsx | 2 +- client/src/tutorial.utils.jsx | 10 ++++++++-- 4 files changed, 14 insertions(+), 7 deletions(-) diff --git a/client/src/components/vbox.info.jsx b/client/src/components/vbox.info.jsx index d2eddbec..126780be 100644 --- a/client/src/components/vbox.info.jsx +++ b/client/src/components/vbox.info.jsx @@ -5,8 +5,8 @@ const { tutorialStage } = require('../tutorial.utils'); const { genItemInfo } = require('./vbox.utils'); const addState = connect( - ({ info, player, tutorial, vboxInfo, itemInfo, instance, comboPreview }) => ({ - info, player, tutorial, vboxInfo, itemInfo, instance, comboPreview, + ({ info, player, tutorial, vboxInfo, itemInfo, instance, comboPreview, authenticated }) => ({ + info, player, tutorial, vboxInfo, itemInfo, instance, comboPreview, authenticated })); @@ -35,12 +35,13 @@ class Info extends preact.Component { itemInfo, instance, comboPreview, + authenticated, } = props; // dispaly priority // tutorial -> comboPreview -> vboxInfo -> info if (tutorial) { - const tutorialStageInfo = tutorialStage(tutorial, clearTutorial, instance); + const tutorialStageInfo = tutorialStage(authenticated, tutorial, clearTutorial, instance); if (tutorialStageInfo) return tutorialStageInfo; } if (comboPreview) return genItemInfo(comboPreview, itemInfo, player); diff --git a/client/src/events.jsx b/client/src/events.jsx index 83c9982d..1354a363 100644 --- a/client/src/events.jsx +++ b/client/src/events.jsx @@ -185,7 +185,7 @@ function registerEvents(store) { const player = v.players.find(p => p.id === account.id); store.dispatch(actions.setPlayer(player)); - if (tutorial) tutorialVbox(player, store, tutorial); + if (tutorial && process.env.NODE_ENV !== 'development') tutorialVbox(player, store, tutorial); if (v.phase === 'Finished') { ws.sendAccountInstances(); diff --git a/client/src/reducers.jsx b/client/src/reducers.jsx index 3c5faf4a..6330f0eb 100644 --- a/client/src/reducers.jsx +++ b/client/src/reducers.jsx @@ -53,7 +53,7 @@ module.exports = { teamPage: createReducer(0, 'SET_TEAM_PAGE'), teamSelect: createReducer([null, null, null], 'SET_TEAM_SELECT'), - tutorial: createReducer(localStorage.getItem('tutorial-complete') ? null : 1, 'SET_TUTORIAL'), + tutorial: createReducer(1, 'SET_TUTORIAL'), vboxSelected: createReducer({ storeSelect: [], stashSelect: [] }, 'SET_VBOX_SELECTED'), vboxCombiner: createReducer(null, 'SET_VBOX_COMBINER'), diff --git a/client/src/tutorial.utils.jsx b/client/src/tutorial.utils.jsx index 2aebae73..216ea0d2 100644 --- a/client/src/tutorial.utils.jsx +++ b/client/src/tutorial.utils.jsx @@ -106,7 +106,7 @@ function tutorialVbox(player, store, tutorial) { store.dispatch(actions.setTutorial(stage)); } -function tutorialStage(tutorial, clearTutorial, instance) { +function tutorialStage(authenticated, tutorial, clearTutorial, instance) { if (!(instance.time_control === 'Practice' && instance.rounds.length === 1)) return false; const exit = () => clearTutorial(); @@ -197,7 +197,6 @@ function tutorialStage(tutorial, clearTutorial, instance) { } if (tutorial === 8) { - localStorage.setItem('tutorial-complete', true); if (window.innerWidth < 1000) { return exit(); } @@ -221,11 +220,18 @@ function tutorialStage(tutorial, clearTutorial, instance) { onMouseDown={exit}> Continue : null; + const skipTutorial = authenticated && !exitTutorial ? + + : null; + return (
{tutorialText()}
{exitTutorial} + {skipTutorial}
); } From 58edf3d5eed9c5507087d96f61f604f96ff31022 Mon Sep 17 00:00:00 2001 From: Mashy Date: Fri, 17 Jan 2020 17:27:42 +1000 Subject: [PATCH 35/38] remove dev mode tutorial skip --- client/src/events.jsx | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/client/src/events.jsx b/client/src/events.jsx index 12653b62..9c3c2d8d 100644 --- a/client/src/events.jsx +++ b/client/src/events.jsx @@ -180,8 +180,8 @@ function registerEvents(store) { setPvp(false); const player = v.players.find(p => p.id === account.id); store.dispatch(actions.setPlayer(player)); - - if (tutorial && process.env.NODE_ENV !== 'development') tutorialVbox(player, store, tutorial); + + if (tutorial) tutorialVbox(player, store, tutorial); if (v.phase === 'Finished') { ws.sendAccountInstances(); @@ -216,7 +216,6 @@ function registerEvents(store) { } function promptRegister() { - store.dispatch(actions.setTutorial(99)); store.dispatch(actions.setInstance(null)); } From 3767f0dffe45413bd4b8c946fc0acef8d427ab1a Mon Sep 17 00:00:00 2001 From: Mashy Date: Fri, 17 Jan 2020 17:28:24 +1000 Subject: [PATCH 36/38] add back register tutorial --- client/src/events.jsx | 1 + 1 file changed, 1 insertion(+) diff --git a/client/src/events.jsx b/client/src/events.jsx index 9c3c2d8d..ce566608 100644 --- a/client/src/events.jsx +++ b/client/src/events.jsx @@ -216,6 +216,7 @@ function registerEvents(store) { } function promptRegister() { + store.dispatch(actions.setTutorial(99)); store.dispatch(actions.setInstance(null)); } From fb40f73ab395d3c8c50799f40182930a03fd946e Mon Sep 17 00:00:00 2001 From: Mashy Date: Fri, 17 Jan 2020 17:31:24 +1000 Subject: [PATCH 37/38] skip tutorial text --- client/src/tutorial.utils.jsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/src/tutorial.utils.jsx b/client/src/tutorial.utils.jsx index 216ea0d2..410b7cf7 100644 --- a/client/src/tutorial.utils.jsx +++ b/client/src/tutorial.utils.jsx @@ -223,7 +223,7 @@ function tutorialStage(authenticated, tutorial, clearTutorial, instance) { const skipTutorial = authenticated && !exitTutorial ? + onMouseDown={exit}> Skip Tutorial : null; return ( From 95f13b0e78b36e6053692c5188a5901de979117e Mon Sep 17 00:00:00 2001 From: ntr Date: Fri, 17 Jan 2020 17:32:58 +1000 Subject: [PATCH 38/38] style tweaks --- client/assets/styles/styles.less | 4 ++++ client/src/components/reshape.jsx | 1 + client/src/components/shop.jsx | 2 +- 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/client/assets/styles/styles.less b/client/assets/styles/styles.less index 92ecfa1c..f2576ff4 100644 --- a/client/assets/styles/styles.less +++ b/client/assets/styles/styles.less @@ -282,6 +282,10 @@ figure.gray { @media (max-width: 1500px) { #mnml { font-size: 75%; + + &.front-page main { + padding: 0 10%; + } } svg { diff --git a/client/src/components/reshape.jsx b/client/src/components/reshape.jsx index 810db6da..2bfb4b11 100644 --- a/client/src/components/reshape.jsx +++ b/client/src/components/reshape.jsx @@ -89,6 +89,7 @@ function Reshape(args) { return (
setMtxActive(null)}>
+

Customise your Constructs

Use credits to modify your construct names and appearance.

    diff --git a/client/src/components/shop.jsx b/client/src/components/shop.jsx index 7e23bc60..ca7121c8 100644 --- a/client/src/components/shop.jsx +++ b/client/src/components/shop.jsx @@ -27,7 +27,7 @@ function Shop(args) { return (
    -

    Support the game

    +

    Support MNML

    Credits are in game currency used to change your team appearance: