Skip to content

Commit 88facb6

Browse files
committed
- add fitting icon to Mystery AI
- fix error where different suspects could have the same image
1 parent 8d99f6e commit 88facb6

File tree

1 file changed

+9
-10
lines changed

1 file changed

+9
-10
lines changed

games/mystery_ai.html

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
<meta charset="UTF-8">
55
<meta name="viewport" content="width=device-width, initial-scale=1.0">
66
<title>Mystery AI: Detective</title>
7+
<link rel="icon" href="data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100'><text y='.9em' font-size='90'>🕵️</text></svg>">
78
<style>:root {
89
--primary: #1a2639;
910
--secondary: #3e4a61;
@@ -1459,26 +1460,24 @@ <h3>The Truth</h3>
14591460
caseDescription: caseData.caseDescription,
14601461
crimeSceneImage: caseData.crimeSceneImage || 0,
14611462
// Replace the current suspect mapping code with this enhanced version:
1462-
suspects: caseData.suspects.map(suspect => {
1463-
// Enhanced gender detection with a more comprehensive check
1463+
suspects: caseData.suspects.map((suspect, index) => {
1464+
// Enhanced gender detection
14641465
const isFemale =
14651466
suspect.name.includes("Ms.") ||
14661467
suspect.name.includes("Mrs.") ||
14671468
suspect.name.includes("Miss") ||
14681469
/\b(she|her|woman|girl|female|daughter|sister)\b/i.test(suspect.description) ||
14691470
/\b(she|her|woman|girl|female|daughter|sister)\b/i.test(suspect.name);
14701471

1471-
// Simplify the image selection by creating separate arrays
1472-
const maleImages = [0, 2, 4, 6]; // Even indices for male images
1473-
const femaleImages = [1, 3, 5, 7]; // Odd indices for female images
1474-
1475-
// Choose a random index from the appropriate gender array
1476-
const imageIndices = isFemale ? femaleImages : maleImages;
1477-
const randomIndex = imageIndices[Math.floor(Math.random() * imageIndices.length)];
1472+
// Create unique image mapping by assigning images sequentially based on gender
1473+
// Female suspects get odd indices (1, 3, 5, 7), male suspects get even indices (0, 2, 4, 6)
1474+
const imageIndex = isFemale ?
1475+
1 + (2 * (index % 4)) : // For females: 1, 3, 5, 7
1476+
0 + (2 * (index % 4)); // For males: 0, 2, 4, 6
14781477

14791478
return {
14801479
...suspect,
1481-
imageUrl: characterImages[randomIndex]
1480+
imageUrl: characterImages[imageIndex]
14821481
};
14831482
}),
14841483
currentSuspect: null,

0 commit comments

Comments
 (0)