Skip to content

Commit

Permalink
Merge pull request #48 from pilksoc/redux-game-client
Browse files Browse the repository at this point in the history
Added project base for new frontend
  • Loading branch information
djpiper28 authored May 5, 2024
2 parents 3437ef3 + bdf5d06 commit 8a11aae
Show file tree
Hide file tree
Showing 13 changed files with 1,017 additions and 602 deletions.
1 change: 0 additions & 1 deletion backend/src/modify_gamestate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,6 @@ pub async fn perform_action(action: Action) {
}

pub async fn move_player(old_pos: Option<[u64; 2]>, new_pos: [u64; 2], player: Player) {

let player_key = player.uuid.to_string();

//remove the players old location in the world, if provided
Expand Down
3 changes: 3 additions & 0 deletions backend/src/ws/gen_json.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ async fn recalculate_game(state: PlayerInfo, id: &str) -> String {
let player_initialised = state.initialised;
let player_location = state.coordinates;

println!("Generating new game state for {id}");
modify_gamestate(state).await;

// The dereferencing looks a little weird. Here's what's going on:
Expand All @@ -34,11 +35,13 @@ async fn recalculate_game(state: PlayerInfo, id: &str) -> String {
let resp: Value;

if player_initialised {
println!("Continuing game loop for {id}");
// if the player is not new to the game, continue game loop
resp = json!({
"grid" : new_grid,
});
} else {
println!("Issuing join data for {id}");
resp = json!({
"coordinates" : player_location,
"uuid" : id
Expand Down
4 changes: 2 additions & 2 deletions game-source-redux/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,6 @@ If you have state that's important to retain within a component, consider creati
```ts
// store.ts
// An extremely simple external store
import { writable } from 'svelte/store'
export default writable(0)
import { writable } from "svelte/store";
export default writable(0);
```
3 changes: 3 additions & 0 deletions game-source-redux/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,8 @@
"tslib": "^2.6.2",
"typescript": "^5.2.2",
"vite": "^5.2.0"
},
"dependencies": {
"uuid": "^9.0.1"
}
}
Loading

0 comments on commit 8a11aae

Please sign in to comment.