rstnode: update dependencies and fixing game build

wip/yesman
Katharina Fey 3 years ago
parent 31ec889558
commit 398027b443
Signed by: kookie
GPG Key ID: F972AEEA2887D547
  1. 2723
      games/rstnode/Cargo.lock
  2. 2
      games/rstnode/Cargo.toml
  3. 13
      games/rstnode/src/_if.rs
  4. 1
      games/rstnode/src/_loop.rs
  5. 8
      games/rstnode/src/_match.rs
  6. 25
      games/rstnode/src/lib.rs
  7. 5
      games/rstnode/src/server.rs

File diff suppressed because it is too large Load Diff

@ -12,7 +12,7 @@ serde_json = "1.0"
async-std = { version = "1.0", features = ["unstable"] }
async-trait = "0.1"
ratman = "0.1.0"
ratman = "0.1"
netmod-mem = "0.1.0"
identity = { version = "0.4", features = ["random"], package = "ratman-identity"}

@ -8,7 +8,12 @@ use async_std::sync::Arc;
use async_trait::async_trait;
use chrono::{DateTime, Utc};
/// The main game interface implemented by the server and client
/// Main game interface implemented by the server and client
///
/// The client implementation simply translates requests to network
/// requests that are sent to the server. The server implementation
/// consists of two parts: the network layer listening loop, and the
/// game server state which then implements the actual game logic.
#[async_trait]
pub trait GameIf {
/// Register a new user on a game server
@ -38,7 +43,11 @@ pub trait GameIf {
) -> Result<LobbyUpdate, LobbyErr>;
/// Send a start request (as lobby admin)
async fn start_req(self: Arc<Self>, user: UserId, lobby: LobbyId) -> Result<DateTime<Utc>, LobbyErr>;
async fn start_req(
self: Arc<Self>,
user: UserId,
lobby: LobbyId,
) -> Result<DateTime<Utc>, LobbyErr>;
/// Perform a game action as a user
async fn perform_action(self: Arc<Self>, user: User, mtch: MatchId, act: Action)

@ -11,6 +11,7 @@ use std::{
};
/// Number of ticks per second
#[from_env("RSTNODE_TICKS")]
const TICKS: u64 = 100;
const TICK_TIME: Duration = Duration::from_millis(1000 / TICKS);

@ -17,7 +17,7 @@ pub struct Match {
pub players: Vec<Player>,
/// The active game map
pub map: Map,
/// Input inbox,
/// Input inbox (handled in-order each game tick)
inbox: RwLock<VecDeque<Action>>,
/// The time the match was initialised
init_t: DateTime<Utc>,
@ -59,9 +59,9 @@ impl Match {
self.inbox.write().await.push_back(cmd);
}
pub async fn handle_inbex(&mut self) {
for act in self.inbox.write().await.drain() {
pub async fn handle_inbox(&mut self) {
// for act in self.inbox.write().await.drain() {
}
// }
}
}

@ -1,21 +1,24 @@
#![allow(warnings)]
#[macro_use]
extern crate const_env;
mod _if;
pub use _if::GameIf;
pub mod data;
pub mod gens;
mod _loop;
mod _match;
mod config;
mod io;
mod lobby;
mod map;
mod mapstore;
mod server;
mod stats;
mod users;
mod wire;
pub mod _loop;
pub mod _match;
pub mod config;
pub mod io;
pub mod lobby;
pub mod map;
pub mod mapstore;
pub mod server;
pub mod stats;
pub mod users;
pub mod wire;
pub use identity::Identity as Id;

@ -1,3 +1,8 @@
//! Game server state handler
//!
//! A server can host many lobbies at the same time. It listens for
//! connections according to a address given to the initialiser.
use crate::{
_if::GameIf,
_match::Match,

Loading…
Cancel
Save