Skip to content

Commit

Permalink
warper
Browse files Browse the repository at this point in the history
  • Loading branch information
ItsSammyM committed Nov 27, 2024
1 parent 07954a5 commit da80e38
Show file tree
Hide file tree
Showing 10 changed files with 28 additions and 24 deletions.
8 changes: 4 additions & 4 deletions client/src/components/ChatMessage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -574,7 +574,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 @@ -622,8 +622,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 @@ -969,7 +969,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
2 changes: 1 addition & 1 deletion client/src/resources/lang/broken_keyboard.json
Original file line number Diff line number Diff line change
Expand Up @@ -658,7 +658,7 @@
"chatMessage.targetsMessage": "Yr trgt gt th fllwng mssg:",
"chatMessage.youWerePossessed": "Y wr pssssd.",
"chatMessage.youWerePossessed.immune": "Smn trd t pssss y bt y r mmn.",
"chatMessage.possessionTargetsRole": "Yr trgt hs th rl \\0.",
"chatMessage.targetHasRole": "Yr trgt hs th rl \\0.",
"chatMessage.targetIsPossessionImmune": "Yr trgt ws mmn t pssssn.",
"chatMessage.werewolfTrackingResult": "\\0 vstd \\1.",
"chatMessage.werewolfTrackingResult.nobody": "\\0 vstd nbdy.",
Expand Down
2 changes: 1 addition & 1 deletion client/src/resources/lang/dyslexic.json
Original file line number Diff line number Diff line change
Expand Up @@ -658,7 +658,7 @@
"chatMessage.targetsMessage": "Oury grteta tgo hte longlowfi agsemse:",
"chatMessage.youWerePossessed": "Yuo rwee sspeodsse.",
"chatMessage.youWerePossessed.immune": "Sonomee idetr to ssoesps yuo utb yuo rea mneumi.",
"chatMessage.possessionTargetsRole": "Oury grteta hsa hte elro \\0.",
"chatMessage.targetHasRole": "Oury grteta hsa hte elro \\0.",
"chatMessage.targetIsPossessionImmune": "Oury grteta swa mneumi to osnseoipss.",
"chatMessage.werewolfTrackingResult": "\\0 iitedvs \\1.",
"chatMessage.werewolfTrackingResult.nobody": "\\0 iitedvs bnyood.",
Expand Down
15 changes: 7 additions & 8 deletions client/src/resources/lang/en_us.json
Original file line number Diff line number Diff line change
Expand Up @@ -913,7 +913,7 @@
"chatMessage.targetsMessage":"Your target got the following message:",
"chatMessage.youWerePossessed":"You were possessed.",
"chatMessage.youWerePossessed.immune":"Someone tried to possess you but you are immune.",
"chatMessage.possessionTargetsRole":"Your target has the role \\0.",
"chatMessage.targetHasRole":"Your target has the role \\0.",
"chatMessage.targetIsPossessionImmune":"Your target was immune to possession.",
"chatMessage.werewolfTrackingResult":"\\0 visited \\1.",
"chatMessage.werewolfTrackingResult.nobody":"\\0 visited nobody.",
Expand All @@ -934,11 +934,10 @@
"chatMessage.godfatherBackupKilled": "The Syndicate was blocked, so \\0 attacked for the Syndicate.",
"chatMessage.silenced": "You are silenced! You must not speak, chat, point, or otherwise communicate until tomorrow!",
"chatMessage.playerRoleAndAlibi": "\\0 had the role \\1 and their alibi stated this: \\2",
"chatMessage.informantResult": "\\0. \\1. \\2.",
"chatMessage.informantResult.role": "Your target's role was \\0",
"chatMessage.informantResult.visited": "Your target visited \\0",
"chatMessage.informantResult.visited.nobody": "Your target didn't visit anybody",
"chatMessage.informantResult.visitedBy": "Your target was visited by \\0",
"chatMessage.informantResult": "\\0 \\1 \\2",
"chatMessage.informantResult.visited": "Your target visited \\0.",
"chatMessage.informantResult.visited.nobody": "Your target didn't visit anybody.",
"chatMessage.informantResult.visitedBy": "Your target was visited by \\0.",
"chatMessage.informantResult.visitedBy.nobody": "Your target was not visited by anybody.",
"chatMessage.framerResult": "\\0 was visited by town loyalists with these roles: \\1.",
"chatMessage.framerResult.nobody": "\\0 was not visited by any town loyalists.",
Expand Down Expand Up @@ -1675,8 +1674,8 @@
"wiki.article.role.kidnapper.extra":"* The Kidnapper can not kill someone on night one\n* You invisibly roleblock the player you detain, they aren't told their roleblocked\n* Players you kidnap don't see your name on your messages. The messages you send appear to be from the jailor\n* If you kidnap a cult or syndicate member, their teammates are told that player is in jail",

