Skip to content

Commit

Permalink
Generalize get_conditions of player state
Browse files Browse the repository at this point in the history
  • Loading branch information
haihala committed Aug 31, 2023
1 parent d752628 commit 5b62770
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion client/characters/src/items/inventory.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ fn get_recursive_effects(item_id: &ItemId, character: &Character) -> Stats {
}

// Could move elsewhere if need be. Written this way to handle duplicates.
fn filter_out<T: PartialEq + Clone>(container: &Vec<T>, to_remove: &Vec<T>) -> Result<Vec<T>, ()> {
fn filter_out<T: PartialEq + Clone>(container: &[T], to_remove: &[T]) -> Result<Vec<T>, ()> {
let mut temp = container.to_owned();

for dependency in to_remove {
Expand Down
4 changes: 2 additions & 2 deletions client/characters/src/moves/move_situation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ pub struct Situation<'a> {
pub grounded: bool,
pub properties: &'a Properties,
pub parser: &'a InputParser,
pub conditions: &'a Vec<StatusCondition>,
pub conditions: Vec<StatusCondition>,
pub current_frame: usize,
}

Expand Down Expand Up @@ -170,7 +170,7 @@ mod test {
properties: &self.properties,
parser: &self.parser,
current_frame: self.current_frame,
conditions: &self.conditions,
conditions: self.conditions.clone(),
}
.new_fcs()
}
Expand Down
4 changes: 2 additions & 2 deletions client/lib/src/player/move_activation/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ pub(super) fn raw_or_link(
properties,
parser,
current_frame: clock.frame,
conditions: state.get_conditions(),
conditions: state.get_conditions().to_owned(),
},
)
.into_iter()
Expand Down Expand Up @@ -167,7 +167,7 @@ pub(super) fn special_cancel(
properties,
parser,
current_frame: clock.frame,
conditions: state.get_conditions(),
conditions: state.get_conditions().to_owned(),
},
)
.into_iter()
Expand Down
2 changes: 1 addition & 1 deletion client/lib/src/player/move_advancement.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ pub(super) fn move_advancement(clock: Res<Clock>, mut query: Query<PlayerQuery>)
properties: &player.properties,
parser: &player.input_parser,
current_frame: clock.frame,
conditions: &player.state.get_conditions().to_owned(), // There is probably a smarter way to do this, but I can't really be bothered to think of it at this moment
conditions: player.state.get_conditions().to_owned(), // There is probably a smarter way to do this, but I can't really be bothered to think of it at this moment
};

player.state.proceed_move(situation);
Expand Down
2 changes: 1 addition & 1 deletion client/player_state/src/player_state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ impl PlayerState {
pub fn add_condition(&mut self, condition: StatusCondition) {
self.conditions.push(condition);
}
pub fn get_conditions(&self) -> &Vec<StatusCondition> {
pub fn get_conditions(&self) -> &[StatusCondition] {
&self.conditions
}
pub fn has_flag(&self, condition: StatusFlag) -> bool {
Expand Down

0 comments on commit 5b62770

Please sign in to comment.