Page 1 of 1

Game specific notepad stored in player db?

Posted: 05 December 2022, 21:29
by cranflavin
I've been working on the game Alchemists, and there is a notepad in the game that users use for the deduction puzzle. I'd like players to be able to modify this notepad at any time and store it in the player SQL table. However, the only way I can see to allow players to modify this at any time is to make all my game states multi-active states, so all players can always perform the action (which is kinda gross). Is there an alternative mechanism by which a player can do an action at all times, even if they aren't the active player? Or is there another obvious mechanism for this that I'm missing?

Re: Game specific notepad stored in player db?

Posted: 05 December 2022, 22:37
by SwHawk
You don't specifically have to make all states multipleactievplayer, you can just allow an out of turn action when the player updates their deduction grid. You would obviously need to use checkPossibleAction instead of checkAction.

Re: Game specific notepad stored in player db?

Posted: 05 December 2022, 22:48
by cranflavin
Ah thanks, that makes sense. Missed that in the docs.

Re: Game specific notepad stored in player db?

Posted: 07 December 2022, 10:59
by basilebor
HI,
I had the same problem for an action in the game I dev.
I wanna player be able to send a forfeit request any time of the game, even if they are not active player.
I didnt want to change all my states to multi-active states just for this.

From the client javascript non active player I have a button that do an ajax call to the server to store data in the DB even if player is not active.
I do just a
➡ js fle :
this.ajaxcall("/mygame/mygame/writeText.html", { text : myText}, this, function( result ) {}, function( is_error) {});

➡ myGame.action.php
public function writeText()
{
self::setAjaxMode();
$text = self::getArg( "text", AT_alphanum, true );
$this->game->writeTextInDb($text);
self::ajaxResponse( );
}

➡ mygame.game.php
function writeTextInDb($text)
{
$sql = "UPDATE database etc
}

Player dont need to be active to do these action