Hi all,
I am a newbie. I have some php, js, css and html experience and a good drive and wish to understand it all.
But I am currently stuck with a javascript error: Cannot read properties of undefined (reading 'image'). after googling it seems it says one of my variables is empty... but i can't figure out which one and what to do.
I have two decks of cards. The first deck needs to show me three random cards from that deck. This is done all successful. so far so good.
The second deck is a different set of cards and it needs to show 10 random cards form that deck. Even though I am using 99% the same code as my first deck (which is working), i just can't get the second deck shown. As mentioned it gives me this annoying error:
Javascript error:
During pageload
Cannot read properties of undefined (reading 'image')
TypeError: Cannot read properties of undefined (reading 'image')
at Object.updateDisplay
Before I show you snippets of my code, I can tell you the image is correctly spelled and in the same directory as the other image. Also in the database i can see it has generated the 10 random cards with card_location 'navontable'
PHP game file:
In the set up part i create the deck based on an array $navCard. Only at the true startup it must give one specific card to each player. Once the card is given, I set the globalvalue on1 (so it does not give the cards again on reloading) and I shuffle the deck.
In the getalldatas part:
I only want to draw the 10 random cards once, so only when the global variable is not equal to zero.
In javascript file:
In the constructor part:
navCards is the id of the div in the tpl is needs to be displayed in.
In the gamedatas part:
TPL file:
Anyone has a clue on where this goes wrong? Or maybe on how I can see whether certain arrays are not NULL.
Thanks in advance
Maurice
I am a newbie. I have some php, js, css and html experience and a good drive and wish to understand it all.
But I am currently stuck with a javascript error: Cannot read properties of undefined (reading 'image'). after googling it seems it says one of my variables is empty... but i can't figure out which one and what to do.
I have two decks of cards. The first deck needs to show me three random cards from that deck. This is done all successful. so far so good.
The second deck is a different set of cards and it needs to show 10 random cards form that deck. Even though I am using 99% the same code as my first deck (which is working), i just can't get the second deck shown. As mentioned it gives me this annoying error:
Javascript error:
During pageload
Cannot read properties of undefined (reading 'image')
TypeError: Cannot read properties of undefined (reading 'image')
at Object.updateDisplay
Before I show you snippets of my code, I can tell you the image is correctly spelled and in the same directory as the other image. Also in the database i can see it has generated the 10 random cards with card_location 'navontable'
PHP game file:
In the set up part i create the deck based on an array $navCard. Only at the true startup it must give one specific card to each player. Once the card is given, I set the globalvalue on1 (so it does not give the cards again on reloading) and I shuffle the deck.
Code: Select all
$this->navCards->createCards( $navCard, 'deck' );
if(self::getGameStateValue('vaultCardsSetup')<>1){
foreach( $players as $player_id => $player )
{
$specialCards = $this->navCards->pickCards( 1, 'deck', 'vault' );
$this->setGameStateInitialValue('vaultCardsSetup', 1);
}
}
$this->navCards->autoreshuffle = true;
$this->navCards->shuffle( 'deck' );
I only want to draw the 10 random cards once, so only when the global variable is not equal to zero.
Code: Select all
$result = array();
if(self::getGameStateValue('navCardsSetup')<>1){
$cards = $this->navCards->pickCardsForLocation( 10, 'deck','navontable');
$this->setGameStateInitialValue('navCardsSetup', 1);
}
$result['showNavigation'] = $this->navCards->getCardsInLocation('navontable');
In the constructor part:
navCards is the id of the div in the tpl is needs to be displayed in.
Code: Select all
this.navDeck = new ebg.stock();
this.navDeck.create( this, $('navCards'), this.navCardWidth, this.navCardHeight);
this.navDeck.image_items_per_row = 9;
for (var vertical = 0; vertical < 2; vertical++) {
for (var horizontal = 0; horizontal < 9; horizontal++) {
var card_type_id = vertical*9 + horizontal;
this.navDeck.addItemType(card_type_id, card_type_id, g_gamethemeurl + 'img/navcards.jpg', card_type_id);
}
}
Code: Select all
for (var i in this.gamedatas.showNavigation) {
var card = this.gamedatas.showNavigation[i];
var vertical = card.type;
var horizontal = card.type_arg;
this.navDeck.addToStockWithId(vertical*9 + horizontal, card.id);
}
Code: Select all
<div id="river" class="whiteblock" style="width:100%;">
<div id="navCards" style="margin-top:5px">
</div>
</div>
Thanks in advance
Maurice