Skip to content

Commit

Permalink
new levels + fix redux state
Browse files Browse the repository at this point in the history
  • Loading branch information
HamburgJ committed Feb 1, 2025
1 parent 149ab21 commit 32cbf01
Show file tree
Hide file tree
Showing 18 changed files with 4,192 additions and 645 deletions.
182 changes: 178 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 9 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
"@types/react-dom": "^18.2.18",
"@types/react-redux": "^7.1.33",
"@types/react-router-dom": "^5.3.3",
"@types/uuid": "^10.0.0",
"ajv": "^8.12.0",
"ajv-keywords": "^5.1.0",
"bootstrap": "^5.3.2",
Expand All @@ -21,13 +22,16 @@
"react-redux": "^8.1.3",
"react-router-dom": "^6.21.0",
"react-scripts": "5.0.1",
"redux-persist": "^6.0.0",
"typescript": "^4.9.5",
"uuid": "^11.0.5",
"web-vitals": "^2.1.4"
},
"scripts": {
"start": "set PORT=3010 && react-scripts start",
"build": "react-scripts build",
"eject": "react-scripts eject"
"build": "npm run generate-game-data && react-scripts build",
"eject": "react-scripts eject",
"generate-game-data": "node scripts/generateGameData.js"
},
"eslintConfig": {
"extends": [
Expand All @@ -45,5 +49,8 @@
"last 1 firefox version",
"last 1 safari version"
]
},
"devDependencies": {
"ts-node": "^10.9.2"
}
}
34 changes: 34 additions & 0 deletions scripts/generateGameData.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
const fs = require('fs');
const path = require('path');
const { v4: uuidv4 } = require('uuid');

// Read the raw game data
const rawGameDataPath = path.join(__dirname, '../src/data/rawGameData.json');
const outputPath = path.join(__dirname, '../src/data/gameData.json');

function generateGameData() {
// Read the raw game data
const rawData = JSON.parse(fs.readFileSync(rawGameDataPath, 'utf-8'));

// Process the data and add UUIDs
const processedData = {
...rawData,
levels: rawData.levels.map(level => ({
...level,
sections: level.sections.map(section => ({
...section,
// Convert string[] to Word[]
words: section.words.map(wordText => ({
id: uuidv4(),
text: wordText
}))
}))
}))
};

// Write the processed data
fs.writeFileSync(outputPath, JSON.stringify(processedData, null, 2));
console.log('Generated game data with UUIDs at:', outputPath);
}

generateGameData();
Loading

0 comments on commit 32cbf01

Please sign in to comment.