Help with incStat()

Game development with Board Game Arena Studio
Post Reply
User avatar
VanHlebar
Posts: 68
Joined: 24 September 2019, 02:30

Help with incStat()

Post by VanHlebar »

So I created a module to hold all of my database type routines for my game. My class defination is as follows:

Code: Select all

class ELGGameMgt extends APP_GameClass
My problem is that I am getting an error in my routine that handles the increasing of the player stats. An example of my call is:

Code: Select all

self::incStat( $statValue, "player_galicia_scoring", $player_id);
I am passing into the fuction $statValue and $player_id but I am getting an error of call to undefined method self::incStat(). I don't have this issue when I am doing database requests. I have confirmed that each stat has been defined properly in my stat.php file and I have reloaded the file through the control panel. I also have set the initStat() for each of them defined in my game Setup function. I have looked in the table and all of them are getting setup just fine.

So I am hoping someone might have another suggestion other than moving the logic over to my main game.php file. :)

Thanks!
User avatar
RicardoRix
Posts: 2548
Joined: 29 April 2012, 23:43

Re: Help with incStat()

Post by RicardoRix »

Wierdly the self::DB stuff works, but I have the same problem with:

self::notifyPlayer and self::getCurrentPlayerId()

I tried even passing $this in the constructor to my class

Code: Select all

class EU_Trains extends APP_GameClass {

    function __construct($game) 
	{
		$this->game = $game;
	}


then notifyPlayer works, but getCurrentPlayerId is protected.

---------------------------------------------------------------
EDIT:
Just checked someone else's code and they pass both the game($this) and the $player_id in the constructor. :/

But this doesn't quite work for me, I want to call this function from the game.action.php file: The strange solution is to add this helper function in the game.php:

Code: Select all

public function getPlayerId()
	{
		return self::getCurrentPlayerId();
	}


Now I can do this:

Code: Select all

	$this->game->notifyPlayer( $this->game->getPlayerId(), 'buildRoute', clienttranslate('asdasd')	
User avatar
VanHlebar
Posts: 68
Joined: 24 September 2019, 02:30

Re: Help with incStat()

Post by VanHlebar »

hmmm... I never even considered passing the reference to $this in my constructor. I will give this a shot and see if it works. I am guessing that this is caused by a missing include for the incStat routines but I can't find any documentation on it other that what is in stats.php help file.

I will post back here after I test to see if it works for me.

Thanks for the suggestion and confirmation that I am not entirely losing my mind! :)
User avatar
VanHlebar
Posts: 68
Joined: 24 September 2019, 02:30

Re: Help with incStat()

Post by VanHlebar »

Well passing in $this to the constructor of my module does solve my issue with being able to access the various Stat methods. It is very strange that this is the workaround when all the self::DB methods work just fine.

Wish I had a better solution for your issue, but I do appreciate the help and thoughs on my problem!
Post Reply

Return to “Developers”