Refactor the method to be get/setViewpoint() instead of get/setCharacterViewpoint for simplicity
This commit is contained in:
+3
-3
@@ -170,7 +170,7 @@ class Game
|
||||
*/
|
||||
public function getViewpoint(): CharacterViewpoint
|
||||
{
|
||||
$v = $this->getCharacter()->getCharacterViewpoint();
|
||||
$v = $this->getCharacter()->getViewpoint();
|
||||
|
||||
if ($v === null) {
|
||||
// No viewpoint set up for this user. Run the hook to find the default
|
||||
@@ -188,7 +188,7 @@ class Game
|
||||
}
|
||||
$v = new CharacterViewpoint();
|
||||
$this->setupViewpoint($v, $s);
|
||||
$this->getCharacter()->setCharacterViewpoint($v);
|
||||
$this->getCharacter()->setViewpoint($v);
|
||||
$v->save($this->getEntityManager());
|
||||
}
|
||||
|
||||
@@ -241,7 +241,7 @@ class Game
|
||||
}
|
||||
}
|
||||
|
||||
$this->getCharacter()->setCharacterViewpoint($v);
|
||||
$this->getCharacter()->setViewpoint($v);
|
||||
$v->save($this->getEntityManager());
|
||||
}
|
||||
|
||||
|
||||
@@ -48,7 +48,7 @@ class Character implements CharacterInterface, CreateableInterface
|
||||
/** @OneToMany(targetEntity="CharacterProperty", mappedBy="owner", cascade={"persist"}) */
|
||||
private $properties;
|
||||
/** @OneToOne(targetEntity="CharacterViewpoint", mappedBy="owner", cascade={"persist"}) */
|
||||
private $characterViewpoint;
|
||||
private $viewpoint;
|
||||
/**
|
||||
* @ManyToMany(targetEntity="MessageThread", inversedBy="participants", cascade={"persist"})
|
||||
* @JoinTable(
|
||||
@@ -250,17 +250,17 @@ class Character implements CharacterInterface, CreateableInterface
|
||||
* Returns the current character viewpoint or null if one is not set.
|
||||
* @return \LotGD\Core\Models\CharacterViewpoint|null
|
||||
*/
|
||||
public function getCharacterViewpoint()
|
||||
public function getViewpoint()
|
||||
{
|
||||
return $this->characterViewpoint;
|
||||
return $this->viewpoint;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the current character viewpoint.
|
||||
*/
|
||||
public function setCharacterViewpoint(CharacterViewpoint $v)
|
||||
public function setViewpoint(CharacterViewpoint $v)
|
||||
{
|
||||
$this->characterViewpoint = $v;
|
||||
$this->viewpoint = $v;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -13,6 +13,6 @@ interface CharacterInterface extends FighterInterface
|
||||
public function getDisplayName(): string;
|
||||
public function getHealth(): int;
|
||||
public function getMaxHealth(): int;
|
||||
public function getCharacterViewpoint();
|
||||
public function getViewpoint();
|
||||
public function getProperty(string $name, $default = null);
|
||||
}
|
||||
|
||||
@@ -20,7 +20,7 @@ class CharacterViewpoint implements CreateableInterface
|
||||
use Creator;
|
||||
use SceneBasics;
|
||||
|
||||
/** @Id @OneToOne(targetEntity="Character", inversedBy="characterViewpoint", cascade="persist") */
|
||||
/** @Id @OneToOne(targetEntity="Character", inversedBy="viewpoint", cascade="persist") */
|
||||
private $owner;
|
||||
/** @Column(type="array") */
|
||||
private $actions = [];
|
||||
|
||||
@@ -19,77 +19,77 @@ trait MockCharacter
|
||||
public function __call($name, $arguments) {
|
||||
throw new IsNullException();
|
||||
}
|
||||
|
||||
|
||||
public function getId(): int
|
||||
{
|
||||
throw new IsNullException();
|
||||
}
|
||||
|
||||
|
||||
public function getName(): string
|
||||
{
|
||||
throw new IsNullException();
|
||||
}
|
||||
|
||||
|
||||
public function getDisplayName(): string
|
||||
{
|
||||
throw new IsNullException();
|
||||
}
|
||||
|
||||
|
||||
public function getHealth(): int
|
||||
{
|
||||
throw new IsNullException();
|
||||
}
|
||||
|
||||
|
||||
public function setHealth(int $amount)
|
||||
{
|
||||
throw new IsNullException();
|
||||
}
|
||||
|
||||
|
||||
public function damage(int $damage)
|
||||
{
|
||||
throw new IsNullException();
|
||||
}
|
||||
|
||||
|
||||
public function heal(int $heal, bool $overheal = false)
|
||||
{
|
||||
throw new IsNullException();
|
||||
}
|
||||
|
||||
|
||||
public function getMaxHealth(): int
|
||||
{
|
||||
throw new IsNullException();
|
||||
}
|
||||
|
||||
|
||||
public function getLevel(): int
|
||||
{
|
||||
throw new IsNullException();
|
||||
}
|
||||
|
||||
|
||||
public function isAlive(): bool
|
||||
{
|
||||
throw new IsNullException();
|
||||
}
|
||||
|
||||
|
||||
public function getAttack(Game $game, bool $ignoreBuffs = false): int
|
||||
{
|
||||
throw new IsNullException();
|
||||
}
|
||||
|
||||
|
||||
public function getDefense(Game $game, bool $ignoreBuffs = false): int
|
||||
{
|
||||
throw new IsNullException();
|
||||
}
|
||||
|
||||
public function getCharacterViewpoint(): CharacterViewpoint
|
||||
|
||||
public function getViewpoint(): CharacterViewpoint
|
||||
{
|
||||
throw new IsNullException();
|
||||
}
|
||||
|
||||
|
||||
public function getProperty(string $name, $default = null)
|
||||
{
|
||||
return $default;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns an empty bufflist
|
||||
* @return BuffList
|
||||
|
||||
@@ -23,7 +23,7 @@ class CharacterViewpointTest extends ModelTestCase
|
||||
// Test character with a characterScene
|
||||
$testCharacter = $em->getRepository(Character::class)->find(2);
|
||||
$this->assertSame(2, $testCharacter->getId());
|
||||
$characterScene = $testCharacter->getCharacterViewpoint();
|
||||
$characterScene = $testCharacter->getViewpoint();
|
||||
|
||||
$this->assertInstanceOf(CharacterViewpoint::class, $characterScene);
|
||||
$this->assertSame("The Village", $characterScene->getTitle());
|
||||
@@ -32,7 +32,7 @@ class CharacterViewpointTest extends ModelTestCase
|
||||
// Test character without a characterScene
|
||||
$testCharacter = $em->getRepository(Character::class)->find(1);
|
||||
$this->assertSame(1, $testCharacter->getId());
|
||||
$characterScene = $testCharacter->getCharacterViewpoint();
|
||||
$characterScene = $testCharacter->getViewpoint();
|
||||
|
||||
$this->assertNull($characterScene);
|
||||
|
||||
@@ -48,11 +48,11 @@ class CharacterViewpointTest extends ModelTestCase
|
||||
|
||||
$testScene = $em->getRepository(Scene::class)->find(2);
|
||||
|
||||
$this->assertSame("The Village", $testCharacter->getCharacterViewpoint()->getTitle());
|
||||
$this->assertSame("The Village", $testCharacter->getViewpoint()->getTitle());
|
||||
|
||||
$testCharacter->getCharacterViewpoint()->changeFromScene($testScene);
|
||||
$testCharacter->getViewpoint()->changeFromScene($testScene);
|
||||
|
||||
$this->assertSame("The Forest", $testCharacter->getCharacterViewpoint()->getTitle());
|
||||
$this->assertSame("The Forest", $testCharacter->getViewpoint()->getTitle());
|
||||
|
||||
$em->flush();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user