Skip to content

Commit 38edc20

Browse files
committed
Cheese command
1 parent db916f4 commit 38edc20

File tree

3 files changed

+91
-2
lines changed

3 files changed

+91
-2
lines changed

server-src/commands.js

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -414,9 +414,19 @@ class CommandHandler {
414414
sendClientCommand(otherClient, "importantMessage", message);
415415
});
416416
},
417-
"<Username> <Message>[br]Makes the screen of the target empty (besides like the background color) except for a small black box, and if you click it - it slowly fades out and reveals a message, then after a second it returns the screen back to normal like nothing happened.",
417+
"<Username> <Message>[br]Makes the screen of the target empty (besides the background color) except for a small black box, and if you click it - it slowly fades out and reveals a message, then after a second it returns the screen back to normal like nothing happened.",
418418
true
419419
);
420+
addCommand(
421+
"cheese",
422+
function (args, userInfo, senderClient) {
423+
var foundClients = searchUsersByKey(args[0], senderClient);
424+
foundClients.forEach((otherClient) => {
425+
sendClientCommand(otherClient, "cheeseStorm");
426+
});
427+
},
428+
'<Username>[br]Many cheese images will show up on the users screen and each stay there for a few seconds. When the user clicks them, they go away and show "+1 cheese".'
429+
);
420430

421431
////////////////////////////////////////////////////
422432
}

src/chat/interface/commands/index.js

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -612,6 +612,85 @@ com.cheeseStorm = function () {
612612
if (!clientSettings.getSetting("JOKE_COMMANDS")) {
613613
return;
614614
}
615+
function summonCheese() {
616+
var x = Math.random() * window.innerWidth;
617+
var y = Math.random() * window.innerHeight;
618+
var cheeseDiv = elements.createElementsFromJSON([
619+
{
620+
element: "div",
621+
style: {
622+
top: y + "px",
623+
left: x + "px",
624+
position: "fixed",
625+
cursor: "pointer",
626+
transform:
627+
"translate(-50%, -50%) rotate(" + Math.random() * 360 + "deg)",
628+
transformOrigin: "center",
629+
},
630+
children: [
631+
{
632+
element: "img",
633+
src: "images/commands/cheese.png",
634+
style: {
635+
height: "32px",
636+
},
637+
},
638+
],
639+
},
640+
])[0];
641+
commandEffectsDiv.append(cheeseDiv);
642+
var startAnimation = cheeseDiv.children[0].animate(
643+
[
644+
{
645+
scale: 0,
646+
},
647+
{
648+
scale: 1,
649+
},
650+
],
651+
{
652+
easing: "ease-out",
653+
duration: 200,
654+
}
655+
);
656+
startAnimation.onfinish = function () {
657+
var timeout = setTimeout(() => {
658+
cheeseDiv.remove();
659+
}, 2500);
660+
cheeseDiv.addEventListener("click", () => {
661+
cheeseDiv.style.pointerEvents = "none";
662+
clearTimeout(timeout);
663+
elements.setInnerJSON(cheeseDiv, [
664+
{
665+
element: "span",
666+
style: {
667+
fontFamily: "PressStart2PRegular",
668+
fontSize: "10px",
669+
fontWeight: "bold",
670+
},
671+
textContent: "+1 Cheese",
672+
},
673+
]);
674+
cheeseDiv.animate(
675+
[
676+
{
677+
top: y + "px",
678+
},
679+
{
680+
top: y - 25 + "px",
681+
opacity: 0,
682+
},
683+
],
684+
{
685+
duration: 1000,
686+
easing: "ease-out",
687+
}
688+
).onfinish = () => cheeseDiv.remove();
689+
});
690+
};
691+
}
692+
var interval = setInterval(summonCheese, 120);
693+
setTimeout(() => clearInterval(interval), 7000);
615694
};
616695

617696
module.exports = com;

wpstatic/version.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{"timestamp":"1761234814866"}
1+
{"timestamp":"1761237516550"}

0 commit comments

Comments
 (0)