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 a1ef715 + 8d78733 commit b6765a6
Show file tree
Hide file tree
Showing 39 changed files with 331 additions and 177 deletions.
21 changes: 21 additions & 0 deletions .github/workflows/deploy-dev.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: Deploy (Dev)

on:
push:
branches:
- main

jobs:
deployment:
name: Deployment
runs-on: ubuntu-latest
steps:
- name: deploy-dev
uses: appleboy/[email protected]
with:
host: ${{ secrets.JP_SERVER_HOSTNAME }}
username: ${{ secrets.JP_SERVER_USER }}
password: ${{ secrets.JP_SERVER_PASSWORD }}
script: |
cd /mafia-app/dev
./update.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export type Doomsayer = {
}

export const DOOMSAYER_GUESSES = [
"mafia", "neutral", "fiends", "cult",
"nonTown",
"jailor", "villager",
"doctor", "bodyguard", "cop", "bouncer", "engineer", "armorsmith", "steward",
"vigilante", "veteran", "marksman", "deputy", "rabblerouser",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import "./largeKiraMenu.css";

export const KIRA_GUESSES = [
"none",
"mafia", "neutral", "fiends", "cult",
"nonTown",
"jailor", "villager",
"detective", "lookout", "spy", "tracker", "philosopher", "psychic", "auditor", "snoop", "gossip", "tallyClerk",
"doctor", "bodyguard", "cop", "bouncer", "engineer", "armorsmith", "steward",
Expand Down
1 change: 1 addition & 0 deletions client/src/resources/keywords.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
"fiends": { "style": "keyword-fiends", "link": "standard/fiends"},
"any": { "style": "keyword-info"},
"none": { "style": "keyword-info"},
"nonTown": { "style": "keyword-info"},
"defense.0": { "style": "keyword-info", "link": "standard/defense"},
"defense.1": { "style": "keyword-info", "link": "standard/defense"},
"defense.2": { "style": "keyword-info", "link": "standard/defense"},
Expand Down
108 changes: 67 additions & 41 deletions client/src/resources/lang/en_us.json

Large diffs are not rendered by default.

33 changes: 16 additions & 17 deletions client/src/resources/roles.json
Original file line number Diff line number Diff line change
Expand Up @@ -835,6 +835,16 @@
{"type": "doomsayerFailed"}
]
},
"drunk": {
"mainRoleSet": "neutral",
"roleSets": ["neutral"],
"armor": false,
"aura": null,
"maxCount": null,
"roleSpecificMenu": true,
"canBeConvertedTo": [],
"chatMessages":[]
},
"chronokaiser": {
"mainRoleSet": "neutral",
"roleSets": ["neutral"],
Expand All @@ -844,9 +854,9 @@
"roleSpecificMenu": true,
"canBeConvertedTo": [],
"chatMessages":[
{"type": "chronokaiserSpeedUp", "percent": "40"},
{"type": "chronokaiserSpeedUp", "percent": "80"},
{"type": "chronokaiserSpeedUp", "percent": "160"}
{"type": "chronokaiserSpeedUp", "percent": "60"},
{"type": "chronokaiserSpeedUp", "percent": "120"},
{"type": "chronokaiserSpeedUp", "percent": "180"}
]
},
"martyr": {
Expand Down Expand Up @@ -1095,20 +1105,9 @@
"result": {
"guesses": {
"0": ["veteran","correct"],
"1": ["cult","notInGame"],
"2": ["mafia","wrongSpot"],
"3": ["mafia","correct"]
}
}
},
{
"type": "kiraResult",
"result": {
"guesses": {
"0": ["veteran","correct"],
"1": ["none","notInGame"],
"2": ["neutral","correct"],
"3": ["mafia","correct"]
"1": ["auditor","notInGame"],
"2": ["nonTown","wrongSpot"],
"3": ["nonTown","correct"]
}
}
},
Expand Down
32 changes: 32 additions & 0 deletions server/src/game/components/confused.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
use std::collections::HashSet;

use crate::game::{player::PlayerReference, Game};


#[derive(Default)]
pub struct Confused{
players: HashSet<PlayerReference>
}
impl Confused{
fn confused<'a>(game: &'a Game)->&'a Self{
&game.confused
}
fn confused_mut<'a>(game: &'a mut Game)->&'a mut Self{
&mut game.confused
}


pub fn add_player(game: &mut Game, player: PlayerReference){
let intoxicated = Self::confused_mut(game);
intoxicated.players.insert(player);
}
pub fn remove_player(game: &mut Game, player: PlayerReference){
let intoxicated = Self::confused_mut(game);
intoxicated.players.remove(&player);
}

pub fn is_intoxicated(game: &Game, player: PlayerReference)->bool{
let intoxicated = Self::confused(game);
intoxicated.players.contains(&player)
}
}
12 changes: 6 additions & 6 deletions server/src/game/components/detained.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,10 @@ impl Detained{
}
}
pub fn detained<'a>(game: &'a Game)->&'a Detained{
&game.restricted
&game.detained
}
pub fn detained_mut<'a>(game: &'a mut Game)->&'a mut Detained{
&mut game.restricted
&mut game.detained
}

