Skip to content

Commit

Permalink
ability to exclude all roles, auto generate factions and alignements …
Browse files Browse the repository at this point in the history
…wiki page
  • Loading branch information
ItsSammyM committed Dec 2, 2023
1 parent d501c7c commit b499c9a
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 8 deletions.
43 changes: 40 additions & 3 deletions client/src/components/WikiSearch.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import ROLES from "./../resources/roles.json";
import translate, { langText } from "../game/lang";
import "./wikiSearch.css";
import { Role, getFactionAlignmentFromRole, getFactionFromRole } from "../game/roleState.d";
import { FactionAlignment, RoleOutline, getRoleOutlineFromFactionAlignment, translateRoleOutline } from "../game/roleListState.d";
import { FACTIONS, FACTION_ALIGNMENTS, FactionAlignment, RoleOutline, getAlignmentStringFromFactionAlignment, getAllFactionAlignments, getRoleOutlineFromFactionAlignment, translateRoleOutline } from "../game/roleListState.d";
import StyledText from "../components/StyledText";
import { HistoryQueue } from "../history";
import { regEscape } from "..";
Expand All @@ -28,7 +28,7 @@ export type WikiPage =
| `role/${Role}`
| `article/${Article}`;

const ARTICLES = ["help", "roles_and_teams", "phases_and_timeline", "controls", "wills_and_notes", "visit", "all_language"] as const;
const ARTICLES = ["help", "roles_and_teams", "phases_and_timeline", "faction_alignments", "wills_and_notes", "visit", "all_language"] as const;
type Article = typeof ARTICLES[number];

