Skip to content

Commit

Permalink
Merge pull request #6 from SnowdenWintermute/feature
Browse files Browse the repository at this point in the history
0.4.0
  • Loading branch information
SnowdenWintermute authored Feb 5, 2024
2 parents a888a92 + 48abca0 commit 3fdf9c3
Show file tree
Hide file tree
Showing 170 changed files with 4,617 additions and 2,326 deletions.
17 changes: 11 additions & 6 deletions client/cypress/e2e/first-user.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,20 @@ describe("a test test", () => {
cy.task("waitForCheckpoint", "second player character created");

cy.findByRole("button", { name: "Ready" }).click();
// cy.findByText("Open Inventory").click();
cy.findByText("Open Inventory").click();
cy.findAllByText("HP Autoinjector").first().click();
cy.findByText("Use").click();
cy.findByText("Execute").click();
cy.findByText("Close Inventory").click();

cy.findByText("Ready to explore").click();
// cy.findByText("Attack").click();
// cy.findByText("Execute").click();
cy.findByText("Attack").click();
cy.findByText("Execute").click();

// cy.wait(2000);
cy.wait(2000);

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

// cy.findAllByText("Take").first().click({ force: true });
Expand Down
7 changes: 7 additions & 0 deletions client/cypress/e2e/second-user.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,13 @@ describe("a test test", () => {
cy.findByRole("button", { name: "Create Character" }).click();
cy.task("checkpoint", "second player character created");
cy.findByRole("button", { name: "Ready" }).click();

cy.findByText("Open Inventory").click();
cy.findAllByText("HP Autoinjector").first().click();
cy.findByText("Use").click();
cy.findByText("Execute").click();
cy.findByText("Close Inventory").click();

cy.findByText("Ready to explore").click();

// cy.task("waitForCheckpoint", "first attack executed");
Expand Down
33 changes: 21 additions & 12 deletions client/cypress/e2e/test.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,22 +12,31 @@ 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("Rebecca Chambers", { delay: 0 });
// cy.findByRole("button", { name: "Create Character" }).focus();
// cy.findByRole("button", { name: "Create Character" }).click();
cy.findByPlaceholderText("Character name...")
.click()
.clear()
.type("Rebecca Chambers", { delay: 0 });
cy.findByRole("button", { name: "Create Character" }).focus();
cy.findByRole("button", { name: "Create Character" }).click();

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

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.wait(1200);
// cy.findByText("Attack").click();
// cy.findByText("Execute").click();
// cy.wait(1200);
// cy.findByText("Attack").click();
// cy.findByText("Execute").click();
});
});
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-c24bce4d664576cf.css">
<link rel="stylesheet" href="/output-3a7d22295aa4068d.css">

<base href="/">

<link rel="preload" href="/roguelike-racing-client-a1f8a7222ed7da46_bg.wasm" as="fetch" type="application/wasm" crossorigin="">
<link rel="modulepreload" href="/roguelike-racing-client-a1f8a7222ed7da46.js"></head>
<link rel="preload" href="/roguelike-racing-client-1290ce234f6245d9_bg.wasm" as="fetch" type="application/wasm" crossorigin="">
<link rel="modulepreload" href="/roguelike-racing-client-1290ce234f6245d9.js"></head>
<body>

