<?php
/**
* プレイヤービルダー
*
*/
class PlayerBuilder
{
private const DEFAULT_NAME = 'Player';
private const DEFAULT_HP_MAX = 100;
private const DEFAULT_ATK = 0;
private const DEFAULT_DEF = 0;
private const DEFAULT_CRI = 0;
private const DEFAULT_BLOCK = 0;
/** @var string $name */
private string $name = self::DEFAULT_NAME;
/** @var int 最大HP */
private int $hpMax = self::DEFAULT_HP_MAX;
/** @var int ATK */
private int $atk = self::DEFAULT_ATK;
/** @var int DEF */
private int $def = self::DEFAULT_DEF;
/** @var int CRI */
private int $cri = self::DEFAULT_CRI;
/** @var int BLOCK */
private int $block = self::DEFAULT_BLOCK;
/** @var Equipment|null 装備 */
private ?Equipment $equipment = null;
/**
* インスタンス作成
*
* @return self
*/
public static function newInstance(): self
{
return new self();
}
/**
* 名前を設定
*
* @param string $name
* @return $this
*/
public function setName(string $name): self
{
$this->name = $name;
return $this;
}
/**
* HPを設定
*
* @param int $hpMax
* @return $this
*/
public function setHpMax(int $hpMax): self
{
$this->hpMax = $hpMax;
return $this;
}
/**
* ATKを設定
*
* @param int $atk
* @return $this
*/
public function setAtk(int $atk): self
{
$this->atk = $atk;
return $this;
}
/**
* DEFを設定
*
* @param int $def
* @return $this
*/
public function setDef(int $def): self
{
$this->def = $def;
return $this;
}
/**
* CRIを設定
*
* @param int $cri
* @return $this
*/
public function setCri(int $cri): self
{
$this->cri = $cri;
return $this;
}
/**
* BLOCKを設定
*
* @param int $block
* @return $this
*/
public function setBlock(int $block): self
{
$this->block = $block;
return $this;
}
/**
* 装備を設定
*
* @param Equipment $equipment
* @return $this
*/
public function setEquipment(Equipment $equipment): self
{
$this->equipment = $equipment;
return $this;
}
/**
* Playerインスタンス作成
*
* @return Player
*/
public function build(): Player
{
return new Player($this->name, $this->hpMax, $this->atk, $this->def, $this->cri, $this->block, $this->equipment);
}
}