db0 / godot-card-game-framework

A framework which comes with prepared scenes and classes to kickstart your card game, as well as a powerful scripting engine to use to provide full rules enforcement.
http://dbzer0.com/projects/godot-card-game-framework/
GNU Affero General Public License v3.0
907 stars 96 forks source link

create a game rand seed #50

Closed vmjcv closed 3 years ago

vmjcv commented 3 years ago

You merged the code prematurely, should I close that commit at that time? Anyway, I created a new merger

db0 commented 3 years ago

Ah I saw some new commits and I thought you were done >_< My bad :)

The other merge is done now, just continue on this one and tell me when you're ready.

db0 commented 3 years ago

Hm I wanted to avoid having the utilities as a singleton. Can you try to make the functions static? They should work then without being a singleton

vmjcv commented 3 years ago

I understand your idea, but godot has very poor support for static functions. It is better to use a singleton to implement the tool class. you can see this https://godotforums.org/discussion/22070/best-practice-is-to-use-a-utility-class-or-node At least now it is a good solution to use a singleton to solve the problem

vmjcv commented 3 years ago

Another solution is to save game_rng in cfc, and use const Util = preload("util.gd") in every script that needs to use the utils method. like this https://godotengine.org/qa/7374/gdscript-utility-classes

db0 commented 3 years ago

Actually developers much stronger in Godot that myself suggest you avoid singletons: https://twitter.com/NathanGDQuest/status/1330151133197819906

I would like to go that direction because I also like to avoid global variables when possible.

Unfortunately that thread you linked is not clear on what exactly the problems they encountered are. They seem to be moving almost everything out of nodes into utils, which is not what I suggest. I only want to avoid unnecessary singletons (or one single massive singleton)

Way I see it, if it doesn't work with a static function, we can always go back to a singleton, but we should give it a try at least.

db0 commented 3 years ago

Are you done with this pull request then? If so, I'll pull it and see about converting to static functions myself

vmjcv commented 3 years ago

Wait a minute, I will study it again, if it can be merged, I will tell you here