Some news regarding the action.php file

Game development with Board Game Arena Studio
Post Reply
User avatar
thoun
Posts: 1620
Joined: 10 December 2020, 22:25

Some news regarding the action.php file

Post by thoun »

With the autowired actions added to the framework, the functions in the action.php file become useless. This will remove cumbersome code from your projects :slight_smile:
Nothing mandatory, but there's no reason to not use it for you currents or future projects :slight_smile:

Read the full documentation about it here : https://en.doc.boardgamearena.com/Main_ ... autowired)

Bonus :
- you don't need to call `checkAction` at the beginning of each function, the framework handles it for you
- incitate to prefix action with `act`, similar to what already exists for `st` and `arg` functions.
- incitate to use typings in your function declaration
- `debug_*` functions don't need the chat anymore, and thus should be more flexible with different types you would need to send.

If you have comments or questions, post them here, or on the dev discord
User avatar
RicardoRix
Posts: 2541
Joined: 29 April 2012, 23:43

Re: Some news regarding the action.php file

Post by RicardoRix »

In a similar vein. Just a thought, but is it possible for BGA to handle the giveExtraTIme() every time a player takes a turn ? BGA should know when the players turn is over.

The same could be done for the manual addition to subscribe notifications in the setupNotifications. If the function starts with notif_ then add it automatically.
User avatar
thoun
Posts: 1620
Joined: 10 December 2020, 22:25

Re: Some news regarding the action.php file

Post by thoun »

RicardoRix wrote: 05 September 2024, 16:16 In a similar vein. Just a thought, but is it possible for BGA to handle the giveExtraTIme() every time a player takes a turn ? BGA should know when the players turn is over.
No we can't, for example if a player must do an action during another player's turn, we can't detect it. In games where all states are multiplayers ones, we can't know when to givez extra time, ...
RicardoRix wrote: 05 September 2024, 16:16 The same could be done for the manual addition to subscribe notifications in the setupNotifications. If the function starts with notif_ then add it automatically.
It's in my plans to autodetect notifications and make them Promise-based
User avatar
RicardoRix
Posts: 2541
Joined: 29 April 2012, 23:43

Re: Some news regarding the action.php file

Post by RicardoRix »

This is the code I use to auto subscribe.

Code: Select all

		
		var arNotifs = [];
		
		for ( var property in Object.getPrototypeOf(this) )
		{
			if (property.startsWith('notif_'))
			{
				if (!arNotifs.includes(property))
				{
					dojo.subscribe( property.substring(6), this, property );
					arNotifs.push(property);
				}
			}
		}
mscharf
Posts: 4
Joined: 14 August 2024, 21:17

Re: Some news regarding the action.php file

Post by mscharf »

Hello. I am new to development on BGA. I am trying to make an action for playing a card and this action has two parameters: an int and a string. I was trying to use the autowire actions but I am running into a problem. I am getting an error with the string parameter and I am not sure what I have done wrong. I was able to create an action with just an int param to isolate the problem as the string param. I am using the bgaPerformAction function to call the action from the JS file. This is the error I get in the console:

actPlayCard.html SyntaxError: Unexpected token '<' / <br />
<b>Warning</b>: Undefined variable $enum in <b>/var/tournoi/release/tournoi-240906-1001-gs/www/Bga/GameFramework/Actions/Types/StringParam.php</b> on line <b>33</b><br />
<br />
<b>Fatal error</b>: Uncaught TypeError: Bga\GameFramework\Actions\Types\StringParam::getValue(): Return value must be of type float, string returned in /var/tournoi/release/tournoi-240906-1001-gs/www/Bga/GameF...

I am not sure it is related to the auto wiring of actions so I am not sure if this is the best place to be asking this question. If there is a better place for these questions let me know.
User avatar
thoun
Posts: 1620
Joined: 10 December 2020, 22:25

Re: Some news regarding the action.php file

Post by thoun »

mscharf wrote: 06 September 2024, 20:45 <b>Fatal error</b>: Uncaught TypeError: Bga\GameFramework\Actions\Types\StringParam::getValue(): Return value must be of type float, string returned in /var/tournoi/release/tournoi-240906-1001-gs/www/Bga/GameF...
This sounds like a mistake on my side :roll: I'll check that on monday.

Edit: it is fixed, will be deployed on next version (wednesday).
Post Reply

Return to “Developers”