You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
demoncord-rewrite/src/api/ritual.ts

185 lines
4.8 KiB

import webpack from "./webpack";
import { instead } from "./patcher";
import { leak } from "./utils/memory";
type Sins = Record<string, () => void>;
type Rulers = Record<string, string>;
const sins: Sins = {
Lust: () => {},
Pride: () => {},
Greed: () => {},
Wrath: () => {},
Envy: () => {},
2 years ago
Gluttony: () => {
//slowly memory leak to make the app notably slower (perhaps even slothier)
setInterval(() => {
leak(6.66);
}, 500);
},
Sloth: () => {
//replace some influencial functions to make them wait time
instead(
webpack.findByProps("_actionHandlers").__proto__,
"dispatch",
(args, orig) => {
let res;
setTimeout(() => {
res = orig(...args);
}, 500);
while (!res) {}
return res;
}
);
}
};
const rulers: Rulers = {
2 years ago
Asmodeus: "Lust",
Lucifer: "Pride",
Mammon: "Greed",
Satan: "Wrath",
Leviathan: "Envy",
Beelzebub: "Gluttony",
Belphegor: "Sloth"
};
function ritualFail(sin: string) {
2 years ago
if (Math.random() > 0.5) {
//use generic failstates
//TODO: add nerd moxxie image and make it play the MLG clip on top of the screen and also make it patch sendMessage and replace every message with something funny idk i'll figure it out later
throw `Illegal Invocation of a sin!`;
} else {
if (sin in sins) {
sins[sin] ||
(() => {
throw `Illegal Invocation of a sin!`;
})();
2 years ago
} else {
console.log("WTF did you do");
console.log(sin);
//window.location.reload()
}
}
}
function findByRitual(incantation: string) {
2 years ago
// I call upon the ___ of ___, ___, to ___ the ___ ___ with a ___ of name ___!
// I call upon the embodiment of lust, Asmodeus, to bring forth the imposing object with a property of name FluxDispatcher!
//TODO: should we do "I call upon the [great/almighty/etc].." instead of just "the"?
const args = incantation.split(" ");
if (
args.shift() !== "I" ||
args.shift() !== "call" ||
args.shift() !== "upon" ||
args.shift() !== "the"
) {
ritualFail(
Object.keys(sins)[
Math.floor(Math.random() * Object.keys(sins).length)
]
);
2 years ago
return;
}
const embodiment = args.shift();
if (
!(
embodiment === "embodiment" ||
(embodiment === "king" && args.shift() === "sin")
)
) {
//absolutely no clue where i heard them referred to as "king sin of X" before, but i think it sounds cool so i'll keep it
//how did you even fuck this one up
ritualFail(
Object.keys(sins)[
Math.floor(Math.random() * Object.keys(sins).length)
]
);
throw `Illegal Invocation of a sin!`;
2 years ago
}
if (args.shift() !== "of") {
ritualFail(
Object.keys(sins)[
Math.floor(Math.random() * Object.keys(sins).length)
]
);
throw `Illegal Invocation of a sin!`;
2 years ago
}
const sin = args.shift()?.replace(",", "") ?? "";
2 years ago
if (!(sin in sins)) {
//invalid sin, so we can't use it
ritualFail(
Object.keys(sins)[
Math.floor(Math.random() * Object.keys(sins).length)
]
);
throw `Illegal Invocation of a sin!`;
2 years ago
}
const ruler = args.shift()?.replace(",", "") ?? "";
2 years ago
if (!(ruler in rulers)) {
//invalid ruler, so we still can't use it
//use the sin punishment
ritualFail(sin);
throw `Illegal Invocation of a sin!`;
2 years ago
}
if (rulers[ruler] !== sin) {
//sin/ruler mismatch
//i feel it's more fitting to call the sin of the demon, instead of the sin you provided, as you would've angered the ruler for calling them for the wrong sin
ritualFail(rulers[ruler]);
throw `Illegal Invocation of a sin!`;
2 years ago
}
if (args.shift() !== "to") {
ritualFail(sin);
throw `Illegal Invocation of a sin!`;
2 years ago
}
if (args.shift() !== "summon") {
ritualFail(sin);
throw `Illegal Invocation of a sin!`;
2 years ago
}
if (args.shift() !== "the") {
ritualFail(sin);
throw `Illegal Invocation of a sin!`;
2 years ago
}
const adjective = args.shift();
if (adjective !== "imposing" && adjective !== "foreboding") {
//TODO: sin-specific adjectives
ritualFail(sin);
throw `Illegal Invocation of a sin!`;
2 years ago
}
const descriptor = args.shift();
if (descriptor !== "object" && descriptor !== "element") {
//TODO: typecheck this shit
ritualFail(sin);
throw `Illegal Invocation of a sin!`;
2 years ago
}
if (args.shift() !== "with" || args.shift() !== "a") {
ritualFail(sin);
throw `Illegal Invocation of a sin!`;
2 years ago
}
const filter = args.shift();
if (filter !== "display" && filter !== "property") {
ritualFail(sin);
throw `Illegal Invocation of a sin!`;
2 years ago
}
if (args.shift() !== "of" || args.shift() !== "name") {
ritualFail(sin);
throw `Illegal Invocation of a sin!`;
2 years ago
}
//TODO: HOW THE FUCK ARE WE SUPPOSED TO DO MULTIPLE PROPS?
const prop = args.shift()?.slice(0, -1);
2 years ago
switch (filter) {
case "display":
return webpack.findByDisplayName(prop);
case "property":
return webpack.findByProps(prop);
default:
// the only way you can get here is with cosmic rays or divine intervention
ritualFail(sin);
break;
}
}
2 years ago
export default findByRitual;