-
mnml is an abstract turn based strategy game
-
free to play
-
no email required
-
glhf
+
);
}
diff --git a/client/src/constants.jsx b/client/src/constants.jsx
index 0719f25f..f7044d3d 100644
--- a/client/src/constants.jsx
+++ b/client/src/constants.jsx
@@ -1,3 +1,5 @@
+const preact = require('preact');
+
const SOURCE_DURATION_MS = 1000;
const TARGET_DELAY_MS = 500;
const TARGET_DURATION_MS = 1500;
@@ -24,15 +26,11 @@ module.exports = {
INFO: {
vbox: {
item: 'VBOX',
- description: 'Contains ITEMS that are available for you to buy.\nDouble-click to purchase.',
+ description:
ITEMS that are available to buy.
the VBOX is refilled every round.
click REFILL at the bottom to purchase a refill.
,
},
inventory: {
item: 'INVENTORY',
- description: 'Holds purchased ITEMS.\nClick to add ITEM to I-COMBINATOR.',
- },
- combiner: {
- item: 'I-COMBINATOR',
- description: 'Combines purchased ITEMS into more powerful variants. Hover over an ITEM to see recipes.',
+ description:
holds ITEMS
ITEMS carry over each round.
,
},
bits: {
item: 'BITS',
@@ -51,12 +49,12 @@ module.exports = {
description: 'Reclaim ITEMS for half the purchase cost of their combined ITEMS.\nClick to enable and click ITEM to reclaim.',
},
refine: {
- item: 'REFINE',
- description: 'Refine ITEMS currently in I-COMBINATOR into more powerful variants',
+ item: 'COMBINE',
+ description:
combine the selected items.
hover over an item to see RECIPES.
,
},
refill: {
item: 'REFILL',
- description: 'Refill the VBOX with new ITEMS.',
+ description: 'Refill the VBOX with new items.',
},
equipSkills: {
item: 'QUICK ACCESS - SKILLS',
diff --git a/client/src/events.jsx b/client/src/events.jsx
index 1c01bd53..a9481ccd 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');
@@ -187,6 +188,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) {
@@ -230,6 +277,7 @@ function registerEvents(store) {
setAccountInstances,
setActiveItem,
setActiveSkill,
+ setDemo,
setConstructList,
setNewConstruct,
setGame,
diff --git a/client/src/reducers.jsx b/client/src/reducers.jsx
index 496a5acc..cfc6dad5 100644
--- a/client/src/reducers.jsx
+++ b/client/src/reducers.jsx
@@ -23,6 +23,8 @@ module.exports = {
animTarget: createReducer(null, 'SET_ANIM_TARGET'),
animText: createReducer(null, 'SET_ANIM_TEXT'),
+ demo: createReducer(null, 'SET_DEMO'),
+
combiner: createReducer([], 'SET_COMBINER'),
constructs: createReducer([], 'SET_CONSTRUCTS'),
constructEditId: createReducer(null, 'SET_CONSTRUCT_EDIT_ID'),
diff --git a/client/src/socket.jsx b/client/src/socket.jsx
index 4ac30163..a6a97162 100644
--- a/client/src/socket.jsx
+++ b/client/src/socket.jsx
@@ -206,6 +206,10 @@ function createSocket(events) {
events.setItemInfo(info);
}
+ function onDemo(v) {
+ events.setDemo(v);
+ }
+
let pongTimeout;
function onPong() {
events.setPing(Date.now() - ping);
@@ -231,6 +235,7 @@ function createSocket(events) {
InstanceState: onInstanceState,
ItemInfo: onItemInfo,
Pong: onPong,
+ Demo: onDemo,
QueueRequested: () => events.notify('pvp queue request received'),
QueueJoined: () => events.notify('you have joined the pvp queue'),
diff --git a/server/src/instance.rs b/server/src/instance.rs
index 9abf3aca..489f6fe2 100644
--- a/server/src/instance.rs
+++ b/server/src/instance.rs
@@ -797,6 +797,25 @@ pub fn instance_game_finished(tx: &mut Transaction, game: &Game, instance_id: Uu
Ok(())
}
+pub fn demo() -> Result
, Error> {
+ let bot = bot_player();
+
+ // generate bot imgs for the client to see
+ for c in bot.constructs.iter() {
+ img::molecular_write(c.img)?;
+ };
+
+ let bot2 = bot_player();
+
+ // generate bot imgs for the client to see
+ for c in bot2.constructs.iter() {
+ img::molecular_write(c.img)?;
+ };
+
+
+ Ok(vec![bot, bot2])
+}
+
#[cfg(test)]
mod tests {
use super::*;
diff --git a/server/src/mob.rs b/server/src/mob.rs
index 6bb6aaf1..2cab954b 100644
--- a/server/src/mob.rs
+++ b/server/src/mob.rs
@@ -27,3 +27,4 @@ pub fn bot_player() -> Player {
let constructs = instance_mobs(bot_id);
Player::new(bot_id, &name(), constructs).set_bot(true)
}
+
diff --git a/server/src/rpc.rs b/server/src/rpc.rs
index 09b9cdfd..4f73e17f 100644
--- a/server/src/rpc.rs
+++ b/server/src/rpc.rs
@@ -21,10 +21,12 @@ use account;
use construct::{Construct};
use events::{Event};
use game::{Game, game_state, game_skill, game_skill_clear, game_ready};
-use instance::{Instance, instance_state, instance_practice, instance_ready, instance_abandon};
+use instance::{Instance, instance_state, instance_practice, instance_ready, instance_abandon, demo};
use item::{Item, ItemInfoCtr, item_info};
use mtx;
use mail;
+
+use player::{Player};
use payments;
use mail::Email;
use pg::{Db};
@@ -41,6 +43,8 @@ pub enum RpcMessage {
AccountInstances(Vec),
AccountShop(mtx::Shop),
+ Demo(Vec),
+
ConstructSpawn(Construct),
GameState(Game),
ItemInfo(ItemInfoCtr),
@@ -271,6 +275,8 @@ impl Handler for Connection {
// tx should do nothing
tx.commit().unwrap();
+ } else {
+ self.ws.send(RpcMessage::Demo(demo().unwrap())).unwrap();
}
Ok(())