-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #6 from SnowdenWintermute/feature
0.4.0
- Loading branch information
Showing
170 changed files
with
4,617 additions
and
2,326 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 20 additions & 5 deletions
25
client/src/components/common_components/atoms/targeting_indicator.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
")} /> | ||
) | ||
} |
74 changes: 74 additions & 0 deletions
74
...s/game/action_menu/action_button_click_handlers/handle_cycle_ability_targeting_schemes.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
} |
72 changes: 72 additions & 0 deletions
72
.../components/game/action_menu/action_button_click_handlers/handle_cycle_ability_targets.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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())) | ||
} | ||
}); | ||
} |
Oops, something went wrong.