pokemon-showdown icon indicating copy to clipboard operation
pokemon-showdown copied to clipboard

Uncoupling the Battle UI from the rest of the UI

Open JohnGagliardi opened this issue 3 years ago • 7 comments

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

JohnGagliardi avatar Jul 13 '21 19:07 JohnGagliardi

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.

Zarel avatar Jul 13 '21 19:07 Zarel

Sweet. So this is a preact component so I should be able to just display it and handle any errors I come across?

JohnGagliardi avatar Jul 13 '21 20:07 JohnGagliardi

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. :(

Zarel avatar Jul 13 '21 20:07 Zarel

How can I help with the dependency issues? I have seen that with my original fork attempt. Nothing seems to be imported anywhere

JohnGagliardi avatar Jul 13 '21 20:07 JohnGagliardi

Where is the "App" class?

JohnGagliardi avatar Jul 13 '21 20:07 JohnGagliardi

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

Zarel avatar Jul 13 '21 21:07 Zarel

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

Zarel avatar Jul 14 '21 17:07 Zarel

Old issue + no clear path forward, so I am closing.

monsanto avatar Jan 07 '23 03:01 monsanto