Skip to content

Commit dc0eea9

Browse files
committed
feat: Add reveal characters option
- Introduce a new debug option to reveal all characters, ignoring the "is-known" tag. - Update filtering logic to incorporate the new debug reveal characters feature. - Initialize traits and tags for new characters in NewGamePage.
1 parent c5d2d5a commit dc0eea9

File tree

3 files changed

+38
-10
lines changed

3 files changed

+38
-10
lines changed

src/common/components/root/debug-modal.tsx

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -176,14 +176,26 @@ export default function DebugModal() {
176176
onChange={(value) => {
177177
updateGameState({
178178
debug: {
179-
...gameState.debug,
180179
revealMap: value,
181180
},
182181
});
183182
}}
184183
/>
185184

186-
{/* You can add more debug options here */}
185+
<DebugOption
186+
title="Reveal Characters"
187+
description={
188+
'Reveal all characters, ignoring "is-known" tag.'
189+
}
190+
checked={gameState.debug.revealCharacters}
191+
onChange={(value) => {
192+
updateGameState({
193+
debug: {
194+
revealCharacters: value,
195+
},
196+
});
197+
}}
198+
/>
187199
</div>
188200
</CardContent>
189201
</Card>

src/common/pages/database-page.tsx

Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,8 @@ import { api } from "@/api/api";
3131
import { CharacterMenu } from "@/character/components/character-menu";
3232

3333
export function DatabasePage() {
34-
const game = useGame((state) => state);
34+
const { gameState, updateGameState } = useGame.getState();
35+
const debugRevealCharacters = gameState.debug.revealCharacters;
3536
const [charactersPage, setCharactersPage] = useState(1);
3637
const [companiesPage, setCompaniesPage] = useState(1);
3738
const [characterSearch, setCharacterSearch] = useState("");
@@ -41,12 +42,19 @@ export function DatabasePage() {
4142
const itemsPerPage = 50;
4243

4344
const filteredCharacters = useMemo(() => {
44-
return game.gameState.characters.filter((character) => {
45+
return gameState.characters.filter((character) => {
46+
if (
47+
!api.util.hasTag(character, "known:character") &&
48+
debugRevealCharacters != true
49+
) {
50+
return;
51+
}
52+
4553
const searchLower = characterSearch.toLowerCase();
4654
const fullName =
4755
`${character.first_name} ${character.last_name}`.toLowerCase();
4856
const company =
49-
game.gameState.companies
57+
gameState.companies
5058
.find((c) => c.employees.some((e) => e.characterID === character.id))
5159
?.name.toLowerCase() || "";
5260

@@ -57,10 +65,15 @@ export function DatabasePage() {
5765
company.includes(searchLower)
5866
);
5967
});
60-
}, [game.gameState.characters, game.gameState.companies, characterSearch]);
68+
}, [
69+
gameState.characters,
70+
gameState.companies,
71+
characterSearch,
72+
debugRevealCharacters,
73+
]);
6174

6275
const filteredCompanies = useMemo(() => {
63-
return game.gameState.companies.filter((company) => {
76+
return gameState.companies.filter((company) => {
6477
const searchLower = companySearch.toLowerCase();
6578
const employeeNames = company.employees
6679
.map((e) => {
@@ -74,7 +87,7 @@ export function DatabasePage() {
7487
employeeNames.includes(searchLower)
7588
);
7689
});
77-
}, [game.gameState.companies, companySearch, game.gameState]);
90+
}, [gameState.companies, companySearch, gameState]);
7891

7992
const paginateData = (data, page) => {
8093
const startIndex = (page - 1) * itemsPerPage;
@@ -168,17 +181,18 @@ export function DatabasePage() {
168181
</div>
169182
<div className="grid grid-cols-2 gap-4">
170183
{charactersData.map((character, index) => {
171-
const company = game.gameState.companies.find((c) =>
184+
const company = gameState.companies.find((c) =>
172185
c.employees.some((e) => e.characterID === character.id)
173186
);
187+
174188
return (
175189
<Card key={character.id}>
176190
<CardHeader>
177191
<div className="flex justify-between items-center">
178192
<CardTitle>{`${character.first_name} ${
179193
character.last_name
180194
}${
181-
character.id == game.gameState.player_id ? " (you)" : ""
195+
character.id == gameState.player_id ? " (you)" : ""
182196
}`}</CardTitle>
183197
<CharacterMenu character={character} />
184198
</div>

src/common/pages/new-game-page.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,8 @@ export function NewGamePage() {
125125
gender: gender,
126126
backstory: backstory,
127127
previous_job: previousJob,
128+
traits: [],
129+
tags: ["known:character"],
128130
});
129131

130132
api.generator.company.populateWorld();

0 commit comments

Comments
 (0)