HoeenCoder / Wavelength

The github repository for the Wavelength server on Pokemon Showdown.
http://wavelength.psim.us/
Other
10 stars 46 forks source link

The future of the "WL" global utility variable #238

Open HoeenCoder opened 5 years ago

HoeenCoder commented 5 years ago

Alot of side servers, including Wavelength, have a global varaible that acts as a holder for utility functions. This can be useful, though these variables are also used for other things at times that could be self contained in their chat-plugin files.

What I want to do with "WL" in this refactor is either A. replace it with a "Tools" global for utility functions that are used all over the server only or B. merge these utilities into Chat (or another appropriate variable like Dex).

You may be wondering, "Why not use Dex if we aren't going to use WL anymore?". Dex is more for sim ("pokedex") based tools, Dex.getTemplate gets a pokemon template, Dex.getAbility gets an ability, ect. Things like WL.nameColor don't make much sense there, especially since Dex is loaded in the battle processes and nameColor isn't used there (waste of memory).

I'm open to other suggestions and ideas, please reply and let me know what you think we should do.

Mystifi commented 5 years ago

@HoeenCoder I think you could still have a central WL file with all of the utilities, but require it from chat.js similarly to how the link regex and chat formatters are included within the Chat global:

Chat.formatText = require('./chat-formatter').formatText;
Chat.linkRegex = require('./chat-formatter').linkRegex;

As for a filename, maybe chat-wl.js to show that it hosts functions/classes/objects/et cetera unique to Wavelength?

Mystifi commented 5 years ago

This would also mean all extraneous WL functions for various plugins would be consolidated into one file rather than a global object continuously being extended; benefits of this include the assurance that all WL functions are present in one place (in case a plugin is deleted) so that no one's running around like a chicken with their head cut off wondering why other plugin files have broken.

EDIT: tells.js should be consolidated into the proposed chat-wl.js. I'm debating on whether or not it's worth it to also include github.js there as well, but I'm not sure how githubhook handles restarting the webhook. Will the old one be closed and a new listener opened, or will another listener open up? It would require inspection into the source if it's public.

HoeenCoder commented 5 years ago

Thanks for the suggestions @Mystifi, thats not a bad option at all. Am also unsure about gihubhook, I or someone else will have to research it later. I would probably call it chat-tools.js or something like that rather than being a server-specific name. If your interested in discussing the refactor in real time with the other devs, feel free to join the discord and I'll give you the developer role so you get access. https://discord.gg/H9b6bNn

Mystifi commented 5 years ago

I'll be joining as kirisame#0993 as that's my new account (as a heads-up).