anims?
This commit is contained in:
@@ -763,6 +763,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::*;
|
||||
|
||||
@@ -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
@@ -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};
|
||||
use instance::{Instance, instance_state, instance_practice, instance_ready, 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),
|
||||
@@ -268,6 +272,8 @@ impl Handler for Connection {
|
||||
|
||||
// tx should do nothing
|
||||
tx.commit().unwrap();
|
||||
} else {
|
||||
self.ws.send(RpcMessage::Demo(demo().unwrap())).unwrap();
|
||||
}
|
||||
|
||||
Ok(())
|
||||
|
||||
Reference in New Issue
Block a user