diff --git a/VERSION b/VERSION index 7f207341..1cc5f657 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -1.0.1 \ No newline at end of file +1.1.0 \ No newline at end of file diff --git a/WORKLOG.md b/WORKLOG.md index bc56173d..a246a525 100644 --- a/WORKLOG.md +++ b/WORKLOG.md @@ -6,12 +6,19 @@ * serde serialize privatise * DO postgres * mobile styles + * can't reset password without knowing password =\ * treats * constructs jiggle when clicked * background colour changes depending on time of day +* bug fixes + * pvp 1st player ready up doesn't get put in game + * pvp 1st round doesn't resolve until warden timer completes + + * bot game grind +* stress test * change score to enum * pct based translates for combat animation @@ -19,6 +26,8 @@ * send account_instances on players update * convert PlusPlus to ++ or rename +* add speed to descriptions +* add components to description e.g. Strike (red circle red circle attack) * clear skill (if currently targetted) * increase power to speed up early rounds diff --git a/acp/package.json b/acp/package.json index 5cfb205d..cc7a1379 100644 --- a/acp/package.json +++ b/acp/package.json @@ -1,6 +1,6 @@ { "name": "mnml-client", - "version": "1.0.1", + "version": "1.1.0", "description": "", "main": "index.js", "scripts": { diff --git a/bin/version.sh b/bin/version.sh new file mode 100755 index 00000000..dd50de69 --- /dev/null +++ b/bin/version.sh @@ -0,0 +1,15 @@ +#!/bin/bash + +# bless you chris and andy <3 +DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd) +MNML_PATH=$(realpath "$DIR/../") + +VERSION=$1 + +echo "Setting version to $VERSION" + +echo $VERSION | tr -d '\n' > VERSION +cd $MNML_PATH/server && sed -i "/^version/c\version = \"$VERSION\"" Cargo.toml +cd $MNML_PATH/ops && npm --allow-same-version --no-git-tag-version version "$VERSION" +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" diff --git a/client/package.json b/client/package.json index 17da24ac..a0ecb408 100644 --- a/client/package.json +++ b/client/package.json @@ -1,6 +1,6 @@ { "name": "mnml-client", - "version": "1.0.1", + "version": "1.1.0", "description": "", "main": "index.js", "scripts": { diff --git a/client/src/app.jsx b/client/src/app.jsx index ad0db010..ab17520c 100644 --- a/client/src/app.jsx +++ b/client/src/app.jsx @@ -13,6 +13,11 @@ const registerEvents = require('./events'); const Mnml = require('./components/mnml'); +function stripeKey() { + if (window.location.host === 'mnml.gg') return 'pk_live_fQGrL1uWww2ot8W1G7vTySAv004ygmnMXq'; + return 'pk_test_Cb49tTqTXpzk7nEmlGzRrNJg00AU0aNZDj'; +} + // Redux Store const store = createStore( combineReducers(reducers), @@ -30,7 +35,7 @@ document.fonts.load('16pt "Jura"').then(() => { const App = () => ( - + diff --git a/client/src/components/stripe.buttons.jsx b/client/src/components/stripe.buttons.jsx index 83076a9d..ef72c5a9 100644 --- a/client/src/components/stripe.buttons.jsx +++ b/client/src/components/stripe.buttons.jsx @@ -1,6 +1,16 @@ const preact = require('preact'); const { injectStripe } = require('react-stripe-elements'); +function subPlan() { + if (window.location.host === 'mnml.gg') return 'plan_Fjdtsd4i7aVLe1'; + return 'prod_FWSA8RoyMMV3st'; +} + +function bitsSku() { + if (window.location.host === 'mnml.gg') return 'sku_Fjdu7zOy3sLGc5'; + return 'sku_FjuNxONdWewjH2'; +} + function BitsBtn(args) { const { stripe, @@ -8,18 +18,18 @@ function BitsBtn(args) { } = args; function subscribeClick() { stripe.redirectToCheckout({ - items: [{ plan: 'plan_Fjdtsd4i7aVLe1', quantity: 1 }], - successUrl: 'https://mnml.gg', - cancelUrl: 'https://mnml.gg', + items: [{ plan: subPlan(), quantity: 1 }], + successUrl: window.location.origin, + cancelUrl: window.location.origin, clientReferenceId: account.id, }); } function bitsClick() { stripe.redirectToCheckout({ - items: [{ sku: 'sku_Fjdu7zOy3sLGc5', quantity: 1 }], - successUrl: 'https://mnml.gg', - cancelUrl: 'https://mnml.gg', + items: [{ sku: bitsSku(), quantity: 1 }], + successUrl: window.location.origin, + cancelUrl: window.location.origin, clientReferenceId: account.id, }); } diff --git a/client/src/socket.jsx b/client/src/socket.jsx index b8e919b9..e19c5c4b 100644 --- a/client/src/socket.jsx +++ b/client/src/socket.jsx @@ -1,11 +1,8 @@ const toast = require('izitoast'); const cbor = require('borc'); -const socketUrl = () => { - if (process.env.NODE_ENV === 'production') return 'wss://mnml.gg/api/ws'; - if (process.env.NODE_ENV === 'staging') return 'wss://sixtysix.pro/api/ws'; - return 'ws://localhost/api/ws'; -}; +const SOCKET_URL = + `${window.location.protocol === 'https:' ? 'wss://' : 'ws://'}${window.location.host}/api/ws`; function errorToast(err) { console.error(err); @@ -299,7 +296,7 @@ function createSocket(events) { ws = null; } - ws = new WebSocket(socketUrl()); + ws = new WebSocket(SOCKET_URL); ws.binaryType = 'arraybuffer'; // Listen for messages diff --git a/etc/nginx/sites-available/mnml.gg.STAGING.SAMPLE.nginx.conf b/etc/nginx/sites-available/mnml.gg.STAGING.SAMPLE.nginx.conf index 5e3fab85..8383b79d 100644 --- a/etc/nginx/sites-available/mnml.gg.STAGING.SAMPLE.nginx.conf +++ b/etc/nginx/sites-available/mnml.gg.STAGING.SAMPLE.nginx.conf @@ -12,8 +12,9 @@ map $http_upgrade $connection_upgrade { '' close; } -# DEV server { + server_name sixtysix.pro; + location / { root /var/lib/mnml/public/current; index index.html; @@ -40,8 +41,8 @@ server { listen [::]:443 ssl ipv6only=on; # managed by Certbot listen 443 ssl; # managed by Certbot - ssl_certificate /etc/letsencrypt/live/mnml.gg/fullchain.pem; # managed by Certbot - ssl_certificate_key /etc/letsencrypt/live/mnml.gg/privkey.pem; # managed by Certbot + ssl_certificate /etc/letsencrypt/live/sixtysix.pro/fullchain.pem; # managed by Certbot + ssl_certificate_key /etc/letsencrypt/live/sixtysix.pro/privkey.pem; # managed by Certbot include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot } diff --git a/ops/package.json b/ops/package.json index 6017c376..ce9cd791 100755 --- a/ops/package.json +++ b/ops/package.json @@ -1,6 +1,6 @@ { "name": "mnml-ops", - "version": "1.0.1", + "version": "1.1.0", "description": "", "main": "index.js", "scripts": { diff --git a/server/Cargo.toml b/server/Cargo.toml index ff673688..2b528b9b 100644 --- a/server/Cargo.toml +++ b/server/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "mnml" -version = "1.0.1" +version = "1.1.0" authors = ["ntr "] [dependencies] diff --git a/server/src/account.rs b/server/src/account.rs index a33b6b02..716c9b10 100644 --- a/server/src/account.rs +++ b/server/src/account.rs @@ -185,8 +185,9 @@ pub fn set_password(tx: &mut Transaction, id: Uuid, current: &String, password: let id: Uuid = row.get(0); let db_pw: String = row.get(1); + // return bad request to prevent being logged out if !verify(current, &db_pw)? { - return Err(MnmlHttpError::PasswordNotMatch); + return Err(MnmlHttpError::BadRequest); } let rounds = 8; diff --git a/server/src/instance.rs b/server/src/instance.rs index eb2c35d7..5443eac9 100644 --- a/server/src/instance.rs +++ b/server/src/instance.rs @@ -724,7 +724,7 @@ pub fn instance_ready(tx: &mut Transaction, account: &Account, instance_id: Uuid Ok(RpcMessage::InstanceState(instance_update(tx, instance)?)) } -pub fn instance_state(tx: &mut Transaction, _account: &Account, instance_id: Uuid) -> Result { +pub fn instance_state(tx: &mut Transaction, instance_id: Uuid) -> Result { let instance = instance_get(tx, instance_id)?; if let Some(game_id) = instance.current_game_id() { diff --git a/server/src/pg.rs b/server/src/pg.rs index 88e05a87..3afabde6 100644 --- a/server/src/pg.rs +++ b/server/src/pg.rs @@ -88,7 +88,7 @@ fn handle_notification(n: Notification, pool: &PgPool, events: &Sender) { Table::Accounts => Some(Event::Push(n.id, RpcMessage::AccountState(account::select(&db, n.id).unwrap()))), Table::Instances => - Some(Event::Push(n.id, RpcMessage::InstanceState(instance::instance_get(&mut tx, n.id).unwrap()))), + Some(Event::Push(n.id, instance::instance_state(&mut tx, n.id).unwrap())), Table::Games => Some(Event::Push(n.id, RpcMessage::GameState(game::game_get(&mut tx, n.id).unwrap()))), _ => { diff --git a/server/src/rpc.rs b/server/src/rpc.rs index df7a503c..01579c23 100644 --- a/server/src/rpc.rs +++ b/server/src/rpc.rs @@ -180,7 +180,7 @@ impl Connection { RpcRequest::InstanceReady { instance_id } => Ok(instance_ready(&mut tx, account, instance_id)?), RpcRequest::InstanceState { instance_id } => - Ok(instance_state(&mut tx, account, instance_id)?), + Ok(instance_state(&mut tx, instance_id)?), RpcRequest::VboxAccept { instance_id, group, index } => Ok(RpcMessage::InstanceState(vbox_accept(&mut tx, account, instance_id, group, index)?)),