From 340d6d18fa646b222c38538b7d98f7cab64ad494 Mon Sep 17 00:00:00 2001 From: Austen McDonald Date: Wed, 9 Nov 2016 00:10:11 +0000 Subject: [PATCH] Rename CharacterViewpoint to Viewpoint As I was writing the documentation, this just feels like added complexity that we don't need. --- src/Game.php | 8 ++++---- src/Models/Character.php | 6 +++--- src/Models/Scene.php | 2 +- .../{CharacterViewpoint.php => Viewpoint.php} | 8 ++++---- src/Tools/Model/MockCharacter.php | 4 ++-- tests/GameTest.php | 2 +- ...cterViewpointTest.php => ViewpointTest.php} | 18 +++++++++--------- tests/datasets/game.yml | 2 +- ...{characterViewpoints.yml => viewpoints.yml} | 2 +- 9 files changed, 26 insertions(+), 26 deletions(-) rename src/Models/{CharacterViewpoint.php => Viewpoint.php} (95%) rename tests/Models/{CharacterViewpointTest.php => ViewpointTest.php} (86%) rename tests/datasets/{characterViewpoints.yml => viewpoints.yml} (97%) diff --git a/src/Game.php b/src/Game.php index 8eac9b4..fb21877 100644 --- a/src/Game.php +++ b/src/Game.php @@ -8,7 +8,7 @@ use Monolog\Logger; use LotGD\Core\Models\ { Character, - CharacterViewpoint, + Viewpoint, Scene }; use LotGD\Core\Exceptions\ { @@ -181,9 +181,9 @@ class Game /** * Return the viewpoint for the current user. - * @return CharacterViewpoint + * @return Viewpoint */ - public function getViewpoint(): CharacterViewpoint + public function getViewpoint(): Viewpoint { $v = $this->getCharacter()->getViewpoint(); @@ -201,7 +201,7 @@ class Game throw new InvalidConfigurationException("No subscriber to h/lotgd/core/default-scene returned a scene."); } - $v = new CharacterViewpoint(); + $v = new Viewpoint(); $v->setOwner($this->getCharacter()); $this->getCharacter()->setViewpoint($v); diff --git a/src/Models/Character.php b/src/Models/Character.php index 9f5b96d..60ca150 100644 --- a/src/Models/Character.php +++ b/src/Models/Character.php @@ -47,7 +47,7 @@ class Character implements CharacterInterface, CreateableInterface private $level = 1; /** @OneToMany(targetEntity="CharacterProperty", mappedBy="owner", cascade={"persist", "remove"}) */ private $properties; - /** @OneToOne(targetEntity="CharacterViewpoint", mappedBy="owner", cascade={"persist", "remove"}) */ + /** @OneToOne(targetEntity="Viewpoint", mappedBy="owner", cascade={"persist", "remove"}) */ private $viewpoint; /** * @ManyToMany(targetEntity="MessageThread", inversedBy="participants", cascade={"persist"}) @@ -248,7 +248,7 @@ class Character implements CharacterInterface, CreateableInterface /** * Returns the current character viewpoint or null if one is not set. - * @return \LotGD\Core\Models\CharacterViewpoint|null + * @return \LotGD\Core\Models\Viewpoint|null */ public function getViewpoint() { @@ -258,7 +258,7 @@ class Character implements CharacterInterface, CreateableInterface /** * Sets the current character viewpoint. */ - public function setViewpoint(CharacterViewpoint $v) + public function setViewpoint(Viewpoint $v) { $this->viewpoint = $v; } diff --git a/src/Models/Scene.php b/src/Models/Scene.php index a693fba..95d5641 100644 --- a/src/Models/Scene.php +++ b/src/Models/Scene.php @@ -16,7 +16,7 @@ use LotGD\Core\Tools\Model\SceneBasics; /** * A scene is a location within the game, such as the Village or the Tavern. Designed * to be a kind of "template" for generating the specific location information for - * a specific user, which then becomes a CharacterViewpoint. + * a specific user, which then becomes a Viewpoint. * @Entity * @Table(name="scenes") */ diff --git a/src/Models/CharacterViewpoint.php b/src/Models/Viewpoint.php similarity index 95% rename from src/Models/CharacterViewpoint.php rename to src/Models/Viewpoint.php index acd0060..261a076 100644 --- a/src/Models/CharacterViewpoint.php +++ b/src/Models/Viewpoint.php @@ -11,12 +11,12 @@ use LotGD\Core\Tools\Model\Creator; use LotGD\Core\Tools\Model\SceneBasics; /** - * A CharacterViewpoint is the current Scene a character is experiencing with + * A Viewpoint is the current Scene a character is experiencing with * all changes from modules included. * @Entity - * @Table(name="character_viewpoints") + * @Table(name="viewpoints") */ -class CharacterViewpoint implements CreateableInterface +class Viewpoint implements CreateableInterface { use Creator; use SceneBasics; @@ -56,7 +56,7 @@ class CharacterViewpoint implements CreateableInterface } /** - * Copies the static data from a scene to this CharacterViewpoint entity + * Copies the static data from a scene to this Viewpoint entity * @param \LotGD\Core\Models\Scene $scene */ public function changeFromScene(Scene $scene) diff --git a/src/Tools/Model/MockCharacter.php b/src/Tools/Model/MockCharacter.php index 3664441..a39ee73 100644 --- a/src/Tools/Model/MockCharacter.php +++ b/src/Tools/Model/MockCharacter.php @@ -9,7 +9,7 @@ use LotGD\Core\{ Game }; use LotGD\Core\Exceptions\IsNullException; -use LotGD\Core\Models\CharacterViewpoint; +use LotGD\Core\Models\Viewpoint; /** * Provides basic implementation to mock CharacterInterface. @@ -81,7 +81,7 @@ trait MockCharacter throw new IsNullException(); } - public function getViewpoint(): CharacterViewpoint + public function getViewpoint(): Viewpoint { throw new IsNullException(); } diff --git a/tests/GameTest.php b/tests/GameTest.php index 6c9dd93..483adc6 100644 --- a/tests/GameTest.php +++ b/tests/GameTest.php @@ -20,7 +20,7 @@ use LotGD\Core\Game; use LotGD\Core\TimeKeeper; use LotGD\Core\ModuleManager; use LotGD\Core\Models\Character; -use LotGD\Core\Models\CharacterViewpoint; +use LotGD\Core\Models\Viewpoint; use LotGD\Core\Models\Scene; use LotGD\Core\Exceptions\ { ActionNotFoundException, diff --git a/tests/Models/CharacterViewpointTest.php b/tests/Models/ViewpointTest.php similarity index 86% rename from tests/Models/CharacterViewpointTest.php rename to tests/Models/ViewpointTest.php index 35a5d0b..ccf5128 100644 --- a/tests/Models/CharacterViewpointTest.php +++ b/tests/Models/ViewpointTest.php @@ -7,7 +7,7 @@ use LotGD\Core\Action; use LotGD\Core\ActionGroup; use LotGD\Core\Attachment; use LotGD\Core\Models\Character; -use LotGD\Core\Models\CharacterViewpoint; +use LotGD\Core\Models\Viewpoint; use LotGD\Core\Models\Scene; use LotGD\Core\Tests\CoreModelTestCase; @@ -28,12 +28,12 @@ class SampleAttachment extends Attachment } /** - * Tests the management of CharacterViewpoints + * Tests the management of Viewpoints */ -class CharacterViewpointTest extends CoreModelTestCase +class ViewpointTest extends CoreModelTestCase { /** @var string default data set */ - protected $dataset = "characterViewpoints"; + protected $dataset = "viewpoints"; public function testGetters() { @@ -44,7 +44,7 @@ class CharacterViewpointTest extends CoreModelTestCase $this->assertSame(2, $testCharacter->getId()); $characterScene = $testCharacter->getViewpoint(); - $this->assertInstanceOf(CharacterViewpoint::class, $characterScene); + $this->assertInstanceOf(Viewpoint::class, $characterScene); $this->assertSame("The Village", $characterScene->getTitle()); $this->assertSame("This is the village.", $characterScene->getDescription()); @@ -95,13 +95,13 @@ class CharacterViewpointTest extends CoreModelTestCase $ag2 ]; - $input = $em->getRepository(CharacterViewpoint::class)->find(2); + $input = $em->getRepository(Viewpoint::class)->find(2); $input->setActionGroups($actionGroups); $input->save($em); $em->clear(); - $output = $em->getRepository(CharacterViewpoint::class)->find(2); + $output = $em->getRepository(Viewpoint::class)->find(2); $this->assertEquals($actionGroups, $output->getActionGroups()); $this->assertEquals($ag2, $input->findActionGroupById('id2')); @@ -124,13 +124,13 @@ class CharacterViewpointTest extends CoreModelTestCase $attachments = [$a1, $a2]; - $input = $em->getRepository(CharacterViewpoint::class)->find(2); + $input = $em->getRepository(Viewpoint::class)->find(2); $input->setAttachments($attachments); $input->save($em); $em->clear(); - $output = $em->getRepository(CharacterViewpoint::class)->find(2); + $output = $em->getRepository(Viewpoint::class)->find(2); $this->assertEquals($attachments, $output->getAttachments()); $this->assertEquals('baz', $output->getAttachments()[0]->getFoo()); $this->assertEquals('fiz', $output->getAttachments()[1]->getFoo()); diff --git a/tests/datasets/game.yml b/tests/datasets/game.yml index 5e7d376..239a7fa 100644 --- a/tests/datasets/game.yml +++ b/tests/datasets/game.yml @@ -11,7 +11,7 @@ characters: id: 3 name: "Char without a Scene" displayName: "C" -character_viewpoints: +viewpoints: - owner_id: 2 title: "The Village" diff --git a/tests/datasets/characterViewpoints.yml b/tests/datasets/viewpoints.yml similarity index 97% rename from tests/datasets/characterViewpoints.yml rename to tests/datasets/viewpoints.yml index 03dd69b..50b02c5 100644 --- a/tests/datasets/characterViewpoints.yml +++ b/tests/datasets/viewpoints.yml @@ -7,7 +7,7 @@ characters: id: 2 name: "Char with a Scene" displayName: "B" -character_viewpoints: +viewpoints: - owner_id: 2 title: "The Village"