hmmm, stuff
This commit is contained in:
parent
2ed7602595
commit
5979e53d91
3 changed files with 32 additions and 23 deletions
35
src/lib.rs
35
src/lib.rs
|
@ -94,7 +94,8 @@ impl GameServer {
|
|||
.map(|p| p == &login.password)
|
||||
.unwrap_or(false)
|
||||
{
|
||||
self.users.insert(login.username.clone(), login.username == "rusty"); // rusty will be admin for now :)
|
||||
let admin = login.username == "rusty"; // rusty will be admin for now :)
|
||||
self.users.insert(login.username.clone(), admin);
|
||||
// Send login confirmation
|
||||
_ = broadcast.send((
|
||||
Some(id.clone()),
|
||||
|
@ -104,7 +105,6 @@ impl GameServer {
|
|||
}),
|
||||
));
|
||||
// Send the list of scenes and chat history and such
|
||||
let admin = *self.users.get(&id).unwrap_or(&false);
|
||||
_ = broadcast.send((Some(login.username.clone()), self.get_scene_list(admin)));
|
||||
_ = broadcast.send((Some(login.username.clone()), self.get_last_messages(50)));
|
||||
} else {
|
||||
|
@ -175,10 +175,14 @@ impl GameServer {
|
|||
scene,
|
||||
} => {
|
||||
if *self.users.get(&id).unwrap_or(&false) {
|
||||
if let Some(scene) = self.game.get_scene_mut(scene) {
|
||||
if let Some(map) = scene.map.as_mut() {
|
||||
if let Some(s) = self.game.get_scene_mut(scene) {
|
||||
if let Some(map) = s.map.as_mut() {
|
||||
map.grid_cell_size = grid_cell_size;
|
||||
map.grid_offset = grid_offset;
|
||||
let return_id = if s.visible_to_users { None } else { Some(id.clone()) };
|
||||
if let Some(scene) = self.get_scene(&id, scene) {
|
||||
_ = broadcast.send((return_id, scene));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -201,17 +205,18 @@ impl GameServer {
|
|||
y,
|
||||
img_path,
|
||||
} => {
|
||||
// TODO: Make sure the user is an admin
|
||||
let token_id = self.game.create_token(map_id, character, img_path.clone(), x, y);
|
||||
_ = broadcast.send((
|
||||
None, // TODO: add the option to spawn the token hidden
|
||||
api::Response::SpawnToken(SpawnToken {
|
||||
token_id,
|
||||
x,
|
||||
y,
|
||||
img: img_path.clone(),
|
||||
}),
|
||||
));
|
||||
if *self.users.get(&id).unwrap_or(&false) {
|
||||
let token_id = self.game.create_token(map_id, character, img_path.clone(), x, y);
|
||||
_ = broadcast.send((
|
||||
None, // TODO: add the option to spawn the token hidden
|
||||
api::Response::SpawnToken(SpawnToken {
|
||||
token_id,
|
||||
x,
|
||||
y,
|
||||
img: img_path.clone(),
|
||||
}),
|
||||
));
|
||||
}
|
||||
}
|
||||
api::Request::MoveToken { token_id, x, y } => {
|
||||
// TODO: add check to make sure the actor is authorized to move the token
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue