I’ve encountered a massive flaw. There are way too many levels of interaction between the card and the main classes, which causes huge problems when modifying the cards. You see, adding objects to panes in JavaFX doesn’t do a lazy copy but clones the object, because it’s basically adding to a List. Which means if I modify the original object, it doesn’t change the object in the list. The things is, there are too many panes (the card is a pane itself, because you need a pane to group text and shapes together), so my code will become incredibly verbose and impossible to work with. Any suggestions?
EDIT: PLAN FAILED. The cards thing is messed up: everything has gone wrong. I didn’t foresee this problem; it’s entirely my mistake. Thankfully, I have a back-up plan that’s not nearly as interesting, unfortunately. I’ve let you all down. The cards seemed to be working initially, before I realised that the way I wove JavaFX and my own little API together was incorrect. The problem is one for which I know the reason, but I’m still unable to fix it without having to re-design the whole program. Let me do a little bit of explaining. Also, @ags1, listen up, since you’re going to be using JavaFX for Vangard too.
In JavaFX, there are different panes. These panes are where you add your GUI components, such as buttons, rectangles, circles, etc. This is the way you actually do it:
pane.getChildren().add(/whatever component you want to add/);
The getChildren() method actually returns a List, thus the add method. By now you should have spotted the inconvenience, but for the sake of those who haven’t, I’ll do a little more explaining.
When you add an object to a List, the List actually clones the object and stores that clone. So when you try and modify the original object, that clone in the List isn’t modified. Now, you might be thinking: “Hey, you can just get that List, remove the clone and put in the updated clone, right?” I actually considered that, but there are way too many lists to do it conveniently while keeping the code clean and easy for me and future modders to work with. It mightn’t seem like much of an issue, but trust me, when I build on the game later on, it’ll become hella inconvenient and I’ll go crazy running around fixing the modifications to the cards. Remember, the card itself is a pane, because that’s the only way I can group multiple GUI components together and organise them easily on the main pane.
I really don’t feel like reverting to plan B, which is a completely command-based game, as explained in the main post. It was originally my intention to release the game just like that, but hey, there’s no demand for those kind of games anymore. A shame really: those games can be fun, for me, at least. I’m not going to completely re-design the card system, because that would take months and within those months I could be doing things a lot more productive. This is a major setback: I really believed in the concept and the algorithm. I can’t deny that I learnt loads: I can now use JavaFX! And I’ve learnt never to rely too much on container classes. I’ve mentioned before that this is just a toy project of mine, and I always knew that there was a chance of it failing. Never mind: it doesn’t do to dwell on this failure.
I’m really, really sorry, though. I can’t promise that my next project won’t fail, but I promise you I won’t give up on starting new projects and taking them as far as I can.