pokemon-showdown
pokemon-showdown copied to clipboard
Uncoupling the Battle UI from the rest of the UI
Hey, I am looking at expanding the client to a simple local game (wouldn't be any multiplayer to begin with).
From first glances it seems that the battle UI code, which I am hoping to fork, is tied in with the rest of the connection and code. Is there a place I can start looking to decouple this?
Thanks for any pointers
Hm, you might have a bit better luck with the Preact client version of the battle UI:
https://github.com/smogon/pokemon-showdown-client/blob/master/src/panel-battle.tsx
(Which has a bunch of dependencies not currently represented by the code... I'll work on fixing this at some point.)
They're both pretty coupled, though. Decoupling this one would involve intercepting BattleRoom#send
for client→server communication, and calling BattleRoom#receiveLine
for server→client communication.
Sweet. So this is a preact component so I should be able to just display it and handle any errors I come across?
Yeah, that should be possible. But like I said, because of the way dependencies are currently handled, this will likely be a lot harder than you're probably used to. That's planned to be fixed one day, but we're not there yet. :(
How can I help with the dependency issues? I have seen that with my original fork attempt. Nothing seems to be imported anywhere
Where is the "App" class?
How can I help with the dependency issues? I have seen that with my original fork attempt. Nothing seems to be imported anywhere
Yeah, the codebase was written before import were a thing in JavaScript, so it uses the older "stick everything in globals" technique. The good news is that I've started work on converting it to use imports!
The App
class is defined in:
https://github.com/smogon/pokemon-showdown-client/blob/master/src/client-main.ts
Actually, no, the App
class only exists in the old (non-Preact) client, so it's in js/client.js
:
https://github.com/smogon/pokemon-showdown-client/blob/5458936f2e66c71c55e29bac5ae079ed23e90b43/js/client.js#L386
Old issue + no clear path forward, so I am closing.