From 73ae1e083dc157c377785a16f48c5dfb27cbc235 Mon Sep 17 00:00:00 2001 From: ntr Date: Tue, 10 Sep 2019 10:35:25 +1000 Subject: [PATCH] demo state --- client/src/components/demo.jsx | 67 ++++++---------------------------- client/src/events.jsx | 51 ++++++++++++++++++++++++-- 2 files changed, 58 insertions(+), 60 deletions(-) diff --git a/client/src/components/demo.jsx b/client/src/components/demo.jsx index 9fabd2ba..9452584d 100644 --- a/client/src/components/demo.jsx +++ b/client/src/components/demo.jsx @@ -1,12 +1,9 @@ const { connect } = require('preact-redux'); const preact = require('preact'); -const sample = require('lodash/sample'); const actions = require('../actions'); const shapes = require('./shapes'); -const { TIMES: { SOURCE_AND_TARGET_TOTAL_DURATION } } = require('./../constants'); - const { ConstructAvatar } = require('./construct'); const { ConstructAnimation } = require('./animations'); @@ -46,16 +43,11 @@ function Demo(args) { if (!demo || !itemInfo.items.length || account) return false; + const { combiner, items, equipping, equipped, players } = demo; + + console.log(items); + const vboxDemo = () => { - const phase = this.state.phase || 'vbox'; - const items = this.state.items || ['Red', 'Red', 'Attack']; - const combiner = this.state.combiner || []; - - const { - equipping, - equipped, - } = this.state; - function inventoryBtn(i, j) { if (!i) return ; const highlighted = combiner.indexOf(j) > -1; @@ -114,31 +106,6 @@ function Demo(args) { ); } - // progress - setTimeout(() => { - if (equipped) { - return this.setState({ combiner: [], items: ['Red', 'Red', 'Attack'], equipped: false, equipping: false }); - } - - if (items[0] === 'Strike' && combiner[0] === 0) { - return this.setState({ combiner: [], items: ['', '', ''], equipped: true, equipping: false }); - } - - if (items[0] === 'Strike') { - return this.setState({ combiner: [0], items: ['Strike', '', ''], equipping: true }); - } - - if (combiner.length === 3) { - return this.setState({ combiner: [], items: ['Strike', '', ''] }); - } - - combiner.push(combiner.length); - this.setState({ combiner }); - return true; - }, 2000); - - const skills = ['Strike']; - const btnClass = equipping ? 'equipping empty gray' : 'empty gray'; @@ -147,12 +114,12 @@ function Demo(args) {
{inventoryElement()}
- {demo[0].constructs.map((c, i) => ( + {players[0].constructs.map((c, i) => (

{c.name}

- {i === 0 && this.state.equipped + {i === 0 && equipped ? : } @@ -170,35 +137,23 @@ function Demo(args) { ); }; - setTimeout(() => { - setAnimTarget({ - skill: sample(itemInfo.items.filter(i => i.skill)).item, - constructId: [this.state.side ? demo[1].constructs[0].id : demo[1].constructs[1].id], - player: Math.round(Math.random()), - direction: 0, - }); - - this.setState({ side: !this.state.side }); - - // setTimeout(setAnimTarget(null), 5000); - }, 6000); - const gameDemo = () => { return (

GAME PHASE

Outplay noobs wahtever write tomorrow, fix the tiemout shit.

+

also have to just picka random avatar so i don't fill up my drive

- - + +
- - + +
diff --git a/client/src/events.jsx b/client/src/events.jsx index e62117d6..a0dc9688 100644 --- a/client/src/events.jsx +++ b/client/src/events.jsx @@ -1,4 +1,5 @@ const eachSeries = require('async/eachSeries'); +const sample = require('lodash/sample'); const actions = require('./actions'); const { TIMES } = require('./constants'); @@ -18,10 +19,6 @@ function registerEvents(store) { store.dispatch(actions.setPing(ping)); } - function setDemo(d) { - store.dispatch(actions.setDemo(d)); - } - function setNav(v) { store.dispatch(actions.setNav(v)); } @@ -190,6 +187,52 @@ function registerEvents(store) { return store.dispatch(actions.setItemInfo(v)); } + function setDemo(d) { + const initial = { + players: d, + combiner: [], + items: ['Red', 'Red', 'Attack'], + equipped: false, + equipping: false, + }; + + const startDemo = () => { + console.log(initial); + store.dispatch(actions.setDemo(initial)); + setTimeout(() => store.dispatch(actions.setDemo(Object.assign({}, initial, { combiner: [0] }))), 2000); + setTimeout(() => store.dispatch(actions.setDemo(Object.assign({}, initial, { combiner: [0, 1] }))), 4000); + setTimeout(() => store.dispatch(actions.setDemo(Object.assign({}, initial, { combiner: [0, 1, 2] }))), 6000); + setTimeout(() => store.dispatch(actions.setDemo(Object.assign({}, initial, { combiner: [], items: ['Strike', '', ''] }))), 8000); + setTimeout(() => store.dispatch(actions.setDemo(Object.assign({}, initial, { combiner: [0], items: ['Strike', '', ''], equipping: true }))), 10000); + setTimeout(() => store.dispatch(actions.setDemo(Object.assign({}, initial, { combiner: [], items: ['', '', ''], equipped: true, equipping: false }))), 12000); + setTimeout(() => store.dispatch(actions.setDemo(Object.assign({}, initial, { items: ['', '', ''], equipped: true, equipping: false }))), 12000); + + setTimeout(() => { + const { itemInfo } = store.getState(); + return store.dispatch(actions.setAnimTarget({ + skill: sample(itemInfo.items.filter(i => i.skill)).item, + constructId: d[1].constructs[0].id, + player: false, + direction: 0, + })); + }, 14000); + + setTimeout(() => { + const { itemInfo } = store.getState(); + return store.dispatch(actions.setAnimTarget({ + skill: sample(itemInfo.items.filter(i => i.skill)).item, + constructId: d[1].constructs[1].id, + player: true, + direction: 0, + })); + }, 16000); + + setTimeout(startDemo, 20000); + }; + + startDemo(); + } + // events.on('SET_PLAYER', setInstance); // events.on('SEND_SKILL', function skillActive(gameId, constructId, targetConstructId, skill) {