Skip to content

Commit

Permalink
Merge pull request #3 from SnowdenWintermute/feature
Browse files Browse the repository at this point in the history
0.2.0
  • Loading branch information
SnowdenWintermute authored Jan 25, 2024
2 parents b704746 + a2df881 commit 84b38f4
Show file tree
Hide file tree
Showing 68 changed files with 1,129 additions and 498 deletions.
10 changes: 6 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
Multiplayer turn based game in the spirit of For the King, Diablo and Final Fantasy.
# Roguelike Racing

A multiplayer turn based game in the spirit of For the King, Diablo and Final Fantasy.

UI written with the Yew frontend framework, backend uses websockets via Actix.

To compile tailwind:
From the client directory run npx tailwindcss -i ./input.css -o ./style/output.css --watch
From the client directory run `npx tailwindcss -i ./input.css -o ./style/output.css --watch`

To run the server:
From the server directory run cargo-watch -x run
From the server directory run `cargo-watch -x run`

To run the frontend:
From the client directory run trunk serve
From the client directory run `TRUNK_PROD=false trunk serve`
23 changes: 14 additions & 9 deletions client/cypress/e2e/first-user.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,22 +12,27 @@ describe("a test test", () => {
cy.findByRole("button", { name: "Create Character" }).focus();
cy.findByRole("button", { name: "Create Character" }).click();

// cy.findByPlaceholderText("Character name...")
// .click()
// .clear()
// .type("R. Chambers", { delay: 0 });
// cy.findByRole("button", { name: "Create Character" }).focus();
// cy.findByRole("button", { name: "Create Character" }).click();
cy.findByPlaceholderText("Character name...")
.click()
.clear()
.type("R. Chambers", { delay: 0 });
cy.findByRole("button", { name: "Create Character" }).focus();
cy.findByRole("button", { name: "Create Character" }).click();

cy.task("checkpoint", "game created");
cy.task("waitForCheckpoint", "second player character created");

cy.findByRole("button", { name: "Ready" }).click();
// cy.findByText("Open Inventory").click();
cy.findByText("Ready to explore").click();
cy.findByText("Attack").click();
cy.findByText("Execute").click();
cy.task("checkpoint", "first attack executed");
// cy.findByText("Attack").click();
// cy.findByText("Execute").click();

// cy.wait(2000);

// cy.findByText("Attack").click();
// cy.findByText("Execute").click();
// cy.task("checkpoint", "first attack executed");

// cy.findAllByText("Take").first().click({ force: true });
// cy.findAllByText("Take").first().click({ force: true });
Expand Down
6 changes: 3 additions & 3 deletions client/cypress/e2e/second-user.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ describe("a test test", () => {
cy.findByRole("button", { name: "Ready" }).click();
cy.findByText("Ready to explore").click();

cy.task("waitForCheckpoint", "first attack executed");
// cy.task("waitForCheckpoint", "first attack executed");

cy.findByText("Attack").click();
cy.findByText("Execute").click();
// cy.findByText("Attack").click();
// cy.findByText("Execute").click();

// cy.findAllByText("Take").first().click({ force: true });
// cy.findAllByText("Take").first().click({ force: true });
Expand Down
22 changes: 22 additions & 0 deletions client/deployment-notes.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# both

- check the dockerfile to see how dummy directories are used to cache dependencies before
actually building

# client

- set env variables in trunk like TRUNK_PROD=true trunk build --release
- access env variables in Yew like :
let in_production = std::env!("TRUNK_PROD");
- websocket address should be in the format wss://domainname.com/ws

# server

- actix address must be changed to 0.0.0.0:port in order to serve from inside
a docker container
- nginx should be configured like shown in the config file in same directory
- in order to ensure the docker container exits on panic set
RUST_BACKTRACE=1 env to in server dockerfile and make sure the s
erver Cargo.toml sets the behavior of :
[profile.release]
panic = 'abort'
8 changes: 4 additions & 4 deletions client/dist/index.html
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
<!DOCTYPE html><html><head>
<meta charset="utf-8">
<title>Roguelike Racing</title>
<link rel="stylesheet" href="/output-577bfbea865325fb.css">
<link rel="stylesheet" href="/output-24b437c61eec847e.css">

<base href="/">

<link rel="preload" href="/roguelike-racing-client-715bddf21eeeb498_bg.wasm" as="fetch" type="application/wasm" crossorigin="">
<link rel="modulepreload" href="/roguelike-racing-client-715bddf21eeeb498.js"></head>
<link rel="preload" href="/roguelike-racing-client-8b44f5306eb3adda_bg.wasm" as="fetch" type="application/wasm" crossorigin="">
<link rel="modulepreload" href="/roguelike-racing-client-8b44f5306eb3adda.js"></head>
<body>

<script type="module">import init from '/roguelike-racing-client-715bddf21eeeb498.js';init('/roguelike-racing-client-715bddf21eeeb498_bg.wasm');</script><script>(function () {
<script type="module">import init from '/roguelike-racing-client-8b44f5306eb3adda.js';init('/roguelike-racing-client-8b44f5306eb3adda_bg.wasm');</script><script>(function () {
var protocol = window.location.protocol === 'https:' ? 'wss:' : 'ws:';
var url = protocol + '//' + window.location.host + '/_trunk/ws';
var poll_interval = 5000;
Expand Down
Binary file removed client/dist/public/code_meme.jpg
Binary file not shown.
Binary file removed client/public/code_meme.jpg
Binary file not shown.
Binary file added client/public/img/door.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added client/public/img/stairs-down.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
use super::action_handlers::handle_cycle_targeting_schemes::handle_cycle_targeting_schemes;
use super::action_handlers::handle_cycle_targets::handle_cycle_targets;
use super::available_actions::GameActions;
use super::get_character_owned_item_by_id::get_character_owned_item_by_id;
use crate::components::game::action_menu::action_handlers::handle_select_ability::handle_select_ability;
pub mod handle_cycle_targeting_schemes;
pub mod handle_cycle_targets;
pub mod handle_select_ability;
use super::enums::GameActions;
use crate::components::websocket_manager::send_client_input::send_client_input;
use crate::store::alert_store::AlertStore;
use crate::store::game_store::get_focused_character;
use crate::store::game_store::get_item_owned_by_focused_character;
use crate::store::game_store::select_item;
use crate::store::game_store::GameStore;
use crate::store::ui_store::UIStore;
Expand All @@ -18,7 +18,7 @@ use common::packets::CharacterAndSlot;
use std::rc::Rc;
use yewdux::prelude::Dispatch;

pub fn create_action_handler<'a>(
pub fn create_action_button_click_handler<'a>(
game_action: GameActions,
game_dispatch: Dispatch<GameStore>,
game_state: Rc<GameStore>,
Expand Down Expand Up @@ -61,7 +61,7 @@ pub fn create_action_handler<'a>(
});
}),
GameActions::SelectItem(id) => Box::new(move || {
let item = get_character_owned_item_by_id(&id, game_state.clone())
let item = get_item_owned_by_focused_character(&id, game_state.clone())
.expect("a character should only be able to select their own items");
let cloned_dispatch = game_dispatch.clone();
select_item(cloned_dispatch, Some(item));
Expand Down Expand Up @@ -100,7 +100,7 @@ pub fn create_action_handler<'a>(
GameActions::SelectAbility(ability_name) => Box::new(move || {
let cloned_dispatch = game_dispatch.clone();
let cloned_alert_dispatch = alert_dispatch.clone();
handle_select_ability(
handle_select_ability::handle_select_ability(
cloned_dispatch,
cloned_alert_dispatch,
&websocket_state.websocket,
Expand All @@ -125,15 +125,18 @@ pub fn create_action_handler<'a>(
}),
GameActions::CycleTargets(next_or_previous) => Box::new(move || {
let cloned_dispatch = game_dispatch.clone();
handle_cycle_targets(
handle_cycle_targets::handle_cycle_targets(
cloned_dispatch,
&websocket_state.websocket,
&next_or_previous,
)
}),
GameActions::CycleTargetingScheme => Box::new(move || {
game_dispatch.reduce_mut(|store| {
handle_cycle_targeting_schemes(store, &websocket_state.websocket)
handle_cycle_targeting_schemes::handle_cycle_targeting_schemes(
store,
&websocket_state.websocket,
)
})
}),
GameActions::UseSelectedAbility => Box::new(move || {
Expand Down Expand Up @@ -187,13 +190,12 @@ pub fn create_action_handler<'a>(
store.detailed_entity = None;
});
}),
_ => Box::new(|| ()), // GameActions::OpenTreasureChest => || (),
// GameActions::TakeItem => || (),
// GameActions::DropItem => || (),
// GameActions::ShardItem => || (),
// GameActions::Attack => || (),
// GameActions::LevelUpAbility(_) => || (),
// GameActions::SetAssignAttributePointsMenuOpen(_) => || (),
// GameActions::AssignAttributePoint(_) => || (),
GameActions::ToggleReadyToDescend => Box::new(move || {
send_client_input(
&websocket_state.websocket,
PlayerInputs::ToggleReadyToGoDownStairs,
);
}),
_ => Box::new(|| ()),
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
use super::enums::GameActions;
use crate::store::game_store::get_item_owned_by_focused_character;
use crate::store::game_store::DetailableEntities;
use crate::store::game_store::GameStore;
use std::rc::Rc;
use yewdux::prelude::Dispatch;

pub fn create_action_mouse_enter_handler(
action: GameActions,
game_dispatch: Dispatch<GameStore>,
game_state: Rc<GameStore>,
) -> Box<dyn Fn()> {
match action {
GameActions::SelectItem(id) => Box::new(move || {
let item = get_item_owned_by_focused_character(&id, game_state.clone())
.expect("a character should only be able to select their own items");
game_dispatch
.reduce_mut(|store| store.hovered_entity = Some(DetailableEntities::Item(item)));
}),
_ => Box::new(|| ()),
}
}

pub fn create_action_mouse_leave_handler(
action: GameActions,
game_dispatch: Dispatch<GameStore>,
_game_state: Rc<GameStore>,
) -> Box<dyn Fn()> {
match action {
GameActions::SelectItem(_id) => Box::new(move || {
game_dispatch.reduce_mut(|store| store.hovered_entity = None);
}),
_ => Box::new(|| ()),
}
}
3 changes: 0 additions & 3 deletions client/src/components/game/action_menu/action_handlers/mod.rs

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,11 +1,19 @@
use super::available_actions::GameActions;
use crate::components::game::action_menu::enums::GameActions;
use crate::store::game_store::GameStore;
use common::game::getters::get_party;
use std::rc::Rc;

pub fn generate_button_text(action: GameActions, game_state: Rc<GameStore>) -> String {
pub fn determine_action_button_text(action: GameActions, game_state: Rc<GameStore>) -> String {
match action {
GameActions::ToggleReadyToExplore => "Ready to explore".to_string(),
GameActions::ToggleReadyToExplore => {
let party = game_state
.get_current_party()
.expect("to be in a party when showing this button");
match party.current_room.room_type {
common::dungeon_rooms::DungeonRoomTypes::Stairs => "Vote to stay".to_string(),
_ => "Ready to explore".to_string(),
}
}
GameActions::SetInventoryOpen(open_status) => {
if open_status {
"Open inventory".to_string()
Expand Down Expand Up @@ -48,6 +56,7 @@ pub fn generate_button_text(action: GameActions, game_state: Rc<GameStore>) -> S
GameActions::CycleTargetingScheme => "Targeting scheme".to_string(),
GameActions::DeselectAbility => "Cancel".to_string(),
GameActions::UseSelectedAbility => "Execute".to_string(),
GameActions::ToggleReadyToDescend => "Vote to descend".to_string(),
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use super::set_up_actions::ActionMenuButtonProperties;
pub mod determine_action_button_text;
use super::build_action_button_properties::ActionMenuButtonProperties;
use yew::prelude::*;

#[derive(Properties, PartialEq)]
Expand Down
Loading

0 comments on commit 84b38f4

Please sign in to comment.