Skip to content

Commit

Permalink
Merge branch 'main' into generic_ability
Browse files Browse the repository at this point in the history
  • Loading branch information
ItsSammyM committed Nov 27, 2024
2 parents 76c733e + 4130c49 commit add6818
Show file tree
Hide file tree
Showing 69 changed files with 888 additions and 761 deletions.
8 changes: 8 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,22 @@
"Informants",
"inno",
"killable",
"Kira",
"Kiras",
"Mafiosos",
"Necro",
"necronomicon",
"Ojos",
"Parris",
"Playerlist",
"Poli",
"Pyrolisk",
"Pyrolisks",
"Rabblerouser",
"rbed",
"reeducator",
"repr",
"retrainer",
"Retri",
"Retributionist",
"Retributionists",
Expand All @@ -41,6 +47,8 @@
"tungstenite",
"unclicked",
"Unswappable",
"Uzumaki",
"Uzumakis",
"vigi",
"votee",
"whisperee",
Expand Down
13 changes: 4 additions & 9 deletions client/src/components/ChatMessage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -609,7 +609,7 @@ export function translateChatMessage(message: ChatMessageVariant, playerNames?:
const visitedByNobody = message.visitedBy.length === 0;

return translate("chatMessage.informantResult",
translate("chatMessage.informantResult.role", translate("role."+message.role+".name")),
translate("chatMessage.targetHasRole", translate("role."+message.role+".name")),
visitedNobody
? translate("chatMessage.informantResult.visited.nobody")
: translate("chatMessage.informantResult.visited", playerListToString(message.visited, playerNames)),
Expand Down Expand Up @@ -646,8 +646,6 @@ export function translateChatMessage(message: ChatMessageVariant, playerNames?:
return translate("chatMessage.puppeteerActionChosen."+message.action);
case "recruiterActionChosen":
return translate("chatMessage.recruiterActionChosen."+message.action);
case "erosActionChosen":
return translate("chatMessage.erosActionChosen."+message.action);
case "marksmanChosenMarks":
if(message.marks.length === 0){
return translate("chatMessage.marksmanChosenMarks.none");
Expand All @@ -659,8 +657,8 @@ export function translateChatMessage(message: ChatMessageVariant, playerNames?:
return translate("chatMessage.mediumHauntStarted", playerNames[message.medium], playerNames[message.player]);
case "youWerePossessed":
return translate("chatMessage.youWerePossessed" + (message.immune ? ".immune" : ""));
case "possessionTargetsRole":
return translate("chatMessage.possessionTargetsRole", translate("role."+message.role+".name"));
case "targetHasRole":
return translate("chatMessage.targetHasRole", translate("role."+message.role+".name"));
case "werewolfTrackingResult":
if(message.players.length === 0){
return translate(
Expand Down Expand Up @@ -1004,9 +1002,6 @@ export type ChatMessageVariant = {
} | {
type: "recruiterActionChosen",
action: RecruiterAction,
} | {
type: "erosActionChosen",
action: "loveLink" | "kill",
} | {
type: "marksmanChosenMarks",
marks: PlayerIndex[],
Expand All @@ -1016,7 +1011,7 @@ export type ChatMessageVariant = {
type: "youWerePossessed",
immune: boolean
} | {
type: "possessionTargetsRole",
type: "targetHasRole",
role: Role
} | {
type: "targetsMessage",
Expand Down
11 changes: 7 additions & 4 deletions client/src/components/Select.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ export default function Select<K extends { toString(): string}>(props: Readonly<
handleSetOpen(false);
break;
case "Enter": {
const found = [...optionsSearch.keys()].find((key) => {
const allSearchResults = [...optionsSearch.keys()].filter((key) => {
for(const search of searchString.split(" ")) {

const val = optionsSearch.get(key);
Expand All @@ -80,9 +80,12 @@ export default function Select<K extends { toString(): string}>(props: Readonly<
}
return true;
});

if(found !== undefined) {
handleOnChange(found);

//sort by length and take the first. If you type "witch" we don't want "syndicate witch"
allSearchResults.sort((a, b) => a.toString().length - b.toString().length);

if(allSearchResults[0] !== undefined) {
handleOnChange(allSearchResults[0]);
}
handleSetOpen(false);

Expand Down
57 changes: 33 additions & 24 deletions client/src/components/grave.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@

import { replaceMentions } from "..";
import { Grave } from "../game/graveState";
import { Grave, GraveInformation } from "../game/graveState";
import translate from "../game/lang";
import { sanitizePlayerMessage } from "./ChatMessage";
import StyledText from "./StyledText";
import React, { ReactElement } from "react";
import React, { ReactElement, useMemo } from "react";
import "./grave.css";
import { useGameState } from "./useHooks";

Expand All @@ -21,35 +21,44 @@ export default function GraveComponent(props: Readonly<{
playerNames?: string[]
onClick?: () => void
}>): ReactElement {


const gamePlayerNames = useGameState(
gameState => gameState.players.map(player => player.toString()),
["gamePlayers"]
)!

const playerNames = props.playerNames===undefined ? gamePlayerNames: props.playerNames;
const playerNames = props.playerNames ?? gamePlayerNames;


if(props.grave.information.type === "obscured") {
return <ObscuredGrave grave={props.grave} playerNames={playerNames}/>
} else {
return <UnobscuredGrave grave={props.grave as any} playerNames={playerNames}/>;
}
}

let deathCauseString: string;
if(props.grave.information.deathCause.type === "killers") {
deathCauseString = props.grave.information.deathCause.killers.map((killer)=>{
switch(killer.type){
case "role":
return translate("role."+killer.value+".name");
case "roleSet":
return translate(killer.value);
default:
return translate("grave.killer."+killer.type);
}
}).join(", ") + ".";
}else{
deathCauseString = translate("grave.deathCause."+props.grave.information.deathCause.type);
}
function UnobscuredGrave(props: Readonly<{
grave: Grave & { information: GraveInformation & { type: "normal" } },
playerNames: string[]
onClick?: () => void
}>): ReactElement {
const graveDeathCause = useMemo(() => {
if(props.grave.information.deathCause.type === "killers") {
return props.grave.information.deathCause.killers.map((killer)=>{
switch(killer.type){
case "role":
return translate("role."+killer.value+".name");
case "roleSet":
return translate(killer.value);
default:
return translate("grave.killer."+killer.type);
}
}).join(", ") + ".";
} else if (props.grave.information.deathCause.type === "none") {
return null;
} else {
return translate("grave.deathCause."+props.grave.information.deathCause.type);
}
}, [props.grave.information.deathCause]);

let graveRoleString = translate(`role.${props.grave.information.role}.name`);

Expand All @@ -62,15 +71,15 @@ export default function GraveComponent(props: Readonly<{
}}
>
<div><StyledText>{`${diedPhaseString+diedPhaseIcon+props.grave.dayNumber}`}</StyledText></div>
<div><StyledText>{`${playerNames[props.grave.player]+" ("+graveRoleString+")"}`}</StyledText></div>
<div><StyledText>{`${translate("killedBy")+" "+deathCauseString}`}</StyledText></div>
<div><StyledText>{`${props.playerNames[props.grave.player]+" ("+graveRoleString+")"}`}</StyledText></div>
{graveDeathCause && <div><StyledText>{`${translate("killedBy")+" "+graveDeathCause}`}</StyledText></div>}
{props.grave.information.will.length === 0 || <>
{translate("alibi")}
<div className="note-area">
<StyledText>
{sanitizePlayerMessage(replaceMentions(
props.grave.information.will,
playerNames
props.playerNames
))}
</StyledText>
</div>
Expand All @@ -82,7 +91,7 @@ export default function GraveComponent(props: Readonly<{
<StyledText>
{sanitizePlayerMessage(replaceMentions(
note,
playerNames
props.playerNames
))}
</StyledText>
</div>
Expand Down
5 changes: 5 additions & 0 deletions client/src/components/styledText.css
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,11 @@
.keyword-kira {
font-family: var(--kira-font, Arial);
}
.keyword-spiral {
font-family: var(--spiral-font, Arial);
line-height: 1em;
letter-spacing: 0.1em;
}
.keyword-trans {
background-image: linear-gradient(to left, cyan, pink, white, pink, cyan);
}
Expand Down
5 changes: 0 additions & 5 deletions client/src/game/abilityInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,6 @@ export type AbilityInput = {
} | {
type: "pitchforkVote"
selection: OnePlayerOptionSelection,
} | {
type: "hitOrderVote"
selection: OnePlayerOptionSelection,
} | {
type: "hitOrderMafioso",
} | {
type: "syndicateGunItemShoot",
input: OnePlayerOptionSelection,
Expand Down
1 change: 0 additions & 1 deletion client/src/game/gameManager.d.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,6 @@ export type GameManager = {
sendSetCounterfeiterAction(action: "forge" | "noForge"): void;
sendSetPuppeteerAction(action: PuppeteerAction): void;
sendSetRecruiterAction(action: RecruiterAction): void;
sendSetErosAction(action: "loveLink" | "kill"): void;
sendSetRoleChosen(role: Role | null): void;

sendVoteFastForwardPhase(fastForward: boolean): void;
Expand Down
6 changes: 0 additions & 6 deletions client/src/game/gameManager.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -539,12 +539,6 @@ export function createGameManager(): GameManager {
action: action
});
},
sendSetErosAction(action) {
this.server.sendPacket({
type: "setErosAction",
action: action
});
},
sendSetRoleChosen(role: Role | null) {
this.server.sendPacket({
type: "setRoleChosen",
Expand Down
8 changes: 4 additions & 4 deletions client/src/game/gameState.d.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,6 @@ export type PlayerGameState = {

forfeitVote: boolean,
pitchforkVote: PlayerIndex | null,
hitOrderVote: PlayerIndex | null,
syndicateGunItemData: {
shooter: PlayerIndex | null,
target: PlayerIndex | null,
Expand Down Expand Up @@ -149,13 +148,14 @@ export type Tag =
"puppeteerMarionette" |
"loveLinked" |
"frame" |
"forfeitVote";
"forfeitVote" |
"spiraling";

export const MODIFIERS = [
"obscuredGraves", "randomLoveLinks",
"deadCanChat", "noAbstaining",
"noDeathCause", "mafiaHitOrders",
"syndicateGunItem"
"noDeathCause",
"roleSetGraveKillers"
] as const;
export type ModifierType = (typeof MODIFIERS)[number];

Expand Down
1 change: 0 additions & 1 deletion client/src/game/gameState.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,6 @@ export function createPlayerGameState(): PlayerGameState {

forfeitVote: false,
pitchforkVote: null,
hitOrderVote: null,
syndicateGunItemData: {
shooter: null,
target: null,
Expand Down
2 changes: 1 addition & 1 deletion client/src/game/graveState.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export type GraveInformation ={
}

export type GraveDeathCause = {
type: "execution" | "leftTown" | "brokenHeart"
type: "execution" | "leftTown" | "brokenHeart" | "none"
} | {
type: "killers"
killers: GraveKiller[]
Expand Down
4 changes: 0 additions & 4 deletions client/src/game/messageListener.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -480,10 +480,6 @@ export default function messageListener(packet: ToClientPacket){
if(GAME_MANAGER.state.stateType === "game" && GAME_MANAGER.state.clientState.type === "player")
GAME_MANAGER.state.clientState.pitchforkVote = packet.player;
break;
case "yourHitOrderVote":
if(GAME_MANAGER.state.stateType === "game" && GAME_MANAGER.state.clientState.type === "player")
GAME_MANAGER.state.clientState.hitOrderVote = packet.player;
break;
case "yourSyndicateGunItemData":
if(GAME_MANAGER.state.stateType === "game" && GAME_MANAGER.state.clientState.type === "player"){
GAME_MANAGER.state.clientState.syndicateGunItemData.shooter = packet.shooter;
Expand Down
6 changes: 0 additions & 6 deletions client/src/game/packet.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -185,9 +185,6 @@ export type ToClientPacket = {
} | {
type: "yourPitchforkVote",
player: PlayerIndex | null
} | {
type: "yourHitOrderVote",
player: PlayerIndex | null
} | {
type: "yourSyndicateGunItemData",
shooter: PlayerIndex | null
Expand Down Expand Up @@ -338,9 +335,6 @@ export type ToServerPacket = {
} | {
type: "setRecruiterAction",
action: RecruiterAction
} | {
type: "setErosAction",
action: "loveLink" | "kill"
} | {
type: "setRoleChosen",
role: Role | null
Expand Down
9 changes: 6 additions & 3 deletions client/src/game/roleState.d.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ export type RoleState = {
type: "spy"
} | {
type: "pyrolisk"
} | {
type: "spiral"
} | {
type: "tracker"
} | {
Expand Down Expand Up @@ -98,9 +100,6 @@ export type RoleState = {
type: "impostor"
backup: PlayerIndex | null,
fakeRole: Role
} | {
type: "eros"
action: "loveLink" | "kill"
} | {
type: "counterfeiter",
action: "forge" | "noForge",
Expand Down Expand Up @@ -141,6 +140,10 @@ export type RoleState = {
type: "disguiser",
currentTarget: PlayerIndex | null,
disguisedRole: Role,
} | {
type: "reeducator",
convertChargesRemaining: boolean,
convertRole: Role,
} | {
type: "framer"
} | {
Expand Down
7 changes: 7 additions & 0 deletions client/src/index.css
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,12 @@
size-adjust: 120%;
}

@font-face {
font-family: game-spiral;
src: url(resources/fonts/oswald/Oswald-Regular.ttf) format('truetype');
size-adjust: 90%;
}


:root{
--background-color: #0E1026;
Expand All @@ -80,6 +86,7 @@

--game-font: game-base;
--kira-font: game-kira;
--spiral-font: game-spiral;
}

s {
Expand Down
1 change: 1 addition & 0 deletions client/src/menu/Anchor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ export default function Anchor(props: Readonly<{

document.documentElement.style.setProperty('--game-font', font);
document.documentElement.style.setProperty('--kira-font', font === `game-base` ? `game-kira` : font);
document.documentElement.style.setProperty('--spiral-font', font === `game-base` ? `game-spiral` : font);
document.documentElement.style.setProperty('--icon-factor', iconFactor);
}

Expand Down
Loading

0 comments on commit add6818

Please sign in to comment.