Hello, i can't find my error, maybe some here can help:
I have the following class
and the following extension
now, i create an instance of CardBang and execute the play method:
Why do i get an error
I have the following class
Code: Select all
class Card extends APP_GameClass
{
public function __construct(){
}
public $id;
public $name;
public $text;
public $copies = [];
public $implemented = false;
public $type; // see dbmodel.sql
public $color;
public $effect; // array with type, impact and sometimes range
public function play($player) {
switch ($this->effect->type) {
//...
}
}
//...
}Code: Select all
class CardBang extends Card {
public function __construct()
{
parent::__construct();
$this->id = CARD_BANG;
$this->name = clienttranslate('BANG!');
$this->text = "A Bang to a player in range. Can usually only be played once per turn";
$this->color = BROWN; //BROWN, BLUE, GREEN
$this->type = 10;
$this->effect = ['type' => BASIC_ATTACK, // BASIC_ATTACK, DRAW, DEFENSIVE, DISCARD, LIFE_POINT_MODIFIER, RANGE_INCREASE, RANGE_DECREASE, OTHER
'range' => 0,
'impacts' => INRANGE // NONE, INRANGE, SPECIFIC_RANGE, ALL_OTHER, ALL, ANY
];
$this->copies = [
BASE_GAME => [ 'AS', '8D', '9D', '10D', 'JD', 'QD', 'KD', 'AD', '2C', '3C', 'QH', 'KH', 'AH', '2D', '3D', '4D', '5D', '6D', '7D', '4C', '5C', '6C', '7C', '8C', '9C' ],
DODGE_CITY => [ '8S', '5C', '6C', 'KC'],
];
}
}Code: Select all
$card = new CardBang();
$card->play($player_id);
at the switch line?Trying to get property 'type' of non-object