58 lines
1.4 KiB
PHP
58 lines
1.4 KiB
PHP
<?php
|
|
class Card {
|
|
public $color;
|
|
public $shape;
|
|
public $plus;
|
|
public $minus;
|
|
public $is_shadow;
|
|
public $shape2;
|
|
|
|
public function __construct($options = []) {
|
|
if (!isset($options['color'])) {
|
|
throw new Exception('A Color is Required to construct a Card');
|
|
}
|
|
if (!isset($options['shape'])) {
|
|
throw new Exception('A Shape is Required to construct a Card');
|
|
}
|
|
if (!isset($options['plus'])) {
|
|
throw new Exception('A Plus value is Required to construct a Card');
|
|
}
|
|
if (!isset($options['minus'])) {
|
|
throw new Exception('A Minus value is Required to construct a Card');
|
|
}
|
|
$this->color = $options['color'];
|
|
$this->shape = $options['shape'];
|
|
$this->plus = $options['plus'];
|
|
$this->minus = $options['minus'];
|
|
|
|
if (isset($options['id'])) {
|
|
$this->id = $options['id'];
|
|
}
|
|
if (isset($options['is_shadow'])) {
|
|
$this->is_shadow = $options['is_shadow'];
|
|
}
|
|
if (isset($options['shape2'])) {
|
|
$this->shape2 = $options['shape2'];
|
|
}
|
|
}
|
|
|
|
public function getWorth() {
|
|
if ($this->is_shadow) {
|
|
if (isset($this->color2)) {
|
|
return 1;
|
|
}
|
|
return 0;
|
|
}
|
|
if (isset($this->color2)) {
|
|
if ($this->plus > $this->minus) {
|
|
return ceil($this->plus / 2);
|
|
}
|
|
return ceil($this->minus / 2);
|
|
}
|
|
return ceil(($this->plus + $this->minus) / 2);
|
|
}
|
|
|
|
public function getCost() {
|
|
return floor($this->getWorth() / 2);
|
|
}
|
|
} |