const PAGES: WikiPage[] = Object.keys(ROLES).map(role => `role/${role}`)
Expand Down Expand Up @@ -136,7 +136,44 @@ export default class WikiSearch extends React.Component<WikiSearchProps, WikiSea
if (this.state.type === "page") {
if (this.state.page === "article/all_language") {
return langText;
} else {
} else if (this.state.page === "article/faction_alignments"){




let articleText = "## Factions and Alignments\n";

for(let faction of FACTIONS){

articleText+="### "+translateRoleOutline({
type: "faction",
faction: faction
})+"\n";

for(let alignment of getAllFactionAlignments(faction)){

articleText+="#### "+translateRoleOutline({
type: "factionAlignment",
factionAlignment: alignment,
})+"\n>";

for(let role in ROLES){

if(getFactionAlignmentFromRole(role as Role) === alignment){
articleText+=translateRoleOutline({
type: "exact",
role: role as Role,
})+"\n";
}
}
}
}

return <StyledText className="wiki-content-body">{articleText}</StyledText>



}else{
return <StyledText className="wiki-content-body">
{getPageText(this.state.page)}
</StyledText>;
Expand Down
15 changes: 14 additions & 1 deletion client/src/menu/lobby/lobbyExcludedRoles.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import { StateListener } from "../../game/gameManager.d";
import translate from "../../game/lang";
import RolePicker from "../../components/RolePicker";
import StyledText from "../../components/StyledText";
import ROLES from "./../../resources/roles.json";
import { Role } from "../../game/roleState.d";

interface ExcludedRolesState {
excludedRoles: RoleOutline[],
Expand Down Expand Up @@ -47,7 +49,18 @@ export default class LobbyExcludedRoles extends React.Component<{}, ExcludedRole
}
excludeRole(){
let roles = [...this.state.excludedRoles];
roles.push(this.state.roleOutline);

if(this.state.roleOutline.type !== "any"){
roles.push(this.state.roleOutline);
}else{
for(let role in ROLES){
roles.push({
type: "exact",
role: role as Role,
});
}
}

GAME_MANAGER.sendExcludedRolesPacket(roles);
}

Expand Down
9 changes: 5 additions & 4 deletions client/src/resources/lang/en_us.json
Original file line number Diff line number Diff line change
Expand Up @@ -393,21 +393,22 @@
"wiki.entry.article.404.text": "If you see this, please report this as a bug, along with what steps you took to arrive to this page.",

"wiki.entry.article.help.title":"Help",
"wiki.entry.article.help.text":"Learn how to use the wiki.",
"wiki.entry.article.help.text":"Learn how to use the wiki. This page is incomplete.",

"wiki.entry.article.roles_and_teams.title":"Roles and Teams",
"wiki.entry.article.roles_and_teams.text":"## Roles\nEvery player has a role, including you. Your role is told to you in the first chat message you received and at the top of the screen. Almost every role has an ability that can be used during the night, these abilities help you to win.\n\nThere can be multiple players with almost any role, so you might not be the only person with the role you have.\n\n### Abilities & Attributes\nAbilities are the actions that your role can take. For most roles, this is who you can target at night, but for a few special roles, you have abilities you can perform during the day.\n\nAttributes are special things about your abilities: when they fail, who you can target, etc.\n\n### Faction & Alignment\nEvery role has a faction and alignment which indicate what team you're on and what your goal is. You can see a role's faction and alignment on its wiki page. Town, Mafia, Coven, and Vampire’s goal is to be the only remaining team, and to kill every player from every other team. Neutral roles have different goals that vary depending on the role.\n\n## Teams\nThe major teams are Town, Mafia, Coven, and Vampire. For these teams, their goal is to be the only team remaining. Some special roles have their own teams as well. In most games, there will be Town and one evil team.\n\n### Town\nThe town usually has the majority when the game starts, meaning there are more players with town roles. This means that during the trial period, the town has voting power. Because of this, evil players must say that they are townies even though they are not in order to not get hanged.\n\n### Mafia, Coven, and Vampire\nThese are the evil teams. At night you can (and should) talk to your team to plan how to win. If you are asked to claim a role, It is often best to say that you are a specific town role, such as doctor or sheriff. In order to make your fake claim believable you must keep a will.",

"wiki.entry.article.phases_and_timeline.title":"Phases",
"wiki.entry.article.phases_and_timeline.text":"The game is always in a phase. Phases run in this order:\n\n### Night\nThis is when most roles use their abilities. Chat is closed at night so players can not communicate with each other. However, some roles can communicate with others at night, for example, the medium can talk to the dead, and mafia can talk with each other.\n\n### Morning\nPlayers see who died last night, their final will, and any death notes that were placed on the body. \n\n### Discussion\nPlayers discuss information they have to try to find out who the evil players are, or if they’re evil themselves, pretend to. Evil players will often try to throw out red herrings or pin the blame on someone else.\n\n### Voting\nPlayers vote to put a player on trial, but this doesn’t always mean that player is going to be killed. The players need a majority of the votes in order to put someone onto trial. If the voting phase ends before a majority is reached, it goes directly to night after. There can be a maximum of three trials during each day.\n\n### Testimony\nThis phase comes after voting only if a player was voted onto trial. The player on trial gives their testimony while everyone else stays quiet. Usually the player on trial will claim a role and post their will here.\n\nIf you have been voted for a trial, don’t give up. Even if you’re evil, you can lie your way out of getting hanged.### Judgment\nThis phase comes after testimony. Everyone votes either innocent, or guilty. If there are more guilty votes than innocent votes, the player on trial is killed. Players can also choose to abstain. The judgment period is usually how the town gets evil players killed.\n\n### Evening\nA brief period before night. If someone was voted guilty today, this is usually where they get to say their final words.\n\nWhen there are three or less players alive, each phase is half as long as it usually is.",
"wiki.entry.article.controls.title":"Controls",
"wiki.entry.article.controls.text":"You can whisper and target people.",

"wiki.entry.article.faction_alignments.title":"Factions and Alignments",
"wiki.entry.article.faction_alignments.text":"",

"wiki.entry.article.wills_and_notes.title":"Wills and Notes",
"wiki.entry.article.wills_and_notes.text":"## Wills\n\nWith any role, it is important to keep a final will. This is a document that shows all the information you claim to have and how you got it. Usually, all players are going to claim that they are a town role, so almost every will you see is a will of a town role.\n\nEach night, the sheriff will choose a player and find out if they are innocent or suspicious. (See the wiki page for “sheriff” to learn more).\nHere is a typical sheriff will:\n\n> N1: John-Innocent\nN2: Peter-Innocent\nN3: Jennifer-Suspicious\n\nThis will shows that on night 1, this sheriff found that John was innocent. On night 2, they found Peter innocent. On night 3, they found that Jennifer was suspicious.\n\nThe sheriff can post this will in order to claim, and show that Jennifer is likely evil. As an evil player, keeping a fake will is extremely important because a claim is only believable with a will alongside it.\n\n## Notes\n\nNotes are just for you, nobody else can see them. To keep organized, It is often very helpful to write down what role everyone else claimed. For example, a note page might look like this:\n\n> John - Claims doctor\nPeter - Claims sheriff\nJennifer - Never claimed, probably evil\n\n## Death notes\n\nSome roles have the ability to leave a death note when they kill another player. This note will be displayed to everyone in the game, and is a main way for evil people to communicate with the town.",

"wiki.entry.article.visit.title":"Visits",
"wiki.entry.article.visit.text":"Visits are how all roles work.",
"wiki.entry.article.visit.text":"Visits are how all roles work. This page is incomplete.",

"wiki.entry.article.all_language.title":"All Language",
"wiki.entry.article.all_language.text":"",
Expand Down

1 comment on commit b499c9a

@vercel
Copy link

@vercel vercel bot commented on b499c9a Dec 2, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

mafia-game – ./

mafia-game-itssammym.vercel.app
mafia-game-git-00x-main-itssammym.vercel.app
mafia-game.vercel.app

Please sign in to comment.