Skip to content

Commit

Permalink
Swarm emote combo fix (#511)
Browse files Browse the repository at this point in the history
* Fix for swarm combos while emotes are disabled + swapped season to "december" because of christmas emotes

* renamed IdentityFormatter to DisabledFormatter
  • Loading branch information
ftwpala authored Nov 10, 2023
1 parent 8bea8fc commit e750020
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 10 deletions.
2 changes: 1 addition & 1 deletion assets/chat/js/const.js
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ const TAGS = [
"weeb",
];

const SEASON = "june";
const SEASON = "december";

module.exports = {
KEYCODES,
Expand Down
4 changes: 2 additions & 2 deletions assets/chat/js/formatters.js
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ function moveModifierToFront(modifierList, modifierName) {
return modifierList;
}

class IdentityFormatter {
class DisabledFormatter {
format(chat, str, message = null) {
return str;
}
Expand Down Expand Up @@ -750,7 +750,7 @@ export {
EmoteFormatter,
GreenTextFormatter,
HtmlTextFormatter,
IdentityFormatter,
DisabledFormatter as IdentityFormatter,
MentionedUserFormatter,
RawEmoteFormatter,
SpoilerFormatter,
Expand Down
16 changes: 9 additions & 7 deletions assets/chat/js/messages.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
HtmlTextFormatter,
MentionedUserFormatter,
UrlFormatter,
IdentityFormatter,
DisabledFormatter,
CodeFormatter,
SpoilerFormatter
} from "./formatters";
Expand Down Expand Up @@ -36,9 +36,9 @@ formatters.set("green", new GreenTextFormatter());

function setFormattersFromSettings(settings) {
if (!settings.get("formatter-emote"))
formatters.set("emote", new IdentityFormatter());
formatters.set("emote", new DisabledFormatter());
if (!settings.get("formatter-green"))
formatters.set("green", new IdentityFormatter());
formatters.set("green", new DisabledFormatter());
}

function buildMessageTxt(chat, message) {
Expand Down Expand Up @@ -440,9 +440,11 @@ function ChatEmoteMessageCount(message) {
if (!message._combo) console.error("no combo", message._combo);
message._combo.attr("class", "chat-combo" + stepClass);

// TODO: currently this does not get hit on "2x" combos, and requires a hack to get swarm emotes to work properly.
// consider finding the reason why it isn't going into this function on "2x" combos and swarm emote hack in the "afterRender" function in the ChatEmoteMessage class
if (
SWARM_EMOTES.includes(message.message.split(":")[0]) &&
message.emotecount <= 6
message.emotecount <= 6 && !(formatters.get("emote") instanceof DisabledFormatter)
) {
message._text.attr("class", message.message.split(":")[0] + "Combo");

Expand All @@ -452,7 +454,7 @@ function ChatEmoteMessageCount(message) {
"</span> </span> </span>";
let html = "";

// for every combo attatch 1 emote
// for every combo attach 1 emote
for (let i = 0; i < message.emotecount; i++) {
html += temp;
}
Expand Down Expand Up @@ -494,8 +496,8 @@ class ChatEmoteMessage extends ChatMessage {
" ",
this._combo_txt
);

if (SWARM_EMOTES.includes(this.message.split(":")[0])) {
// this fixes a bug when an emote hits "2x" it does not enter the ChatEmoteMessageCount function until 3x
if (SWARM_EMOTES.includes(this.message.split(":")[0]) && !(formatters.get("emote") instanceof DisabledFormatter)) {
this._text.attr("class", this.message.split(":")[0] + "Combo");
this._text.append(
`${formatters.get("emote").format(chat, this.message, this)}`
Expand Down

0 comments on commit e750020

Please sign in to comment.