pub fn add_detain(game: &mut Game, player: PlayerReference){
Expand All @@ -62,16 +62,16 @@ impl Detained{
);
}

game.restricted.players.insert(player);
game.detained.players.insert(player);
}
pub fn remove_detain(game: &mut Game, player: PlayerReference){
game.restricted.players.remove(&player);
game.detained.players.remove(&player);
}
pub fn clear_detain(game: &mut Game){
game.restricted.players.clear();
game.detained.players.clear();
}

pub fn is_detained(game: &Game, player: PlayerReference)->bool{
game.restricted.players.contains(&player)
game.detained.players.contains(&player)
}
}
4 changes: 2 additions & 2 deletions server/src/game/components/mafia_recruits.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use std::collections::HashSet;

use crate::game::{
attack_power::AttackPower, chat::ChatMessageVariant, player::PlayerReference, resolution_state::ResolutionState, role::{
attack_power::AttackPower, chat::ChatMessageVariant, player::PlayerReference, game_conclusion::GameConclusion, role::{
Priority, Role
}, role_list::RoleSet, tag::Tag, win_condition::WinCondition, Game
};
Expand Down Expand Up @@ -30,7 +30,7 @@ impl MafiaRecruits{

game.set_recruiter_recruits(recruiter_recruits);
RevealedGroupID::Mafia.add_player_to_revealed_group(game, player);
player.set_win_condition(game, WinCondition::ResolutionStateReached { win_if_any: vec![ResolutionState::Mafia].into_iter().collect() });
player.set_win_condition(game, WinCondition::GameConclusionReached { win_if_any: vec![GameConclusion::Mafia].into_iter().collect() });


for mafia in MafiaRecruits::mafia_and_recruits(game){
Expand Down
2 changes: 1 addition & 1 deletion server/src/game/components/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@ pub mod pitchfork;
pub mod poison;
pub mod revealed_group;
pub mod detained;

pub mod confused;

6 changes: 3 additions & 3 deletions server/src/game/components/pitchfork.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use std::{collections::{HashMap, HashSet}, ops::Mul};

use crate::{game::{
attack_power::AttackPower, grave::GraveKiller, phase::PhaseType, player::PlayerReference, resolution_state::ResolutionState, role::Priority, role_list::RoleSet, Game
attack_power::AttackPower, grave::GraveKiller, phase::PhaseType, player::PlayerReference, game_conclusion::GameConclusion, role::Priority, role_list::RoleSet, Game
}, packet::ToClientPacket};

#[derive(Clone)]
Expand Down Expand Up @@ -77,7 +77,7 @@ impl Pitchfork{
if
!voter.alive(game) ||
!target.alive(game) ||
!voter.win_condition(game).requires_only_this_resolution_state(ResolutionState::Town)
!voter.win_condition(game).requires_only_this_resolution_state(GameConclusion::Town)
{continue;}

let count = votes.entry(*target).or_insert(0);
Expand Down Expand Up @@ -126,7 +126,7 @@ impl Pitchfork{
}
pub fn number_of_votes_needed(game: &Game) -> u8 {
let x = PlayerReference::all_players(game).filter(|p|
p.alive(game) && p.win_condition(game).requires_only_this_resolution_state(ResolutionState::Town)
p.alive(game) && p.win_condition(game).requires_only_this_resolution_state(GameConclusion::Town)
).count().mul(2).div_ceil(3) as u8;
if x == 0 {1} else {x}
}
Expand Down
4 changes: 2 additions & 2 deletions server/src/game/components/puppeteer_marionette.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use std::collections::HashSet;

use crate::game::{
attack_power::AttackPower, chat::ChatMessageVariant, player::PlayerReference, resolution_state::ResolutionState, role::{
attack_power::AttackPower, chat::ChatMessageVariant, player::PlayerReference, game_conclusion::GameConclusion, role::{
Priority, Role
}, tag::Tag, win_condition::WinCondition, Game
};
Expand Down Expand Up @@ -30,7 +30,7 @@ impl PuppeteerMarionette{

game.set_puppeteer_marionette(puppeteer_marionette);
RevealedGroupID::Puppeteer.add_player_to_revealed_group(game, player);
player.set_win_condition(game, WinCondition::ResolutionStateReached { win_if_any: vec![ResolutionState::Fiends].into_iter().collect() });
player.set_win_condition(game, WinCondition::GameConclusionReached { win_if_any: vec![GameConclusion::Fiends].into_iter().collect() });

for fiend in PuppeteerMarionette::marionettes_and_puppeteer(game){
fiend.push_night_message(game, ChatMessageVariant::PuppeteerPlayerIsNowMarionette{player: player.index()});
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use super::{player::PlayerReference, role::Role, role_list::RoleSet, win_condition::WinCondition, Game};

#[derive(Debug, PartialEq, Eq, Clone, Hash)]
pub enum ResolutionState {
pub enum GameConclusion {
Town,
Mafia,
Cult,
Expand All @@ -13,20 +13,20 @@ pub enum ResolutionState {

Draw
}
impl ResolutionState {
pub fn all()->Vec<ResolutionState>{
impl GameConclusion {
pub fn all()->Vec<GameConclusion>{
vec![
ResolutionState::Town,
ResolutionState::Mafia,
ResolutionState::Cult,
ResolutionState::Fiends,
ResolutionState::Death,
ResolutionState::Politician,
ResolutionState::Draw
GameConclusion::Town,
GameConclusion::Mafia,
GameConclusion::Cult,
GameConclusion::Fiends,
GameConclusion::Death,
GameConclusion::Politician,
GameConclusion::Draw
]
}
///either return Some(EndGameCondition) or None (if the game is not over yet)
pub fn game_is_over(game: &Game)->Option<ResolutionState> {
pub fn game_is_over(game: &Game)->Option<GameConclusion> {

//Special wildcard case
let living_roles = PlayerReference::all_players(game).filter_map(|player|{
Expand All @@ -43,19 +43,19 @@ impl ResolutionState {

//if nobody is left to hold game hostage
if !PlayerReference::all_players(game).any(|player|player.keeps_game_running(game)){
return Some(ResolutionState::Draw);
return Some(GameConclusion::Draw);
}

//find one end game condition that everyone agrees on
for resolution in ResolutionState::all() {
for resolution in GameConclusion::all() {
//if everyone who keeps the game running agrees on this end game condition, return it
if
PlayerReference::all_players(game)
.filter(|p|p.alive(game))
.filter(|p|p.keeps_game_running(game))
.all(|p|
match p.win_condition(game){
WinCondition::ResolutionStateReached{win_if_any} => win_if_any.contains(&resolution),
WinCondition::GameConclusionReached{win_if_any} => win_if_any.contains(&resolution),
WinCondition::RoleStateWon => true,
}
)
Expand All @@ -73,11 +73,20 @@ impl ResolutionState {
/// *has the ability to change what the set of living players win conditions are until game over (convert, marionette, kill)*
/// A detective and a witch game never ends
pub fn keeps_game_running(role: Role)->bool{
if RoleSet::Neutral.get_roles().contains(&role){
false
}else{
true

match role {
Role::Drunk => true,
_ => if
RoleSet::Neutral.get_roles().contains(&role) ||
RoleSet::Minions.get_roles().contains(&role){
false
}else{
true
}
}



}
}

Expand Down
17 changes: 10 additions & 7 deletions server/src/game/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ pub mod visit;
pub mod verdict;
pub mod role_list;
pub mod settings;
pub mod resolution_state;
pub mod game_conclusion;
pub mod components;
pub mod available_buttons;
pub mod on_client_message;
Expand All @@ -21,6 +21,7 @@ pub mod win_condition;

use std::collections::HashMap;
use std::time::Duration;
use components::confused::Confused;
use components::love_linked::LoveLinked;
use components::mafia::Mafia;
use components::pitchfork::Pitchfork;
Expand Down Expand Up @@ -51,7 +52,7 @@ use self::components::{
cult::Cult,
puppeteer_marionette::PuppeteerMarionette
};
use self::resolution_state::ResolutionState;
use self::game_conclusion::GameConclusion;
use self::event::on_game_ending::OnGameEnding;
use self::event::on_grave_added::OnGraveAdded;
use self::grave::GraveReference;
Expand Down Expand Up @@ -97,7 +98,8 @@ pub struct Game {
pub poison: Poison,
pub modifiers: Modifiers,
pub revealed_groups: RevealedGroups,
pub restricted: Detained,
pub detained: Detained,
pub confused: Confused,
}

#[derive(Serialize, Debug, Clone, Copy)]
Expand Down Expand Up @@ -189,8 +191,8 @@ impl Game {
poison: Poison::default(),

revealed_groups: RevealedGroups::default(),
restricted: Detained::default(),

detained: Detained::default(),
confused: Confused::default(),
};

if !game.game_is_over() {
Expand Down Expand Up @@ -336,7 +338,7 @@ impl Game {
}

pub fn game_is_over(&self) -> bool {
if let Some(_) = ResolutionState::game_is_over(self){
if let Some(_) = GameConclusion::game_is_over(self){
true
}else{
false
Expand Down Expand Up @@ -497,7 +499,8 @@ pub mod test {

modifiers: Default::default(),
revealed_groups: Default::default(),
restricted: Default::default(),
detained: Default::default(),
confused: Default::default(),
};

//set wincons and revealed groups
Expand Down
Loading

0 comments on commit b6765a6

Please sign in to comment.