Diving into code, need some assistance

Game development with Board Game Arena Studio
User avatar
Madmartigan007
Posts: 10
Joined: 26 December 2020, 19:09

Diving into code, need some assistance

Post by Madmartigan007 »

Hello, sorry my by noob status.

I am using Martian Dice as an example as there are some similarities to what I need. At this point I am only trying to get the game to start without errors after the "game" does the initial of rolling 3 of the 12 starting dice. No html, no js, no css yet.

All work in php so far.

I am using the "Check Project" and narrowed the issue somewhere in my sutakku.game.php class.


/*uncommenting this fails, dont know why

if (!self::isPlayerZombie(self::getActivePlayerId())) {
self::throwDice();

$dice_thrown = self::getCurrentRoundDice();

self::notifyAllPlayers("diceThrown", '', array(
'dice' => $dice_thrown,
'is_reroll' => false,
));
*/

I tested the isPlayerZombie function by itself and it doesn't fail, so it must be in the throwDice or getCurrentRoundDice functions. Fining this very tedious and frustrating, but trying not to throw in the towel.

I haven't figured out how to debug other then trial and error rerunning. I see the PHPmyAdmin would probably be used to view the database as you are testing. That will come in handy at some point.

Current Error with that commented out above, but i need to resolve the above first.
Unexpected error: Wrong formatted data from BGA gameserver 1 (method: createGame): JSON_ERROR_SYNTAX HERE{"status":1,"data":true}

I can make myself available on Discord if anyone has time to help me move forward.

thank you
User avatar
Victoria_La
Posts: 665
Joined: 28 December 2015, 20:55

Re: Diving into code, need some assistance

Post by Victoria_La »

what project? It would be easier just to look at all code.
Like where is this code? In function like setupGame you cannot use getActivePlayer for example
User avatar
Victoria_La
Posts: 665
Joined: 28 December 2015, 20:55

Re: Diving into code, need some assistance

Post by Victoria_La »

Found it
Remove
print "HERE";
from the code, you cannot print anything from php - it all become part of response.
To debug use debug functions that go to log
User avatar
Madmartigan007
Posts: 10
Joined: 26 December 2020, 19:09

Re: Diving into code, need some assistance

Post by Madmartigan007 »

sorry, project is Sutakku.

Removed the Print "HERE" - looks like the underlying issue is still there, but that resolved getting the game to at least start. Strange that my board image reset to a very large image again, i'll look into that.

Error: Error loading file: syntax error, unexpected end of file around if(0){ /** *------ * BGA framework: © Gre

This happens when I uncomment this




/*uncommenting this fails, dont know why

if (!self::isPlayerZombie(self::getActivePlayerId())) {
self::throwDice();

$dice_thrown = self::getCurrentRoundDice();

self::notifyAllPlayers("diceThrown", '', array(
'dice' => $dice_thrown,
'is_reroll' => false,
));
*/
User avatar
Madmartigan007
Posts: 10
Joined: 26 December 2020, 19:09

Re: Diving into code, need some assistance

Post by Madmartigan007 »

Still getting error compiling

Error: Error loading file: syntax error, unexpected '=>' (T_DOUBLE_ARROW) around if(0){ /** *------ * BGA framework: © Gre


I've tried to comment out everything and cannot find what is causing this. Can someone please assist?

Game is Sutakku. So frustrated.


If I can get some help so I can log out every command I can see where this is breaking. I've read about 10 different games for examples but cannot figure out how proper logging works. I just need to get past some of this "easy" stuff and I'll get somewhere.
User avatar
Silae
Posts: 5
Joined: 16 July 2018, 07:51

Re: Diving into code, need some assistance

Post by Silae »

On line 87

Code: Select all

self::setGameStateInitialValue('end_turn_notification_sent', false);
Use numbers and not false / true, you must have encountered an error for setup.

Code: Select all

/*uncommenting this fails, dont know why

if ( !self::isPlayerZombie( self::getActivePlayerId() ) ) {

     self::throwDice();
     $dice_thrown = self::getCurrentRoundDice();

     self::notifyAllPlayers("diceThrown", '', array(
          'dice' => $dice_thrown,
          'is_reroll' => false,)
     );
}
*/
You forgot a bracket at the end of the if condition, don't know if that would solve your problem.
User avatar
Madmartigan007
Posts: 10
Joined: 26 December 2020, 19:09

Re: Diving into code, need some assistance

Post by Madmartigan007 »

Thanks for looking, checked both issues and cleaned them up, issue still exists.

Error: Error loading file: syntax error, unexpected '=>' (T_DOUBLE_ARROW) around if(0){ /** *------ * BGA framework: © Gre
User avatar
Madmartigan007
Posts: 10
Joined: 26 December 2020, 19:09

Re: Diving into code, need some assistance

Post by Madmartigan007 »

I was able to get past this error by commenting out this:

// this breaks the code
// foreach ($dice_thrown => $amount) {
// $sql_values[] = "($amount)";
// }

I believe the fix should look like this:

foreach ($dice_thrown as $amount => $amount) {
$sql_values[] = "($amount)";
}

I started to use throw new feException("Count :" . $count); to push the variables to the screen for testing. Crude, but works for the moment.

Now to go study some more PHP

thanks all
User avatar
Silae
Posts: 5
Joined: 16 July 2018, 07:51

Re: Diving into code, need some assistance

Post by Silae »

If you want to loop over of an associative array, you should do :

Code: Select all

foreach ($my_array as $key => $value){
	$sql_values[] = "(' " . $value . " ')";
}


You can concatenate like this : str_1 = string1 . $var1 . string2;
I guess you want to make a SQL query, you need to add a ' after and before the bracket.
In setupNewGame function, the same code exists for players. You can check it and use it.

Advice : check every function you write before writing another one, otherwise it would be really tedious to debug.
User avatar
Conardist
Posts: 7
Joined: 26 April 2020, 14:36

Re: Diving into code, need some assistance

Post by Conardist »

Madmartigan007 wrote: 29 December 2020, 22:49
/*uncommenting this fails, dont know why

if (!self::isPlayerZombie(self::getActivePlayerId())) {
self::throwDice();

$dice_thrown = self::getCurrentRoundDice();

self::notifyAllPlayers("diceThrown", '', array(
'dice' => $dice_thrown,
'is_reroll' => false,
));
*/
Perhaps the last section you have a comma after false but no more array info - so remove the last comma?

Like this:

self::notifyAllPlayers("diceThrown", '', array(
'dice' => $dice_thrown,
'is_reroll' => false
));
Post Reply

Return to “Developers”