Page 2 of 2

Re: Diving into code, need some assistance

Posted: 02 January 2021, 15:20
by Tisaac
Conardist wrote: 02 January 2021, 09:40
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
));
No, that's totally valid syntax in most languages now, and very convenient .

Re: Diving into code, need some assistance

Posted: 02 January 2021, 17:39
by Madmartigan007
Game: Sutakku

Hello all, progress is steady and I am looking to try to take this to the next step.
I finished 75% of the PHP main class for basic stuff. Game starts with an autoroll of 3 dice out of 12. I have that working and data stored in the database. Next is for user to "select" 2 or 3 of these dice. I believe took care of the php database side. I can really use some help trying to get a simple visual of the 3 dice that the user can select from.

I have the sprites created and the css based on examples. I have the board showing on the screen.

I am trying to figure out the steps so that the user gets prompted to select some dice and continue. All actions are created. Been looking at many examples, just need a little push. If anyone has a sometime and can send me a message to possibly just discuss it on discord or here it would be appreciated.

I'm currently studying the BGA cookbook

Re: Diving into code, need some assistance

Posted: 23 February 2021, 19:03
by KuWizard
Hi! I am a developer of the Martian Dice code you use.
Please be aware that this is my first project at BGA and I am not proficient at all at writing clean and concise code :)
But anyway, I'm flattered to have a project to be used as a base even if this is a coincidence :)

Re: Diving into code, need some assistance

Posted: 25 February 2021, 03:39
by AmadanNaBriona
Madmartigan007 wrote: 02 January 2021, 17:39
I am trying to figure out the steps so that the user gets prompted to select some dice and continue. All actions are created. Been looking at many examples, just need a little push. If anyone has a sometime and can send me a message to possibly just discuss it on discord or here it would be appreciated.
One way to do it:

in your js file:

Code: Select all

        onUpdateActionButtons: function( stateName, args )
        {
                      
            if( this.isCurrentPlayerActive() ) {
                switch( stateName ) {
 
                 case 'selectDice':
                    this.addDiceToSelect();
                    break;
             }
	}
Your addDiceToSelect function should create action buttons which will display the dice the user selects. You will have to have some way of determining which dice those are, most likely through a subscribed notify function that sets a client state variable.