Skip to content

Commit

Permalink
possess playerlist
Browse files Browse the repository at this point in the history
  • Loading branch information
ItsSammyM committed Dec 7, 2024
1 parent 2a6beb5 commit a683587
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 10 deletions.
3 changes: 1 addition & 2 deletions server/src/game/ability_input/saved_controllers_map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use crate::{
forfeit_vote::ForfeitVote, insider_group::InsiderGroupID,
pitchfork::Pitchfork, syndicate_gun_item::SyndicateGunItem
}, event::on_validated_ability_input_received::OnValidatedAbilityInputReceived, phase::PhaseType, player::PlayerReference, Game
}, log, packet::ToClientPacket, vec_map::VecMap, vec_set::VecSet
}, packet::ToClientPacket, vec_map::VecMap, vec_set::VecSet
};

use super::*;
Expand Down Expand Up @@ -111,7 +111,6 @@ impl SavedControllersMap{
!available_ability_data.allowed_players().contains(&actor) ||
(*saved_selection == selection && selection != AbilitySelection::new_unit())
{
log!(error "saved_controllers_map"; "Invalid input id:{:?} selection:{:?} controller_param:{:?}", id, selection, available_ability_data);
return false;
}
}
Expand Down
4 changes: 2 additions & 2 deletions server/src/game/components/night_visits.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,13 @@ impl NightVisits{
fn get_untagged_visits_from_visitor<'a>(game: &Game, visitor: PlayerReference) -> Vec<&Visit>{
game.night_visits.visits.iter()
.filter(|visit| visit.visitor == visitor)
.filter(|visit| visit.tag == VisitTag::None)
.filter(|visit| visit.tag == VisitTag::Role)
.collect()
}
fn get_untagged_visits_from_visitor_mut<'a>(game: &'a mut Game, visitor: PlayerReference) -> Vec<&'a mut Visit>{
game.night_visits.visits.iter_mut()
.filter(|visit| visit.visitor == visitor)
.filter(|visit| visit.tag == VisitTag::None)
.filter(|visit| visit.tag == VisitTag::Role)
.collect()
}
}
Expand Down
19 changes: 18 additions & 1 deletion server/src/game/player/player_helper_functions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,24 @@ impl PlayerReference{
);
},
AbilitySelection::ThreePlayerOption { .. } => {},
AbilitySelection::PlayerList { .. } => {},
AbilitySelection::PlayerList { selection } => {

let mut selection = selection.0.clone();
if let Some(first) = selection.first_mut(){
*first = possessed_into_visit.target;
}else{
selection = vec![possessed_into_visit.target];
}


SavedControllersMap::set_selection_in_controller(
game,
possessed_visit.target,
controller_id.clone(),
AbilitySelection::new_player_list(selection),
true
);
},
AbilitySelection::RoleOption { .. } => {},
AbilitySelection::TwoRoleOption { .. } => {},
AbilitySelection::TwoRoleOutlineOption { .. } => {},
Expand Down
2 changes: 1 addition & 1 deletion server/src/game/role/common_role.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ pub fn can_night_select(game: &Game, actor_ref: PlayerReference, target_ref: Pla

pub(super) fn convert_selection_to_visits(_game: &Game, actor_ref: PlayerReference, target_refs: Vec<PlayerReference>, attack: bool) -> Vec<Visit> {
if !target_refs.is_empty() {
vec![Visit::new(actor_ref, target_refs[0], attack, VisitTag::None)]
vec![Visit::new(actor_ref, target_refs[0], attack, VisitTag::Role)]
} else {
Vec::new()
}
Expand Down
2 changes: 1 addition & 1 deletion server/src/game/role/framer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ impl RoleStateImpl for Framer {
let mut new_visits = vec![];
let mut got_first = false;
for visit in actor_ref.all_night_visits_cloned(game){
if visit.tag == VisitTag::None {
if visit.tag == VisitTag::Role {
if !got_first {
new_visits.push(visit);
}
Expand Down
2 changes: 1 addition & 1 deletion server/src/game/role/reeducator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ impl RoleStateImpl for Reeducator {
.map(|mut v|{
if
!InsiderGroupID::in_same_revealed_group(game, actor_ref, v.target) &&
v.tag == VisitTag::None
v.tag == VisitTag::Role
{
v.attack = true;
}
Expand Down
4 changes: 2 additions & 2 deletions server/src/game/visit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ impl Visit {
visitor,
target,
attack,
tag: VisitTag::None,
tag: VisitTag::Role,
}
}
pub fn new(visitor: PlayerReference, target: PlayerReference, attack: bool, tag: VisitTag) -> Self {
Expand All @@ -30,6 +30,6 @@ impl Visit {
#[derive(Default, Clone, Copy, Debug, PartialEq, Eq)]
pub enum VisitTag{
#[default]
None,
Role,
SyndicateGunItem,
}

0 comments on commit a683587

Please sign in to comment.