"wiki.article.role.warper.reminder": "Each night, select two players, all visits to the first player are redirected to the second.",
"wiki.article.role.warper.guide": "- At night, select 2 players\n - If somebody else tries to visit the first player, they instead visit the second player\n - The first player is told they are transported, but the second is not\n - You can't choose yourself as your first target, you can't warp yourself\n\n _For example_\n- If a godfather tries to attack @1, but you warped @1 to @4, then @4 will die instead, and @1 is told they are transported\n\nYou are a minion, so you should try to harm the town as much as possible while looking to benefit non-town players.\n\n",
"wiki.article.role.warper.abilities":" - Visit 2 players to warp visits from the first player to the second player\n - You can't select yourself as the first target, you cannot warp yourself",
"wiki.article.role.warper.guide": "- At night, select 2 players\n - If somebody else tries to visit the first player, they instead visit the second player\n - The first player is told they are transported, but the second is not\n - You can't choose yourself as your first target, you can't warp yourself\n- You are told the role of your first target\n\n _For example_\n- If a godfather tries to attack @1, but you warped @1 to @4, then @4 will die instead, and @1 is told they are transported\n\nYou are a minion, so you should try to harm the town as much as possible while looking to benefit non-town players.\n\n",
"wiki.article.role.warper.abilities":" - Visit 2 players to warp visits from the first player to the second player\n - You can't select yourself as the first target, you cannot warp yourself\n- You are told the role of your first target",
"wiki.article.role.warper.attributes":" - All visits to first player instead visit the second player\n - The first player you visit is told they were transported",
"wiki.article.role.warper.extra": " - Some abilities are not affected by yours due to the priority system. _For example_ You can't stop a jester from haunting their target using a transport, this depends on priorities and whether or not an ability is indirect\n* Warpers act after transporters\n* Warpers do not warp the visits of a transporter",

Expand Down
7 changes: 4 additions & 3 deletions client/src/resources/roles.json
Original file line number Diff line number Diff line change
Expand Up @@ -795,7 +795,7 @@
{"type": "targetsMessage", "message":
{"type": "sheriffResult","suspicious":true}
},
{"type": "possessionTargetsRole", "role":"detective"},
{"type": "targetHasRole", "role":"detective"},
{"type": "targetIsPossessionImmune"},
{"type": "youWerePossessed", "immune": false},
{"type": "youWerePossessed", "immune": true}
Expand Down Expand Up @@ -990,7 +990,7 @@
{"type": "targetsMessage", "message":
{"type": "sheriffResult","suspicious":true}
},
{"type": "possessionTargetsRole", "role":"detective"},
{"type": "targetHasRole", "role":"detective"},
{"type": "targetIsPossessionImmune"},
{"type": "youWerePossessed", "immune": false},
{"type": "youWerePossessed", "immune": true}
Expand Down Expand Up @@ -1020,7 +1020,8 @@
"canWriteDeathNote": false,
"canBeConvertedTo": [],
"chatMessages":[
{"type": "transported"}
{"type": "transported"},
{"type": "targetHasRole", "role":"detective"}
]
},
"kidnapper":{
Expand Down
2 changes: 1 addition & 1 deletion client/src/resources/styling/chatMessage.json
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@
"targetsMessage": "result",
"targetIsPossessionImmune": "result",
"youWerePossessed": "result",
"possessionTargetsRole": "result",
"targetHasRole": "result",
"werewolfTrackingResult": "result",
"youSurvivedAttack": "result",
"doomsayerFailed": "result",
Expand Down
2 changes: 1 addition & 1 deletion server/src/game/chat/chat_message_variant.rs
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ pub enum ChatMessageVariant {
TargetIsPossessionImmune,
YouWerePossessed { immune: bool },
TargetsMessage{message: Box<ChatMessageVariant>},
PossessionTargetsRole { role: Role },
TargetHasRole { role: Role },

#[serde(rename_all = "camelCase")]
WerewolfTrackingResult{tracked_player: PlayerIndex, players: Vec<PlayerIndex>},
Expand Down
2 changes: 1 addition & 1 deletion server/src/game/player/player_helper_functions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ impl PlayerReference{
Priority::Investigative => {
if let Some(currently_used_player) = currently_used_player {
self.push_night_message(game,
ChatMessageVariant::PossessionTargetsRole { role: currently_used_player.role(game) }
ChatMessageVariant::TargetHasRole { role: currently_used_player.role(game) }
);
}
return None;
Expand Down
1 change: 1 addition & 0 deletions server/src/game/role/warper.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ impl RoleStateImpl for Warper {


first_visit.target.push_night_message(game, ChatMessageVariant::Transported);
actor_ref.push_night_message(game, ChatMessageVariant::TargetHasRole { role: first_visit.target.role(game) });

for player_ref in PlayerReference::all_players(game){
if player_ref == actor_ref {continue;}
Expand Down

0 comments on commit da80e38

Please sign in to comment.