Andrew Gazelka
07/24/2020, 6:30 AMGUI which groups together `GUIComponent`s. Each GUI has a onExit() method that is called when the user tries to exit the GUI.
• suppose I have GUI with a counter and every time a user GUIComponent is (A) clicked or the (B) user exits a GUI the counter should be increased. Once counter reached a threshold, AnEvent occurs
how should I structure this?
WAY 1 Right now I almost might think of having GUIWithCounter(val counter: Int) : BaseGUI(...) and each time (A | B) occurs we open GUIWithCounter(counter+1)
• this hard because there is a lot of logic which goes into the creation of BaseGUI … therefore, when creating it we’d want to use a factory method instead. In Kotlin, we can’t extend a class by using factory methods
WAY 2 We could have GUIWithCounter : GUI (here GUI is an interface) … we’d create an instance of BaseGUI with factory methods with desired arguments… and then use strategy pattern (delegate GUI methods to the instance of BaseGUI) .. this seems nice and dandy but here we’d need BaseGUI to be a concrete class. Therefore, we’d need a onExit() function in BaseGUI that does nothing/throws UnimplementedException (probably not an issue… but this is obv bad code. Perhaps BaseGUI would instead take a GUIEventHandler interface in the constructor and delegate onExit() to implementation defined there. Maybe just me but handlers seem like they could get messy with a bunch of object: … in code.)
WAY 3 I don’t think this is a good idea???… but we could also have a GUICounterState and have a function which creates a BaseGUI with a handler and components that increment the GUICounterState. The GUICounterState would then have a detection method to see when counter has gone over a specific threshold.
Thoughts?Hanno
07/24/2020, 7:08 AMAndrew Gazelka
07/24/2020, 7:21 AMAndrew Gazelka
07/24/2020, 7:21 AMAndrew Gazelka
07/24/2020, 7:21 AMHanno
07/24/2020, 7:35 AMAndrew Gazelka
07/24/2020, 11:23 AMAndrew Gazelka
07/24/2020, 11:38 AMinstanceof with the handlerAndrew Gazelka
07/24/2020, 11:38 AMHanno
07/24/2020, 12:50 PMJakub Pi
07/24/2020, 2:35 PMAndrew Gazelka
07/25/2020, 4:20 PMinstanceof on CaptchaHandlers to see which GUIS are Captchas. You are suggesting that I have a scheduler for each Captcha that I can subscribe to—even though it might be more efficient than having one giant one?
val currentGUI = GUIPathStore[onlinePlayer].current?.handler as? CaptchaHandler ?: continue
if (millis - currentGUI.startedTime < 30_000) continue
onlinePlayer.kickPlayer("You must solve the captcha within 30 seconds")Hanno
07/25/2020, 6:04 PMJakub Pi
07/26/2020, 3:45 AMAndrew Gazelka
07/26/2020, 3:22 PMAndrew Gazelka
07/26/2020, 3:43 PMAndrew Gazelka
07/26/2020, 3:46 PMITEM_COUNT items and only one is right. The solver must click on the right item within 30 seconds or they will get kickedHanno
07/26/2020, 3:56 PMAndrew Gazelka
07/26/2020, 4:21 PMAndrew Gazelka
07/26/2020, 4:23 PMJakub Pi
07/26/2020, 4:25 PMAndrew Gazelka
07/26/2020, 4:26 PMBroadcastChannel#asFlow() imo they are better than ReceiveChannels because there are a lot of predefined extension funcs for themAndrew Gazelka
07/26/2020, 4:27 PMAndrew Gazelka
07/26/2020, 4:27 PMJakub Pi
07/26/2020, 4:31 PMAndrew Gazelka
07/26/2020, 4:33 PMHanno
07/26/2020, 7:57 PM