Page 1 of 1
Help with incStat()
Posted: 14 May 2020, 01:31
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!
Re: Help with incStat()
Posted: 14 May 2020, 16:53
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')
Re: Help with incStat()
Posted: 14 May 2020, 17:41
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!

Re: Help with incStat()
Posted: 14 May 2020, 18:06
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!