diff --git a/package-lock.json b/package-lock.json index ab2a55b..4eb13c9 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "jstris-plus", - "version": "2.5.2", + "version": "2.5.6", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "jstris-plus", - "version": "2.5.2", + "version": "2.5.6", "dependencies": { "webpack": "^5.73.0", "zip-folder": "^1.0.0" diff --git a/package.json b/package.json index 7192f5a..88f2e2c 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "jstris-plus", - "version": "2.5.6", + "version": "2.5.8", "description": "3rd party matchmaking, custom skins/sfx/gfx, and many more improvements to jstris!", "main": "index.js", "scripts": { diff --git a/src/config.js b/src/config.js index 642aa96..ecfebfd 100644 --- a/src/config.js +++ b/src/config.js @@ -33,6 +33,8 @@ var config = { ENABLE_STAT_PPB: false, ENABLE_STAT_SCORE_PACE: false, ENABLE_STAT_PC_NUMBER: false, + OVERSTACK_COLUMN: 0, + PARITY_COLUMN: 0, ENABLE_AUTOMATIC_REPLAY_CODES: false, ENABLE_CHAT_TIMESTAMPS: true, diff --git a/src/settingsModal.js b/src/settingsModal.js index d1aa414..57b9ea8 100644 --- a/src/settingsModal.js +++ b/src/settingsModal.js @@ -219,6 +219,8 @@ const generateBody = () => { createCheckbox("ENABLE_STAT_PPB", "Enable points per block stat for ultra"); createCheckbox("ENABLE_STAT_SCORE_PACE", "Enable score pace for ultra"); createCheckbox("ENABLE_STAT_PC_NUMBER", "Enable pc number indicator for pc mode"); + createSliderInput("OVERSTACK_COLUMN", "Well column for overstack counter", 0, 9, 1); + createSliderInput("PARITY_COLUMN", "Well column for local parity", -1, 9, 1); createTitle("Misc settings"); createCheckbox("ENABLE_AUTOMATIC_REPLAY_CODES", "Enable automatic replay code saving on reset"); diff --git a/src/stats.js b/src/stats.js index 4e616ea..d39683b 100644 --- a/src/stats.js +++ b/src/stats.js @@ -21,6 +21,17 @@ const updateStats = function () { } stat.row.style.display = "table-row"; var val = stat.calc(this); + if (val == undefined) return; + if (val == -999) { // key disappear the stat + stat.row.style.display = "none"; + return; + } + if (stat.name == "Overstack") { + if (val < 0) stat.row.style.color = "red"; + else if (val < 12) stat.row.style.color = "green"; + else if (val < 25) stat.row.style.color = "orange"; + else stat.row.style.color = "red"; + } stat.row.children[1].innerHTML = val; } else { stat.row.style.display = "none"; @@ -43,6 +54,23 @@ const initStat = (index, name, configVar, calc, options = {}) => { }) } +const initStat2 = (index, name, configVar, calc, options = {}) => { + let column = Config()[configVar]; + stats[index].push({ + name, + calc, + val: 0, + enabled: (column > 1 && column < 8), + initialValue: options.initialValue || 0, + enabledMode: options.enabledMode || 0, // 0 = enabled for all modes + }); + Config().onChange(configVar, val => { + for (var individualStats of stats) + var stat = individualStats.find(e => e.name == name); + stat.enabled = val; + }) +} + export const initStats = () => { const stages = document.querySelectorAll("#stage"); stages.forEach((stageEle, i) => { @@ -81,7 +109,111 @@ export const initGameStats = (stageEle, index) => { var score = game["gamedata"]["score"]; var placedBlocks = game["placedBlocks"]; return replaceBadValues(score / placedBlocks).toFixed(2); - }, { enabledMode: 5 }); + }, { enabledMode: 0 }); + + initStat2(index,"Chk_par_L", "PARITY_COLUMN", game => { + let well_index = parseInt(Config()["PARITY_COLUMN"]); + if (well_index == -1 || well_index == 0) return -999; + + let board = game["matrix"]; + + let blacks = 0; + let whites = 0; + for (let row in board) { + for (let col = 0; col < well_index; col++) { + if (row % 2 == col % 2) { + whites += board[row][col] != 0; + } else { + blacks += board[row][col] != 0; + } + } + } + for (let col = 0; col < game.deadline.length; col++) { + if (col % 2 == 0) blacks += game.deadline[col] != 0; + else whites += game.deadline[col] != 0; + } + let check = whites - blacks; + + return check; + + + }, { enabledMode: 2 }); + + initStat2(index,"Chk_par_R", "PARITY_COLUMN", game => { + let well_index = parseInt(Config()["PARITY_COLUMN"]); + if (well_index == -1 || well_index == 9) return -999; + + let board = game["matrix"]; + + let blacks = 0; + let whites = 0; + for (let row in board) { + for (let col = 9; col > well_index; col--) { + if (row % 2 == col % 2) { + whites += board[row][col] != 0; + } else { + blacks += board[row][col] != 0; + } + } + } + for (let col = 0; col < game.deadline.length; col++) { + if (col % 2 == 0) blacks += game.deadline[col] != 0; + else whites += game.deadline[col] != 0; + } + let check = whites - blacks; + + return check; + + + }, { enabledMode: 2 }); + + initStat2(index,"Overstack", "OVERSTACK_COLUMN", game => { + let well_index = parseInt(Config()["OVERSTACK_COLUMN"]); + if (well_index <= 1 || well_index >= 8) return -999; + var placedBlocks = game["placedBlocks"]; + if (placedBlocks % 7 != 0) return undefined; + + let board = game["matrix"]; + + let col = well_index + 1; + let well_height_8 = 0; + for (let row = 19; row >= 0; row--) { + if (board[row][col] == 0) { + well_height_8 = 20 - row; + break; + } + } + col = well_index - 1; + let well_height_6 = 0; + for (let row = 19; row >= 0; row--) { + if (board[row][col] == 0) { + well_height_6 = 20 - row; + break; + } + } + + let well_height = Math.max(well_height_6,well_height_8) + Math.abs(well_height_6-well_height_8) * 2 / 5; + // incredibl + // console.log(well_height_8, well_height_6, well_height); + + // now determine stacc height + + let num_minoes = 0; + for (let row = 0; row < 20; row++) { + for (let col = 0; col < 10; col++) { + if (Math.abs(col - well_index) > 2) { // define columns within 2 of the well to be part of well + if (board[row][col] != 0) num_minoes++; + } + } + } + + let overstacc = num_minoes - well_height * 5; + + // if (game["blockInHold"]!= null && game["blockInHold"].id == 2) overstacc -= 10; // if you still have the T piece in hold + + return overstacc; + + }, { enabledMode: 2 }); initStat(index,"Score pace", "ENABLE_STAT_SCORE_PACE", game => { var score = game["gamedata"]["score"];