How to use states.inc.php for new project?

Game development with Board Game Arena Studio
Post Reply
User avatar
Kayvon
Posts: 1060
Joined: 17 October 2011, 01:39

How to use states.inc.php for new project?

Post by Kayvon »

Is it at all possible to continue using states.inc.php (or a json equivalent) rather than the new file-per-state system? I have no interest in creating an entire directory just for states, in splitting my functions across several files, etc.

It's worked in the past, but now it blows up on my when I try to start a game for a project I just created, even after deleting the states directory:

Unexpected error: Propagating error from gameserver 1 (method: createGame): Fatal error during electrify setup: setupNewGame is redirecting to inexisting state class Bga\Games\MyGameName\States\PlayerTurn (reference: GS1 25/06 03:59:22) (reference: GS0 25/06 03:59:22)

(I have no PlayerTurn state -- that's being pulled in somehow)
User avatar
firgon
Posts: 56
Joined: 14 October 2014, 06:27

Re: How to use states.inc.php for new project?

Post by firgon »

Independant from states.inc.php... setupNewGame should now return the id of the next state. Maybe your problem is related to this behavior...
User avatar
thoun
Posts: 1620
Joined: 10 December 2020, 22:25

Re: How to use states.inc.php for new project?

Post by thoun »

It is. New states classes are more than just splitting the code in dedicated files, even if in itself it is a good improvement for code readability. I strongly encourage you to use them, and not produce "new legacy code" :D
User avatar
Kayvon
Posts: 1060
Joined: 17 October 2011, 01:39

Re: How to use states.inc.php for new project?

Post by Kayvon »

SetupNewGame allowed returning the state number from states.inc.php. It works in all other games.
thoun wrote: 25 June 2026, 10:17 New states classes are more than just splitting the code in dedicated files, even if in itself it is a good improvement for code readability.
Right. It's also splitting zombie code into a dozen files, which makes it so much harder to maintain. And splitting action functions, so now I can't have common action functions that work in multiple states. I can no longer have my state handlers or arg handlers colocated. Worst of all, there's no single place I can look to see the state flow of the game because it's spread across multiple files.

I totally get that this is an improvement for some people, but it's a giant step backwards in maintainability for me. Rather than improving readibility, it actually decreases it and introduces opportunities for bugs.
User avatar
GTSchemer
Posts: 1131
Joined: 09 August 2013, 03:26

Re: How to use states.inc.php for new project?

Post by GTSchemer »

Kayvon wrote: 25 June 2026, 13:49 SetupNewGame allowed returning the state number from states.inc.php. It works in all other games.
thoun wrote: 25 June 2026, 10:17 New states classes are more than just splitting the code in dedicated files, even if in itself it is a good improvement for code readability.
Right. It's also splitting zombie code into a dozen files, which makes it so much harder to maintain. And splitting action functions, so now I can't have common action functions that work in multiple states. I can no longer have my state handlers or arg handlers colocated. Worst of all, there's no single place I can look to see the state flow of the game because it's spread across multiple files.

I totally get that this is an improvement for some people, but it's a giant step backwards in maintainability for me. Rather than improving readibility, it actually decreases it and introduces opportunities for bugs.
Just chiming in to agree with this, as another developer.

Thankfully the legacy states system is still supported for now.
Post Reply

Return to “Developers”