mirror of
https://github.com/monkeytypegame/monkeytype.git
synced 2025-10-24 23:07:25 +08:00
Unlock and power lever added
This commit is contained in:
parent
22403248d2
commit
5ce55d91e6
3 changed files with 55 additions and 4 deletions
|
|
@ -2034,6 +2034,24 @@ export let defaultCommands = {
|
|||
defaultValue: "",
|
||||
exec: (input) => {},
|
||||
},
|
||||
{
|
||||
id: "unlockMonkeyPower",
|
||||
display: "Unlock the MONKEY POWER!!",
|
||||
alias: "monkeypower",
|
||||
available: () => !Config.monkeyPowerUnlocked,
|
||||
exec: () => {
|
||||
UpdateConfig.setMonkeyPowerUnlocked(true);
|
||||
},
|
||||
},
|
||||
{
|
||||
id: "lockMonkeyPower",
|
||||
display: "Lock away the Monkey Power.. Its to much!",
|
||||
alias: "monkeypower",
|
||||
available: () => Config.monkeyPowerUnlocked,
|
||||
exec: () => {
|
||||
UpdateConfig.setMonkeyPowerUnlocked(false);
|
||||
},
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -122,6 +122,7 @@ let defaultConfig = {
|
|||
customBackgroundFilter: [0, 1, 1, 1, 1],
|
||||
customLayoutfluid: "qwerty#dvorak#colemak",
|
||||
monkeyPowerUnlocked: false,
|
||||
monkeyPowerLevel: 9001,
|
||||
};
|
||||
|
||||
function isConfigKeyValid(name) {
|
||||
|
|
@ -1484,6 +1485,19 @@ export function setCustomBackgroundFilter(array, nosave) {
|
|||
if (!nosave) saveToLocalStorage();
|
||||
}
|
||||
|
||||
export function setMonkeyPowerUnlocked(val, nosave) {
|
||||
if (val !== true) val = false;
|
||||
config.monkeyPowerUnlocked = val;
|
||||
if (!nosave) saveToLocalStorage();
|
||||
}
|
||||
|
||||
export function setMonkeyPowerLevel(level, nosave) {
|
||||
level = parseInt(level);
|
||||
if (![1, 2, 9001].includes(level)) level = 0;
|
||||
config.monkeyPowerLevel = level;
|
||||
if (!nosave) saveToLocalStorage();
|
||||
}
|
||||
|
||||
export function apply(configObj) {
|
||||
if (configObj == null || configObj == undefined) {
|
||||
Notifications.add("Could not apply config", -1, 3);
|
||||
|
|
@ -1568,6 +1582,8 @@ export function apply(configObj) {
|
|||
setMode(configObj.mode, true);
|
||||
setMonkey(configObj.monkey, true);
|
||||
setRepeatQuotes(configObj.repeatQuotes, true);
|
||||
setMonkeyPowerUnlocked(configObj.monkeyPowerUnlocked, true);
|
||||
setMonkeyPowerLevel(configObj.monkeyPowerLevel, true);
|
||||
|
||||
LanguagePicker.setActiveGroup();
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
import * as TestLogic from "./test-logic";
|
||||
import * as ThemeColors from "./theme-colors";
|
||||
import * as UI from "./ui";
|
||||
import Config, * as UpdateConfig from "./config";
|
||||
|
||||
/**
|
||||
* @typedef {{ x: number, y: number }} vec2
|
||||
|
|
@ -165,11 +166,23 @@ function startRender() {
|
|||
}
|
||||
}
|
||||
|
||||
function randomColor() {
|
||||
const r = Math.floor(Math.random() * 256).toString(16);
|
||||
const g = Math.floor(Math.random() * 256).toString(16);
|
||||
const b = Math.floor(Math.random() * 256).toString(16);
|
||||
return `#${r}${g}${b}`;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {boolean} good Good power or not?
|
||||
*/
|
||||
export function addPower(good) {
|
||||
if (!TestLogic.active) return;
|
||||
if (
|
||||
!TestLogic.active ||
|
||||
!Config.monkeyPowerUnlocked ||
|
||||
Config.monkeyPowerLevel === 0
|
||||
)
|
||||
return;
|
||||
|
||||
// Shake
|
||||
$("html").css("overflow", "hidden");
|
||||
|
|
@ -192,9 +205,13 @@ export function addPower(good) {
|
|||
i > 0;
|
||||
i--
|
||||
) {
|
||||
ctx.particles.push(
|
||||
createParticle(...coords, good ? ThemeColors.caret : ThemeColors.error)
|
||||
);
|
||||
const color =
|
||||
Config.monkeyPowerLevel > 1
|
||||
? randomColor()
|
||||
: good
|
||||
? ThemeColors.caret
|
||||
: ThemeColors.error;
|
||||
ctx.particles.push(createParticle(...coords, color));
|
||||
}
|
||||
|
||||
startRender();
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue