Skip to content

Commit

Permalink
Merge branch 'main' into prod
Browse files Browse the repository at this point in the history
  • Loading branch information
ItsSammyM committed Oct 18, 2024
2 parents b6765a6 + 2158a78 commit 97f2dad
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 6 deletions.
4 changes: 2 additions & 2 deletions client/src/resources/lang/en_us.json
Original file line number Diff line number Diff line change
Expand Up @@ -1120,7 +1120,7 @@
"wiki.article.standard.confused.title:var.0": "Confuses",
"wiki.article.standard.confused.title:var.1": "Confusing",
"wiki.article.standard.confused.title:var.2": "Confuse",
"wiki.article.standard.confused.text": "The role of a player who is confused might not function correctly. Confused affects each role differently. You might not be told that you are confused.\n How this affects every role:\n - Snoop: You are always told that you can't tell\n - Detective: You are always told innocent\n - Philosopher: You are always told friends\n - Gossip: You are always told that your target didn't visit an enemy",
"wiki.article.standard.confused.text": "The role of a player who is confused might not function correctly. Confused affects each role differently. You might not be told that you are confused.\n How this affects every role:\n - Snoop: You are always told that you can't tell\n - Detective: You are always told innocent\n - Philosopher: You are always told friends\n - Gossip: You are always told that your target didn't visit an enemy\n - Psychic: You are told a random list of 3 players for your evil vision, You are told a random list of 2 players for your good vision.",
"wiki.article.standard.marionette.title": "Marionette",
"wiki.article.standard.marionette.title:var.0": "Marionettes",
"wiki.article.standard.marionette.title:var.1": "Puppet",
Expand Down Expand Up @@ -1524,7 +1524,7 @@
"wiki.article.role.martyr.attributes":"* When you have zero bullets left, you leave town and lose\n* You have a basic attack",
"wiki.article.role.martyr.extra":"* When you visit a player while you have zero bullets left you will not attack them\n* You're an ex-cultist, they rejected you because you told the truth",

"wiki.article.role.drunk.guide": "Before the game starts, whoever gets this role switches roles without being told, and they become confused until the end of the game. Their role switches to either Detective, Philosopher, Snoop, or Gossip\n This means that if you got one of those roles, you could be confused and not even know it.\n The drunk is a town loyalist, so you still win with town.",
"wiki.article.role.drunk.guide": "Before the game starts, whoever gets this role switches roles without being told, and they become confused until the end of the game. Their role switches to either Detective, Philosopher, Snoop, Gossip, or Psychic\n This means that if you got one of those roles, you could be confused and not even know it.\n The drunk is a town loyalist, so you still win with town.",
"wiki.article.role.drunk.abilities": "",
"wiki.article.role.drunk.attributes": "",
"wiki.article.role.drunk.extra": "",
Expand Down
4 changes: 2 additions & 2 deletions server/src/game/role/drunk.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ impl RoleStateImpl for Drunk {
}
}
impl Drunk{
const POSSIBLE_ROLES: [Role; 4] = [
Role::Detective, Role::Snoop, Role::Gossip, Role::Philosopher
const POSSIBLE_ROLES: [Role; 5] = [
Role::Detective, Role::Snoop, Role::Gossip, Role::Philosopher, Role::Psychic
];
}
42 changes: 40 additions & 2 deletions server/src/game/role/psychic.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use rand::seq::SliceRandom;
use serde::Serialize;

use crate::game::components::confused::Confused;
use crate::game::{attack_power::DefensePower, chat::ChatMessageVariant};
use crate::game::game_conclusion::GameConclusion;
use crate::game::player::PlayerReference;
Expand All @@ -27,10 +28,18 @@ impl RoleStateImpl for Psychic {

actor_ref.push_night_message(game, match game.day_number() % 2 {
1=>{
Psychic::get_psychic_result_evil(game, actor_ref)
if Confused::is_intoxicated(game, actor_ref){
Psychic::get_confused_result_evil(game, actor_ref)
}else{
Psychic::get_psychic_result_evil(game, actor_ref)
}
},
_=>{
Psychic::get_psychic_result_good(game, actor_ref)
if Confused::is_intoxicated(game, actor_ref){
Psychic::get_confused_result_good(game, actor_ref)
}else{
Psychic::get_psychic_result_good(game, actor_ref)
}
},
});

Expand Down Expand Up @@ -91,6 +100,35 @@ impl Psychic {
.filter(|player_ref|player_ref.alive(game) && *player_ref!=actor_ref)
.collect()
}
fn get_confused_result_evil(game: &Game, actor_ref: PlayerReference)->ChatMessageVariant{
let mut rng = rand::thread_rng();

let random_players: Vec<_> = Psychic::get_valid_players(game, actor_ref).into_iter()
.collect::<Vec<_>>()
.choose_multiple(&mut rng, 3).copied().collect();

let Some(random_player0) = random_players.get(0) else {return ChatMessageVariant::PsychicFailed};
let Some(random_player1) = random_players.get(1) else {return ChatMessageVariant::PsychicFailed};
let Some(random_player2) = random_players.get(2) else {return ChatMessageVariant::PsychicFailed};

let mut out = [random_player0, random_player1, random_player2];
out.shuffle(&mut rng);
ChatMessageVariant::PsychicEvil { players: [out[0].index(), out[1].index(), out[2].index()] }
}
fn get_confused_result_good(game: &Game, actor_ref: PlayerReference)->ChatMessageVariant{
let mut rng = rand::thread_rng();

let random_players: Vec<_> = Psychic::get_valid_players(game, actor_ref).into_iter()
.collect::<Vec<_>>()
.choose_multiple(&mut rng, 2).copied().collect();

let Some(random_player0) = random_players.get(0) else {return ChatMessageVariant::PsychicFailed};
let Some(random_player1) = random_players.get(1) else {return ChatMessageVariant::PsychicFailed};

let mut out = [random_player0, random_player1];
out.shuffle(&mut rng);
ChatMessageVariant::PsychicGood { players: [out[0].index(), out[1].index()] }
}

fn player_is_evil(game: &Game, player_ref: PlayerReference)-> bool {
!player_ref.win_condition(game).requires_only_this_resolution_state(GameConclusion::Town)
Expand Down

0 comments on commit 97f2dad

Please sign in to comment.