diff --git a/client/Cargo.toml b/client/Cargo.toml index 7f5eb4ad..1e3212c9 100644 --- a/client/Cargo.toml +++ b/client/Cargo.toml @@ -3,10 +3,6 @@ name = "client" version = "0.1.0" edition = "2021" -[features] -# disable file import and export -wasm = [] - # may be needed for remote client #[lib] #name = "client" diff --git a/client/src/local_client.rs b/client/src/local_client.rs index a1db8722..77c8e3eb 100644 --- a/client/src/local_client.rs +++ b/client/src/local_client.rs @@ -2,19 +2,20 @@ use crate::client; use macroquad::prelude::next_frame; -use std::fs::File; -use std::io::BufReader; use crate::client::{Features, GameSyncRequest, GameSyncResult}; use server::city::City; -use server::game::{Game, GameData}; +use server::game::Game; use server::map::Terrain; use server::position::Position; use server::resource_pile::ResourcePile; use server::unit::UnitType; -pub async fn run(mut game: Game, features: &Features) { +pub async fn run(mut game: Game) { let mut state = client::init().await; + let features = Features { + import_export: true, + }; let mut sync_result = GameSyncResult::None; loop { @@ -109,19 +110,23 @@ fn add_terrain(game: &mut Game, pos: &str, terrain: Terrain) { game.map.tiles.insert(Position::from_offset(pos), terrain); } -const EXPORT_FILE: &str = "game.json"; +// const EXPORT_FILE: &str = "game.json"; fn import() -> Game { - let file = File::open(EXPORT_FILE).expect("Failed to open export file"); - let reader = BufReader::new(file); - let data: GameData = serde_json::from_reader(reader).expect("Failed to read export file"); - Game::from_data(data) + // todo only works with native client + // let file = File::open(EXPORT_FILE).expect("Failed to open export file"); + // let reader = BufReader::new(file); + // let data: GameData = serde_json::from_reader(reader).expect("Failed to read export file"); + // Game::from_data(data) + panic!() } -fn export(game: &Game) { - serde_json::to_writer_pretty( - File::create(EXPORT_FILE).expect("Failed to create export file"), - &game.cloned_data(), - ) - .expect("Failed to write export file"); +fn export(_game: &Game) { + // todo only works with native client + // serde_json::to_writer_pretty( + // File::create(EXPORT_FILE).expect("Failed to create export file"), + // &game.cloned_data(), + // ) + // .expect("Failed to write export file"); + panic!() } diff --git a/client/src/local_client/bin/main.rs b/client/src/local_client/bin/main.rs index 47db5c13..75547208 100644 --- a/client/src/local_client/bin/main.rs +++ b/client/src/local_client/bin/main.rs @@ -1,15 +1,8 @@ -use client::client::Features; use client::local_client; use server::game::Game; #[macroquad::main("Clash")] async fn main() { - let wasm = cfg!(feature = "wasm"); - - let features = Features { - import_export: !wasm, - }; - //todo add button to decide random or fixed game let game = if false { Game::new(2, "a".repeat(32), true) @@ -17,5 +10,5 @@ async fn main() { local_client::setup_local_game() }; - local_client::run(game, &features).await; + local_client::run(game).await; } diff --git a/client/wasm-bindgen-macroquad.sh b/client/wasm-bindgen-macroquad.sh index 629e21a2..9c090ce4 100755 --- a/client/wasm-bindgen-macroquad.sh +++ b/client/wasm-bindgen-macroquad.sh @@ -114,10 +114,10 @@ TARGET_DIR="target/wasm32-unknown-unknown" # Build echo "Building $PROJECT_NAME..." if [ -n "$RELEASE" ]; then - cargo build --release --target wasm32-unknown-unknown --features "wasm" + cargo build --release --target wasm32-unknown-unknown TARGET_DIR="$TARGET_DIR/release" else - cargo build --target wasm32-unknown-unknown --features "wasm" + cargo build --target wasm32-unknown-unknown TARGET_DIR="$TARGET_DIR/debug" fi