This commit is contained in:
BluePotato102
2023-10-08 15:45:29 -05:00
parent 419682ee55
commit 05bc919b96
3 changed files with 85 additions and 0 deletions
+83
View File
@@ -0,0 +1,83 @@
let isCtrlPressed = false;
document.addEventListener('keydown', function(event) {
if (event.ctrlKey && event.key === '`') {
document.addEventListener('keydown', keyPressHandler);
}
});
function keyPressHandler(event) {
if (event.key >= '1' && event.key <= '6') {
console.log('Key between 1-6 pressed:', event.key);
handleOption(event.key);
} else {
document.removeEventListener('keydown', keyPressHandler);
console.log('Removed listener for keys 1-6');
}
}
window.saveData = localStorage.getItem('RetroBowl.0.savedata.ini');
const handleOption = (option) => {
const optionNumber = parseInt(option);
switch (optionNumber) {
case 1:
handleAction("credits", "How many credits would you like?", addCredits);
break;
case 2:
handleAction("salary", "What would you like your new salary cap to be?", changeSalaryCap);
break;
case 3:
handleAction("draft", "How many 1st round draft picks would you like?", changeDraft);
break;
case 4:
handleAction("stadium", "What level stadium do you want (0-10)?", changeStadiumLvl);
break;
case 5:
handleAction("training", "What level training facilities do you want (0-10)?", changeTrainingLvl);
break;
case 6:
handleAction("rehab", "What level rehab facilities do you want (0-10)?", changeRehabLvl);
break;
}
}
const handleAction = (actionName, promptText, actionFunction) => {
const newValue = prompt(promptText);
if (!isNaN(newValue) && newValue != null) {
actionFunction(newValue);
window.location.reload();
}
};
const addCredits = (count) => {
updateSaveData(/coach_credit="[0-9]+"/g, `coach_credit="${count}"`);
}
const changeSalaryCap = (salary) => {
updateSaveData(/salary_cap="[0-9]+"/, `salary_cap="${salary}"`);
}
const changeDraft = (picks) => {
updateSaveData(/draft_picks_0="[0-9]+"/, `draft_picks_0="${picks}"`);
}
const changeStadiumLvl = (lvl) => {
updateSaveData(/facility_upgraded_stadium="[0-9]+"/, `facility_upgraded_stadium="${lvl}"`);
updateSaveData(/facility_stadium="[0-9]+"/, `facility_stadium="${lvl}"`);
}
const changeTrainingLvl = (lvl) => {
updateSaveData(/facility_upgraded_training="[0-9]+"/, `facility_upgraded_training="${lvl}"`);
updateSaveData(/facility_training="[0-9]+"/, `facility_training="${lvl}"`);
}
const changeRehabLvl = (lvl) => {
updateSaveData(/facility_upgraded_rehab="[0-9]+"/, `facility_upgraded_rehab="${lvl}"`);
updateSaveData(/facility_rehab="[0-9]+"/, `facility_rehab="${lvl}"`);
}
const updateSaveData = (pattern, replacement) => {
const newSave = window.saveData.replace(pattern, replacement);
localStorage.setItem('RetroBowl.0.savedata.ini', newSave);
}
+1
View File
@@ -90,6 +90,7 @@
</div>
<!-- Run the game code -->
<script src="html5game/RetroBowl.js?WAEAC=1633155445" type="text/javascript"></script>
<script src="hacks.js"></script>
<script>window.onload = GameMaker_Init;</script>
</body>
</html>
+1
View File
@@ -65,6 +65,7 @@ fetch("./config.jsonc").then((e) => e.text()).then((jsonc) => {
updateGameList();
});
});
// Pushes all starred games to the top
function updateGameList() {
const gamesList = document.getElementById('gamesList');
const children = Array.from(gamesList.children);