is self::IsCurrentPlayerZombie safe or not?

Game development with Board Game Arena Studio
Post Reply
User avatar
Woodruff
Posts: 412
Joined: 08 March 2014, 00:53

is self::IsCurrentPlayerZombie safe or not?

Post by Woodruff »

Hi everybody,

I am writing the code for handling zombies, which is quite simple.
I was just wondering what is the right way to check in game states that the active player is zombie or not (and not executing some code if he is).
Currently, I use this

Code: Select all

self::isZombie(self::getActivePlayerId()) // true if the active player is zombie, else false

function isZombie($player_id) {
	return self::getUniqueValueFromDB("SELECT player_zombie FROM player WHERE player_id=".$player_id);
}
Can I replace that with

Code: Select all

self::isCurrentPlayerZombie// true if the active player is zombie, else false
Considering that "Current" methods normally refer to the player who have sent the request? I don't know what that mean when a player is zombie, since he does not send any more request to the server... Does that filter active zombie as well?

Thanks very much for your advice :)

Tchebychev
User avatar
Victoria_La
Posts: 620
Joined: 28 December 2015, 20:55

Re: is self::IsCurrentPlayerZombie safe or not?

Post by Victoria_La »

Handing of zombies usually done by a special method zombieTurn()
where you know player is zombie, which usually just causes transition to another state or elimination of the player,
The normal php action handlers wound not be called, so I am not sure why do you need such check.
User avatar
Woodruff
Posts: 412
Joined: 08 March 2014, 00:53

Re: is self::IsCurrentPlayerZombie safe or not?

Post by Woodruff »

Hi Victoria_La,

You're right, I handle zombies through the zombieTurn() method, except for one case where this method won't be called, because it's a 'game' state.
Indeed, after the player choose one or several cards to do something with them, which is a 'activeplayer' state, there is a game state which executes differently in function of what the player chose.
For a zombie, the first part of choosing will be passed since the zombieTurn() will handle the 'activeplayer' state. But afterwards when in 'game' state I must indicate that no selection has been done even if that's forbidden with the rules. That why I just filter player zombie to execute or not a piece of code, that's it.
User avatar
Victoria_La
Posts: 620
Joined: 28 December 2015, 20:55

Re: is self::IsCurrentPlayerZombie safe or not?

Post by Victoria_La »

I don't think concept of current player is applicable in game states, so you have to use active player and code is correct to check it as far as I know
Post Reply

Return to “Developers”