Change characterViewpoint to be one-to-one, bidirectional.
This commit is contained in:
@@ -47,7 +47,7 @@ class Character implements CharacterInterface, CreateableInterface
|
||||
private $level = 1;
|
||||
/** @OneToMany(targetEntity="CharacterProperty", mappedBy="owner", cascade={"persist"}) */
|
||||
private $properties;
|
||||
/** @OneToMany(targetEntity="CharacterViewpoint", mappedBy="owner", cascade={"persist"}) */
|
||||
/** @OneToOne(targetEntity="CharacterViewpoint", mappedBy="owner", cascade={"persist"}) */
|
||||
private $characterViewpoint;
|
||||
/**
|
||||
* @ManyToMany(targetEntity="MessageThread", inversedBy="participants", cascade={"persist"})
|
||||
@@ -90,7 +90,6 @@ class Character implements CharacterInterface, CreateableInterface
|
||||
public function __construct()
|
||||
{
|
||||
$this->properties = new ArrayCollection();
|
||||
$this->characterViewpoint = new ArrayCollection();
|
||||
$this->buffs = new ArrayCollection();
|
||||
$this->messageThreads = new ArrayCollection();
|
||||
}
|
||||
@@ -253,11 +252,15 @@ class Character implements CharacterInterface, CreateableInterface
|
||||
*/
|
||||
public function getCharacterViewpoint()
|
||||
{
|
||||
if (count($this->characterViewpoint) === 0) {
|
||||
return null;
|
||||
}
|
||||
return $this->characterViewpoint;
|
||||
}
|
||||
|
||||
return $this->characterViewpoint->first();
|
||||
/**
|
||||
* Sets the current character viewpoint.
|
||||
*/
|
||||
public function setCharacterViewpoint(CharacterViewpoint $v)
|
||||
{
|
||||
$this->characterViewpoint = $v;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -20,7 +20,7 @@ class CharacterViewpoint implements CreateableInterface
|
||||
use Creator;
|
||||
use SceneBasics;
|
||||
|
||||
/** @Id @ManyToOne(targetEntity="Character", inversedBy="id", cascade="persist") */
|
||||
/** @Id @OneToOne(targetEntity="Character", inversedBy="characterViewpoint", cascade="persist") */
|
||||
private $owner;
|
||||
/** @Column(type="array") */
|
||||
private $actions = [];
|
||||
@@ -61,6 +61,10 @@ class CharacterViewpoint implements CreateableInterface
|
||||
$this->setTitle($scene->getTitle());
|
||||
$this->setDescription($scene->getDescription());
|
||||
$this->setTemplate($scene->getTemplate());
|
||||
|
||||
$this->setActions([]);
|
||||
$this->setAttachments([]);
|
||||
$this->setData([]);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -81,6 +85,24 @@ class CharacterViewpoint implements CreateableInterface
|
||||
$this->actions = $actions;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns all attachments.
|
||||
* @return array
|
||||
*/
|
||||
public function getAttachments(): array
|
||||
{
|
||||
return $this->attachments;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets attachments.
|
||||
* @param array $actions
|
||||
*/
|
||||
public function setAttachments(array $attachments)
|
||||
{
|
||||
$this->attachments = $attachments;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns all data
|
||||
* @return array
|
||||
@@ -126,8 +148,8 @@ class CharacterViewpoint implements CreateableInterface
|
||||
public function findActionById(string $id)
|
||||
{
|
||||
foreach ($this->getActions() as $group) {
|
||||
foreach ($group->getSctions() as $a) {
|
||||
if ($a->getId() == $actionId) {
|
||||
foreach ($group->getActions() as $a) {
|
||||
if ($a->getId() == $id) {
|
||||
return $a;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user