I'm trying to get started to create a four player card game and this is the code I have in the handleInternalEvent function in the extension. Could anyone tell me if this would be the right way to assign ids to the players?
The original tris example is :
Code: Select all
if (u.getPlayerIndex() == 1)
p1id = u.getUserId()
else
p2id = u.getUserId()
I am trying it like this and I get the error that my code can't cal the method getName in the extension:
(Error in extension [ botifarra.as ]: TypeError: Cannot call method "getName" of undefined (botifarra.as#1627) Internal: 50 -- Line number: 49 in file: botifarra.as)
Code: Select all
if (u.getPlayerIndex() != -1)
{
numPlayers++;
if (u.getPlayerIndex() == 1)
p1id = u.getUserId()
else if (u.getPlayerIndex() == 2)
p2id = u.getUserId()
else if (u.getPlayerIndex() == 3)
p3id = u.getUserId()
else if(u.getPlayerIndex() == 4)
p4id = u.getUserId()
if(numPlayers == 4 && !gameStarted)
{
startGame();
}