Merge branch 'demo-orig' into develop

This commit is contained in:
ntr
2019-09-12 11:35:18 +10:00
57 changed files with 429 additions and 137 deletions
+19
View File
@@ -797,6 +797,25 @@ pub fn instance_game_finished(tx: &mut Transaction, game: &Game, instance_id: Uu
Ok(())
}
pub fn demo() -> Result<Vec<Player>, 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::*;
+1
View File
@@ -27,3 +27,4 @@ pub fn bot_player() -> Player {
let constructs = instance_mobs(bot_id);
Player::new(bot_id, &name(), constructs).set_bot(true)
}
+7 -1
View File
@@ -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<Instance>),
AccountShop(mtx::Shop),
Demo(Vec<Player>),
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(())