<script type="module">import init from '/roguelike-racing-client-a1f8a7222ed7da46.js';init('/roguelike-racing-client-a1f8a7222ed7da46_bg.wasm');</script><script>(function () {
<script type="module">import init from '/roguelike-racing-client-1290ce234f6245d9.js';init('/roguelike-racing-client-1290ce234f6245d9_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
6 changes: 6 additions & 0 deletions client/src/components/common_components/atoms/button_basic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ use crate::components::common_components::atoms::button_blank::ButtonBlank;
pub struct Props {
#[prop_or(Callback::from(|_e: MouseEvent|()))]
pub onclick: Callback<MouseEvent>,
#[prop_or(Callback::from(|_e: FocusEvent|()))]
pub onfocus: Callback<FocusEvent>,
#[prop_or(Callback::from(|_e: FocusEvent|()))]
pub onblur: Callback<FocusEvent>,
#[prop_or(false)]
pub disabled: bool,
#[prop_or_default]
Expand All @@ -27,6 +31,8 @@ pub fn button_basic(props: &Props) -> Html {
)
}
onclick={props.onclick.clone()}
onfocus={props.onfocus.clone()}
onblur={props.onblur.clone()}
disabled={props.disabled}
button_type={props.button_type.clone()}
>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,28 @@
use common::combatants::abilities::CombatantAbilityNames;
use common::items::consumables::ConsumableProperties;
use common::items::consumables::ConsumableTypes;
use yew::prelude::*;

#[derive(Properties, PartialEq)]
pub struct Props {}
pub struct Props {
pub ability_name_option: Option<CombatantAbilityNames>,
pub consumable_option: Option<ConsumableProperties>,
}

#[function_component(TargetingIndicator)]
pub fn targeting_indicator(_: &Props) -> Html {
pub fn targeting_indicator(props: &Props) -> Html {
let mut color = "yellow-700";

if let Some(consumable) = &props.consumable_option {
match consumable.consumable_type {
ConsumableTypes::HpAutoinjector => color = "green-600",
ConsumableTypes::Grenade => (),
ConsumableTypes::SmokeBomb => color = "gray-700",
}
}
html!(
<div class="w-0 h-0 border-t-[1.5rem] border-t-yellow-700
border-r-[1.5rem] border-r-transparent border-l-[1.5rem] border-l-transparent
" />
<div class={format!("w-0 h-0 border-t-[1.5rem] border-t-{color}
border-r-[1.5rem] border-r-transparent border-l-[1.5rem] border-l-transparent
")} />
)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
use super::handle_cycle_combat_action_targeting_schemes::handle_cycle_combat_action_targeting_schemes;
use crate::components::websocket_manager::send_client_input::send_client_input;
use crate::store::game_store::GameStore;
use common::app_consts::error_messages;
use common::errors::AppError;
use common::game::getters::get_mut_party;
use common::packets::client_to_server::ChangeTargetsPacket;
use common::packets::client_to_server::PlayerInputs;
use gloo::console::log;
use web_sys::WebSocket;
use yewdux::Dispatch;

pub fn handle_cycle_ability_targeting_schemes(
game_dispatch: Dispatch<GameStore>,
websocket_option: &Option<WebSocket>,
) {
let result = move || -> Result<(), AppError> {
game_dispatch.reduce_mut(|game_store| {
let game = game_store.game.as_mut().ok_or_else(|| AppError {
error_type: common::errors::AppErrorTypes::ClientError,
message: error_messages::MISSING_GAME_REFERENCE.to_string(),
})?;
let party_id = game_store.current_party_id.ok_or_else(|| AppError {
error_type: common::errors::AppErrorTypes::ClientError,
message: error_messages::MISSING_PARTY_REFERENCE.to_string(),
})?;
let party = get_mut_party(game, party_id)?;
let focused_character = party
.characters
.get(&game_store.focused_character_id)
.ok_or_else(|| AppError {
error_type: common::errors::AppErrorTypes::ClientError,
message: error_messages::CHARACTER_NOT_FOUND.to_string(),
})?;
let focused_character_id = focused_character.entity_properties.id;
let current_targets = focused_character
.combatant_properties
.combat_action_targets
.as_ref()
.ok_or_else(|| AppError {
error_type: common::errors::AppErrorTypes::Generic,
message: error_messages::TRIED_TO_CYCLE_TARGETS_WHEN_NO_TARGETS.to_string(),
})
.cloned()?;
let ability_name = focused_character
.combatant_properties
.selected_ability_name
.as_ref()
.ok_or_else(|| AppError {
error_type: common::errors::AppErrorTypes::ClientError,
message: error_messages::MISSING_ABILITY_REFERENCE.to_string(),
})?;
// if only one targeting scheme, return early
let ability_attributes = ability_name.get_attributes();
let combat_action_properties = ability_attributes.combat_action_properties;
let new_targets = handle_cycle_combat_action_targeting_schemes(
game_store,
combat_action_properties,
current_targets,
)?;

log!(format!("sending new ability targets {:#?}", new_targets));
send_client_input(
&websocket_option,
PlayerInputs::ChangeAbilityTargets(ChangeTargetsPacket {
character_id: focused_character_id,
new_targets,
}),
);
Ok(())
})
};
let _ = result();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
use super::handle_cycle_combat_action_targets::handle_cycle_combat_action_targets;
use crate::components::websocket_manager::send_client_input::send_client_input;
use crate::store::game_store::GameStore;
use common::app_consts::error_messages;
use common::errors::AppError;
use common::game::getters::get_mut_party;
use common::packets::client_to_server::ChangeTargetsPacket;
use common::packets::client_to_server::PlayerInputs;
use common::primatives::NextOrPrevious;
use gloo::console::log;
use web_sys::WebSocket;
use yewdux::prelude::Dispatch;

pub fn handle_cycle_ability_targets(
game_dispatch: Dispatch<GameStore>,
websocket_option: &Option<WebSocket>,
direction: &NextOrPrevious,
) {
game_dispatch.reduce_mut(|game_store| {
let mut closure = move || -> Result<(), AppError> {
let game = game_store.game.as_mut().ok_or_else(|| AppError {
error_type: common::errors::AppErrorTypes::ClientError,
message: error_messages::MISSING_GAME_REFERENCE.to_string(),
})?;
let party_id = game_store.current_party_id.ok_or_else(|| AppError {
error_type: common::errors::AppErrorTypes::ClientError,
message: error_messages::MISSING_PARTY_REFERENCE.to_string(),
})?;
let party = get_mut_party(game, party_id)?;
let focused_character = party
.characters
.get(&game_store.focused_character_id)
.ok_or_else(|| AppError {
error_type: common::errors::AppErrorTypes::ClientError,
message: error_messages::CHARACTER_NOT_FOUND.to_string(),
})?;
let focused_character_id = focused_character.entity_properties.id;
let ability_name = focused_character
.combatant_properties
.selected_ability_name
.as_ref()
.ok_or_else(|| AppError {
error_type: common::errors::AppErrorTypes::ClientError,
message: error_messages::MISSING_ABILITY_REFERENCE.to_string(),
})?;
let ability_name = ability_name.clone();
let ability_attributes = ability_name.get_attributes();
let combat_action_properties = ability_attributes.combat_action_properties;
let new_targets = handle_cycle_combat_action_targets(
game_store,
combat_action_properties,
direction,
)?;

send_client_input(
&websocket_option,
PlayerInputs::ChangeAbilityTargets(ChangeTargetsPacket {
character_id: focused_character_id,
new_targets,
}),
);
Ok(())
};
let result = closure();
if result.is_ok() {
()
} else {
log!("an unhandled client error occured");
log!(format!("{:#?}", result.err()))
}
});
}
Loading

0 comments on commit 3fdf9c3

Please sign in to comment.