Compare commits
12 Commits
v0.4.1
...
v0.5.0-alpha
| Author | SHA1 | Date | |
|---|---|---|---|
| 049d116028 | |||
| a097c29d67 | |||
| bab3e0f236 | |||
| 2f89bbc7e3 | |||
| 6e2ba248c4 | |||
| b398ffae14 | |||
| 90971d152a | |||
| 04b3b6aaf9 | |||
| 0aaba1b94b | |||
| 2affd4803f | |||
| c07f7b3342 | |||
| 8a75e81431 |
+3
-2
@@ -2,7 +2,7 @@
|
||||
"name": "lotgd/core",
|
||||
"description": "Core functionality for Legend of the Green Dragon, a text-based RPG game.",
|
||||
"license": "AGPL-3.0",
|
||||
"version": "0.4.0",
|
||||
"version": "0.5.0",
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"LotGD\\Core\\": "src/",
|
||||
@@ -20,7 +20,8 @@
|
||||
"monolog/monolog": "^1.12",
|
||||
"symfony/console": "^3.0",
|
||||
"symfony/yaml": "^3.0",
|
||||
"d11wtq/boris": "^1.0"
|
||||
"d11wtq/boris": "^1.0",
|
||||
"ramsey/uuid-doctrine": "^1.5"
|
||||
},
|
||||
"repositories": [
|
||||
{
|
||||
|
||||
Generated
+411
-161
File diff suppressed because it is too large
Load Diff
+2
-2
@@ -20,7 +20,7 @@ class Action
|
||||
* @param string|null $title
|
||||
* @param array $parameters
|
||||
*/
|
||||
public function __construct(int $destinationSceneId, ?string $title = null, array $parameters = [])
|
||||
public function __construct(string $destinationSceneId, ?string $title = null, array $parameters = [])
|
||||
{
|
||||
$this->id = bin2hex(random_bytes(8));
|
||||
$this->destinationSceneId = $destinationSceneId;
|
||||
@@ -43,7 +43,7 @@ class Action
|
||||
* go if they take this action.
|
||||
* @return int
|
||||
*/
|
||||
public function getDestinationSceneId(): int
|
||||
public function getDestinationSceneId(): string
|
||||
{
|
||||
return $this->destinationSceneId;
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@ namespace LotGD\Core;
|
||||
use Doctrine\Common\Annotations\AnnotationRegistry;
|
||||
use Doctrine\Common\EventManager as DoctrineEventManager;
|
||||
use Doctrine\Common\Util\Debug;
|
||||
use Doctrine\DBAL\DBALException;
|
||||
use Doctrine\ORM\Events as DoctrineEvents;
|
||||
use Doctrine\ORM\ {
|
||||
EntityManager,
|
||||
@@ -173,6 +174,11 @@ class Bootstrap
|
||||
// Create entity manager
|
||||
$entityManager = EntityManager::create(["pdo" => $pdo], $configuration);
|
||||
|
||||
// Register uuid type
|
||||
try {
|
||||
\Doctrine\DBAL\Types\Type::addType('uuid', 'Ramsey\Uuid\Doctrine\UuidType');
|
||||
} catch (DBALException $e) {}
|
||||
|
||||
// Create Schema and update database if needed
|
||||
$metaData = $entityManager->getMetadataFactory()->getAllMetadata();
|
||||
$schemaTool = new SchemaTool($entityManager);
|
||||
|
||||
@@ -111,7 +111,8 @@ class EventManager
|
||||
'class' => $class,
|
||||
'library' => $library
|
||||
]);
|
||||
$e->save($this->g->getEntityManager());
|
||||
|
||||
$this->g->getEntityManager()->persist($e);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
+1
-1
@@ -60,7 +60,7 @@ class Game
|
||||
*/
|
||||
public static function getVersion(): string
|
||||
{
|
||||
return '0.1.0';
|
||||
return '0.5.0';
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -4,13 +4,15 @@ declare(strict_types=1);
|
||||
namespace LotGD\Core\Models;
|
||||
|
||||
use Doctrine\ORM\Mapping\MappedSuperclass;
|
||||
use Ramsey\Uuid\Uuid;
|
||||
use Ramsey\Uuid\UuidInterface;
|
||||
|
||||
/**
|
||||
* @MappedSuperclass
|
||||
*/
|
||||
abstract class BasicEnemy implements FighterInterface
|
||||
{
|
||||
/** @Id @Column(type="integer") @GeneratedValue */
|
||||
/** @Id @Column(type="uuid", unique=True) */
|
||||
protected $id;
|
||||
/** @Column(type="string", length=50); */
|
||||
protected $name;
|
||||
@@ -18,12 +20,20 @@ abstract class BasicEnemy implements FighterInterface
|
||||
protected $level;
|
||||
/** @var int */
|
||||
protected $health;
|
||||
|
||||
/**
|
||||
* BasicEnemy constructor. Sets uuid upon creation.
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function __construct() {
|
||||
$this->id = Uuid::uuid4();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the enemy's id
|
||||
* @return int
|
||||
*/
|
||||
public function getId(): int
|
||||
public function getId(): UuidInterface
|
||||
{
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
+10
-6
@@ -7,6 +7,8 @@ use Doctrine\ORM\Mapping\Entity;
|
||||
use Doctrine\ORM\Mapping\Table;
|
||||
|
||||
use LotGD\Core\Exceptions\ArgumentException;
|
||||
use Ramsey\Uuid\Uuid;
|
||||
use Ramsey\Uuid\UuidInterface;
|
||||
|
||||
/**
|
||||
* A model representing a buff used to modify the flow of the battle.
|
||||
@@ -23,7 +25,7 @@ class Buff
|
||||
const ACTIVATE_NONE = 0b0000;
|
||||
const ACTIVATE_ANY = 0b1111;
|
||||
|
||||
/** @Id @Column(type="integer") @GeneratedValue */
|
||||
/** @Id @Column(type="uuid", unique=True) */
|
||||
private $id;
|
||||
/**
|
||||
* @ManyToOne(targetEntity="Character", inversedBy="buffs")
|
||||
@@ -231,7 +233,7 @@ class Buff
|
||||
* Allowed buff values and their type
|
||||
* @var array
|
||||
*/
|
||||
private $buffArrayTemplate = [
|
||||
private static $buffArrayTemplate = [
|
||||
"slot" => "string",
|
||||
"name" => "string",
|
||||
"startMessage" => "string",
|
||||
@@ -282,13 +284,15 @@ class Buff
|
||||
*/
|
||||
public function __construct(array $buffArray)
|
||||
{
|
||||
$this->id = Uuid::uuid4();
|
||||
|
||||
foreach ($buffArray as $attribute => $value) {
|
||||
// Throw exception if an attribute does not exist (to prevent spelling errors)
|
||||
if (!isset($this->buffArrayTemplate[$attribute])) {
|
||||
if (!isset(self::$buffArrayTemplate[$attribute])) {
|
||||
throw new ArgumentException("{$attribute} is not a valid key for a buff.");
|
||||
}
|
||||
|
||||
switch ($this->buffArrayTemplate[$attribute]) {
|
||||
switch (self::$buffArrayTemplate[$attribute]) {
|
||||
case "string":
|
||||
if (is_string($value) === false) {
|
||||
throw new ArgumentException("{$attribute} needs to be a string.");
|
||||
@@ -338,7 +342,7 @@ class Buff
|
||||
{
|
||||
$buffArray = [];
|
||||
|
||||
foreach ($this->buffArrayTemplate as $attribute => $type) {
|
||||
foreach (self::$buffArrayTemplate as $attribute => $type) {
|
||||
$buffArray[$attribute] = $buff->$attribute;
|
||||
}
|
||||
|
||||
@@ -349,7 +353,7 @@ class Buff
|
||||
* Returns the id of the buff
|
||||
* @return int
|
||||
*/
|
||||
public function getId(): int
|
||||
public function getId(): UuidInterface
|
||||
{
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
@@ -17,6 +17,8 @@ use LotGD\Core\Exceptions\BuffSlotOccupiedException;
|
||||
use LotGD\Core\Tools\Model\{
|
||||
Creator, ExtendableModel, GameAware, PropertyManager, SoftDeletable
|
||||
};
|
||||
use Ramsey\Uuid\Uuid;
|
||||
use Ramsey\Uuid\UuidInterface;
|
||||
|
||||
/**
|
||||
* Model for a character
|
||||
@@ -32,7 +34,7 @@ class Character implements CharacterInterface, CreateableInterface, GameAwareInt
|
||||
use GameAware;
|
||||
use ExtendableModel;
|
||||
|
||||
/** @Id @Column(type="integer") @GeneratedValue */
|
||||
/** @Id @Column(type="uuid", unique=True) */
|
||||
private $id;
|
||||
/** @Column(type="string", length=50); */
|
||||
private $name;
|
||||
@@ -90,6 +92,8 @@ class Character implements CharacterInterface, CreateableInterface, GameAwareInt
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->id = Uuid::uuid4();
|
||||
|
||||
$this->properties = new ArrayCollection();
|
||||
$this->buffs = new ArrayCollection();
|
||||
$this->messageThreads = new ArrayCollection();
|
||||
@@ -99,7 +103,7 @@ class Character implements CharacterInterface, CreateableInterface, GameAwareInt
|
||||
* Returns the entity's id
|
||||
* @return int The id
|
||||
*/
|
||||
public function getId(): int
|
||||
public function getId(): UuidInterface
|
||||
{
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
@@ -3,12 +3,14 @@ declare(strict_types=1);
|
||||
|
||||
namespace LotGD\Core\Models;
|
||||
|
||||
use Ramsey\Uuid\UuidInterface;
|
||||
|
||||
/**
|
||||
* Interface for the character model and all objects that mimick such a model.
|
||||
*/
|
||||
interface CharacterInterface extends FighterInterface
|
||||
{
|
||||
public function getId(): int;
|
||||
public function getId(): UuidInterface;
|
||||
public function getName(): string;
|
||||
public function getDisplayName(): string;
|
||||
public function getHealth(): int;
|
||||
|
||||
@@ -39,9 +39,6 @@ class Message
|
||||
private $systemMessage = false;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Constructs the message.
|
||||
* Use the Message Manager methods send() and sendSystemMessage() instead.
|
||||
|
||||
+5
-2
@@ -8,6 +8,8 @@ use Doctrine\ORM\Mapping\Table;
|
||||
|
||||
use LotGD\Core\Tools\Model\Creator;
|
||||
use LotGD\Core\Tools\Model\Deletor;
|
||||
use Ramsey\Uuid\Uuid;
|
||||
use Ramsey\Uuid\UuidInterface;
|
||||
|
||||
/**
|
||||
* Model for the message of the day
|
||||
@@ -20,7 +22,7 @@ class MotD implements CreateableInterface
|
||||
use Creator;
|
||||
use Deletor;
|
||||
|
||||
/** @Id @Column(type="integer") @GeneratedValue */
|
||||
/** @Id @Column(type="uuid", unique=True) */
|
||||
private $id;
|
||||
/**
|
||||
* @ManyToOne(targetEntity="Character", cascade={"persist"}, fetch="EAGER")
|
||||
@@ -49,6 +51,7 @@ class MotD implements CreateableInterface
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->id = Uuid::uuid4();
|
||||
$this->creationTime = new \DateTime("now");
|
||||
}
|
||||
|
||||
@@ -56,7 +59,7 @@ class MotD implements CreateableInterface
|
||||
* Returns the entities ID
|
||||
* @return int
|
||||
*/
|
||||
public function getId(): int
|
||||
public function getId(): UuidInterface
|
||||
{
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
@@ -43,9 +43,9 @@ class CharacterRepository extends EntityRepository
|
||||
}
|
||||
|
||||
/**
|
||||
* Find a character by ID.
|
||||
* Find a character by ID, excluding soft deleted ones.
|
||||
*/
|
||||
public function find($id, $lockMode = NULL, $lockVersion = NULL, int $deletes = self::SKIP_SOFTDELETED)
|
||||
public function find($id, $lockMode=null, $lockVersion=null)
|
||||
{
|
||||
$queryBuilder = $this->getEntityManager()->createQueryBuilder();
|
||||
$queryBuilder->select("c")
|
||||
@@ -53,7 +53,29 @@ class CharacterRepository extends EntityRepository
|
||||
->where($queryBuilder->expr()->eq("c.id", ":id"))
|
||||
->setParameter("id", $id);
|
||||
|
||||
$this->modifyQuery($queryBuilder, $deletes);
|
||||
$this->modifyQuery($queryBuilder, self::SKIP_SOFTDELETED);
|
||||
|
||||
try {
|
||||
return $queryBuilder->getQuery()->getSingleResult();
|
||||
} catch (NoResultException $e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Finds a character id ID, including soft deleted ones.
|
||||
* @param $id
|
||||
* @return mixed|null
|
||||
* @throws \Doctrine\ORM\NonUniqueResultException
|
||||
*/
|
||||
public function findWithSoftDeleted($id) {
|
||||
$queryBuilder = $this->getEntityManager()->createQueryBuilder();
|
||||
$queryBuilder->select("c")
|
||||
->from(Character::class, "c")
|
||||
->where($queryBuilder->expr()->eq("c.id", ":id"))
|
||||
->setParameter("id", $id);
|
||||
|
||||
$this->modifyQuery($queryBuilder, self::INCLUDE_SOFTDELETED);
|
||||
|
||||
try {
|
||||
return $queryBuilder->getQuery()->getSingleResult();
|
||||
|
||||
@@ -12,6 +12,8 @@ use LotGD\Core\Exceptions\ArgumentException;
|
||||
use LotGD\Core\Tools\Model\Creator;
|
||||
use LotGD\Core\Tools\Model\Deletor;
|
||||
use LotGD\Core\Tools\Model\SceneBasics;
|
||||
use Ramsey\Uuid\Uuid;
|
||||
use Ramsey\Uuid\UuidInterface;
|
||||
|
||||
/**
|
||||
* A scene is a location within the game, such as the Village or the Tavern. Designed
|
||||
@@ -26,8 +28,8 @@ class Scene implements CreateableInterface, SceneConnectable
|
||||
use Deletor;
|
||||
use SceneBasics;
|
||||
|
||||
/** @Id @Column(type="integer") @GeneratedValue */
|
||||
private $id;
|
||||
/** @Id @Column(type="string", length=36, unique=True, name="id", options={"fixed" = true}) */
|
||||
protected $id;
|
||||
|
||||
/**
|
||||
* @OneToMany(targetEntity="SceneConnectionGroup", mappedBy="scene", cascade={"persist", "remove"})
|
||||
@@ -61,6 +63,8 @@ class Scene implements CreateableInterface, SceneConnectable
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->id = Uuid::uuid4()->toString();
|
||||
|
||||
$this->connectionGroups = new ArrayCollection();
|
||||
$this->outgoingConnections = new ArrayCollection();
|
||||
$this->incomingConnections = new ArrayCollection();
|
||||
@@ -70,7 +74,7 @@ class Scene implements CreateableInterface, SceneConnectable
|
||||
* Returns the primary ID for this scene.
|
||||
* @return int
|
||||
*/
|
||||
public function getId(): int
|
||||
public function getId(): string
|
||||
{
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
@@ -15,14 +15,14 @@ class SceneConnection
|
||||
{
|
||||
/**
|
||||
* @Id
|
||||
* @ManyToOne(targetEntity="Scene")
|
||||
* @ManyToOne(targetEntity="Scene", inversedBy="outgoingConnections")
|
||||
* @JoinColumn(name="outgoingScene", referencedColumnName="id")
|
||||
*/
|
||||
private $outgoingScene;
|
||||
|
||||
/**
|
||||
* @Id
|
||||
* @ManyToOne(targetEntity="Scene")
|
||||
* @ManyToOne(targetEntity="Scene", inversedBy="incomingConnections")
|
||||
* @JoinColumn(name="incomingScene", referencedColumnName="id")
|
||||
*/
|
||||
private $incomingScene;
|
||||
|
||||
@@ -329,7 +329,7 @@ class Viewpoint implements CreateableInterface
|
||||
* Removes any actions that correspond to a given scene ID, if present.
|
||||
* @param int $id
|
||||
*/
|
||||
public function removeActionsWithSceneId(int $id)
|
||||
public function removeActionsWithSceneId(string $id)
|
||||
{
|
||||
foreach ($this->getActionGroups() as $group) {
|
||||
$actions = $group->getActions();
|
||||
|
||||
+24
-4
@@ -42,6 +42,7 @@ class ModuleManager
|
||||
{
|
||||
$name = $library->getName();
|
||||
$package = $library->getComposerPackage();
|
||||
$em = $this->g->getEntityManager();
|
||||
|
||||
$this->g->getLogger()->debug("Registering module {$name}...");
|
||||
|
||||
@@ -53,6 +54,8 @@ class ModuleManager
|
||||
$this->g->getLogger()->debug("Creating module model for {$name}");
|
||||
$m = new ModuleModel($name);
|
||||
|
||||
$em->beginTransaction();
|
||||
|
||||
$class = $library->getRootNamespace() . 'Module';
|
||||
try {
|
||||
$klass = new \ReflectionClass($class);
|
||||
@@ -69,9 +72,16 @@ class ModuleManager
|
||||
}
|
||||
|
||||
// Subscribe to the module's events.
|
||||
$subscriptions = $library->getSubscriptionPatterns();
|
||||
foreach ($subscriptions as $s) {
|
||||
$this->g->getEventManager()->subscribe($s, $class, $name);
|
||||
try {
|
||||
$subscriptions = $library->getSubscriptionPatterns();
|
||||
foreach ($subscriptions as $s) {
|
||||
$this->g->getEventManager()->subscribe($s, $class, $name);
|
||||
}
|
||||
} catch (\Throwable $e) {
|
||||
$em->rollBack();
|
||||
$em->clear();
|
||||
|
||||
throw $e;
|
||||
}
|
||||
|
||||
// Run the module's onRegister handler.
|
||||
@@ -79,10 +89,20 @@ class ModuleManager
|
||||
|
||||
try {
|
||||
$class::onRegister($this->g, $m);
|
||||
$m->save($this->g->getEntityManager());
|
||||
$this->g->getEntityManager()->persist($m);
|
||||
|
||||
$this->g->getEntityManager()->flush();
|
||||
$em->commit();
|
||||
return;
|
||||
} catch (Throwable $e) {
|
||||
$em->rollBack();
|
||||
$em->clear();
|
||||
|
||||
$this->g->getLogger()->error("Calling {$class}::onRegister failed with exception: {$e->getMessage()}");
|
||||
unset($m);
|
||||
|
||||
// Propagate the exception.
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,6 +10,7 @@ use LotGD\Core\{
|
||||
};
|
||||
use LotGD\Core\Exceptions\IsNullException;
|
||||
use LotGD\Core\Models\Viewpoint;
|
||||
use Ramsey\Uuid\UuidInterface;
|
||||
|
||||
/**
|
||||
* Provides basic implementation to mock CharacterInterface.
|
||||
@@ -21,7 +22,7 @@ trait MockCharacter
|
||||
throw new IsNullException();
|
||||
}
|
||||
|
||||
public function getId(): int
|
||||
public function getId(): UuidInterface
|
||||
{
|
||||
throw new IsNullException();
|
||||
}
|
||||
|
||||
+34
-30
@@ -5,6 +5,7 @@ namespace LotGD\Core\Tests\Models;
|
||||
|
||||
use Doctrine\Common\Collections\Collection;
|
||||
|
||||
use Doctrine\Common\Util\Debug;
|
||||
use LotGD\Core\{
|
||||
Battle,
|
||||
DiceBag,
|
||||
@@ -25,6 +26,9 @@ use LotGD\Core\Models\BattleEvents\{
|
||||
};
|
||||
|
||||
use LotGD\Core\Tests\CoreModelTestCase;
|
||||
use Ramsey\Uuid\Codec\OrderedTimeCodec;
|
||||
use Ramsey\Uuid\Uuid;
|
||||
use Ramsey\Uuid\UuidFactory;
|
||||
|
||||
class BattleTest extends CoreModelTestCase
|
||||
{
|
||||
@@ -52,8 +56,8 @@ class BattleTest extends CoreModelTestCase
|
||||
{
|
||||
$em = $this->getEntityManager();
|
||||
|
||||
$character = $em->getRepository(Character::class)->find(1);
|
||||
$monster = $em->getRepository(Monster::class)->find(1);
|
||||
$character = $em->getRepository(Character::class)->find("d363c077-234a-433d-834e-f1a1d3b281d8");
|
||||
$monster = $em->getRepository(Monster::class)->find("de84c507-9673-44e7-b665-9e43416b9c2f");
|
||||
|
||||
$this->assertSame(5, $monster->getLevel());
|
||||
$this->assertSame(52, $monster->getMaxHealth());
|
||||
@@ -69,8 +73,8 @@ class BattleTest extends CoreModelTestCase
|
||||
{
|
||||
$em = $this->getEntityManager();
|
||||
|
||||
$character = $em->getRepository(Character::class)->find(1);
|
||||
$monster = $em->getRepository(Monster::class)->find(1);
|
||||
$character = $em->getRepository(Character::class)->find("d363c077-234a-433d-834e-f1a1d3b281d8");
|
||||
$monster = $em->getRepository(Monster::class)->find("de84c507-9673-44e7-b665-9e43416b9c2f");
|
||||
|
||||
$battle = new Battle($this->getMockGame($character), $character, $monster);
|
||||
|
||||
@@ -106,8 +110,8 @@ class BattleTest extends CoreModelTestCase
|
||||
{
|
||||
$em = $this->getEntityManager();
|
||||
|
||||
$character = $em->getRepository(Character::class)->find(1);
|
||||
$monster = $em->getRepository(Monster::class)->find(1);
|
||||
$character = $em->getRepository(Character::class)->find("d363c077-234a-433d-834e-f1a1d3b281d8");
|
||||
$monster = $em->getRepository(Monster::class)->find("de84c507-9673-44e7-b665-9e43416b9c2f");
|
||||
|
||||
$battle = new Battle($this->getMockGame($character), $character, $monster);
|
||||
$battle = $battle->serialize();
|
||||
@@ -139,8 +143,8 @@ class BattleTest extends CoreModelTestCase
|
||||
{
|
||||
$em = $this->getEntityManager();
|
||||
|
||||
$highLevelPlayer = $em->getRepository(Character::class)->find(2);
|
||||
$lowLevelMonster = $em->getRepository(Monster::class)->find(3);
|
||||
$highLevelPlayer = $em->getRepository(Character::class)->find("4d01c29b-d825-4bc7-9e6e-63525155fd37");
|
||||
$lowLevelMonster = $em->getRepository(Monster::class)->find("c004bcb6-a7c1-4f9a-abc2-1711c64e23a0");
|
||||
|
||||
$battle = new Battle($this->getMockGame($highLevelPlayer), $highLevelPlayer, $lowLevelMonster);
|
||||
|
||||
@@ -172,8 +176,8 @@ class BattleTest extends CoreModelTestCase
|
||||
{
|
||||
$em = $this->getEntityManager();
|
||||
|
||||
$lowLevelPlayer = $em->getRepository(Character::class)->find(3);
|
||||
$highLevelMonster = $em->getRepository(Monster::class)->find(2);
|
||||
$lowLevelPlayer = $em->getRepository(Character::class)->find("c3792b61-4e34-4710-9871-65a68ac30bb4");
|
||||
$highLevelMonster = $em->getRepository(Monster::class)->find("b636df29-f72d-4e2d-9850-982e783a9e94");
|
||||
|
||||
$battle = new Battle($this->getMockGame($lowLevelPlayer), $lowLevelPlayer, $highLevelMonster);
|
||||
|
||||
@@ -205,8 +209,8 @@ class BattleTest extends CoreModelTestCase
|
||||
{
|
||||
$em = $this->getEntityManager();
|
||||
|
||||
$character = $em->getRepository(Character::class)->find(1);
|
||||
$monster = $em->getRepository(Monster::class)->find(1);
|
||||
$character = $em->getRepository(Character::class)->find("d363c077-234a-433d-834e-f1a1d3b281d8");
|
||||
$monster = $em->getRepository(Monster::class)->find("de84c507-9673-44e7-b665-9e43416b9c2f");
|
||||
|
||||
$battle = new Battle($this->getMockGame($character), $character, $monster);
|
||||
|
||||
@@ -220,8 +224,8 @@ class BattleTest extends CoreModelTestCase
|
||||
{
|
||||
$em = $this->getEntityManager();
|
||||
|
||||
$character = $em->getRepository(Character::class)->find(1);
|
||||
$monster = $em->getRepository(Monster::class)->find(1);
|
||||
$character = $em->getRepository(Character::class)->find("d363c077-234a-433d-834e-f1a1d3b281d8");
|
||||
$monster = $em->getRepository(Monster::class)->find("de84c507-9673-44e7-b665-9e43416b9c2f");
|
||||
|
||||
$battle = new Battle($this->getMockGame($character), $character, $monster);
|
||||
|
||||
@@ -236,8 +240,8 @@ class BattleTest extends CoreModelTestCase
|
||||
{
|
||||
$em = $this->getEntityManager();
|
||||
|
||||
$character = $em->getRepository(Character::class)->find(1);
|
||||
$monster = $em->getRepository(Monster::class)->find(1);
|
||||
$character = $em->getRepository(Character::class)->find("d363c077-234a-433d-834e-f1a1d3b281d8");
|
||||
$monster = $em->getRepository(Monster::class)->find("de84c507-9673-44e7-b665-9e43416b9c2f");
|
||||
|
||||
$battle = new Battle($this->getMockGame($character), $character, $monster);
|
||||
|
||||
@@ -257,23 +261,23 @@ class BattleTest extends CoreModelTestCase
|
||||
default:
|
||||
case 0:
|
||||
// Fair Battle
|
||||
$character = $em->getRepository(Character::class)->find(1);
|
||||
$monster = $em->getRepository(Monster::class)->find(1);
|
||||
$character = $em->getRepository(Character::class)->find("d363c077-234a-433d-834e-f1a1d3b281d8");
|
||||
$monster = $em->getRepository(Monster::class)->find("de84c507-9673-44e7-b665-9e43416b9c2f");
|
||||
break;
|
||||
case 1:
|
||||
// very long battle
|
||||
$character = $em->getRepository(Character::class)->find(4);
|
||||
$monster = $em->getRepository(Monster::class)->find(3);
|
||||
$character = $em->getRepository(Character::class)->find("6565b418-55f5-4a6b-8d92-a9ef81329912");
|
||||
$monster = $em->getRepository(Monster::class)->find("c004bcb6-a7c1-4f9a-abc2-1711c64e23a0");
|
||||
break;
|
||||
case 2:
|
||||
// player should win battle
|
||||
$character = $em->getRepository(Character::class)->find(13);
|
||||
$monster = $em->getRepository(Monster::class)->find(11);
|
||||
$character = $em->getRepository(Character::class)->find("1a9f63f2-3006-4e12-b272-4fd6be518a93");
|
||||
$monster = $em->getRepository(Monster::class)->find("7ca9c141-aaf8-44a5-9d04-b6f9923f3c66");
|
||||
break;
|
||||
case 3:
|
||||
// player should lose battle
|
||||
$character = $em->getRepository(Character::class)->find(11);
|
||||
$monster = $em->getRepository(Monster::class)->find(13);
|
||||
$character = $em->getRepository(Character::class)->find("24d71c26-f915-401c-8b3e-1932edf650ce");
|
||||
$monster = $em->getRepository(Monster::class)->find("09540b93-63c9-4d82-8501-f569f63dfc4c");
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -1331,7 +1335,7 @@ class BattleTest extends CoreModelTestCase
|
||||
public function testBufflistGoodguyAttackModifier()
|
||||
{
|
||||
$em = $this->getEntityManager();
|
||||
$player = $em->getRepository(Character::class)->find(1);
|
||||
$player = $em->getRepository(Character::class)->find("d363c077-234a-433d-834e-f1a1d3b281d8");
|
||||
$game = $this->getMockGame($player);
|
||||
|
||||
$player->addBuff(new Buff([
|
||||
@@ -1360,7 +1364,7 @@ class BattleTest extends CoreModelTestCase
|
||||
public function testBufflistGoodguyDefenseModifier()
|
||||
{
|
||||
$em = $this->getEntityManager();
|
||||
$player = $em->getRepository(Character::class)->find(1);
|
||||
$player = $em->getRepository(Character::class)->find("d363c077-234a-433d-834e-f1a1d3b281d8");
|
||||
$game = $this->getMockGame($player);
|
||||
|
||||
$player->addBuff(new Buff([
|
||||
@@ -1389,7 +1393,7 @@ class BattleTest extends CoreModelTestCase
|
||||
public function testBufflistGoodguyDamageModifier()
|
||||
{
|
||||
$em = $this->getEntityManager();
|
||||
$player = $em->getRepository(Character::class)->find(1);
|
||||
$player = $em->getRepository(Character::class)->find("d363c077-234a-433d-834e-f1a1d3b281d8");
|
||||
$game = $this->getMockGame($player);
|
||||
|
||||
$player->addBuff(new Buff([
|
||||
@@ -1418,7 +1422,7 @@ class BattleTest extends CoreModelTestCase
|
||||
public function testBufflistBadguyAttackModifier()
|
||||
{
|
||||
$em = $this->getEntityManager();
|
||||
$player = $em->getRepository(Character::class)->find(1);
|
||||
$player = $em->getRepository(Character::class)->find("d363c077-234a-433d-834e-f1a1d3b281d8");
|
||||
$game = $this->getMockGame($player);
|
||||
|
||||
$player->addBuff(new Buff([
|
||||
@@ -1447,7 +1451,7 @@ class BattleTest extends CoreModelTestCase
|
||||
public function testBufflistBadguyDefenseModifier()
|
||||
{
|
||||
$em = $this->getEntityManager();
|
||||
$player = $em->getRepository(Character::class)->find(1);
|
||||
$player = $em->getRepository(Character::class)->find("d363c077-234a-433d-834e-f1a1d3b281d8");
|
||||
$game = $this->getMockGame($player);
|
||||
|
||||
$player->addBuff(new Buff([
|
||||
@@ -1476,7 +1480,7 @@ class BattleTest extends CoreModelTestCase
|
||||
public function testBufflistBadguyDamageModifier()
|
||||
{
|
||||
$em = $this->getEntityManager();
|
||||
$player = $em->getRepository(Character::class)->find(1);
|
||||
$player = $em->getRepository(Character::class)->find("d363c077-234a-433d-834e-f1a1d3b281d8");
|
||||
$game = $this->getMockGame($player);
|
||||
|
||||
$player->addBuff(new Buff([
|
||||
|
||||
@@ -5,6 +5,7 @@ namespace LotGD\Core\Tests\DefectiveModule;
|
||||
use LotGD\Core\Exceptions\CoreException;
|
||||
use LotGD\Core\Game;
|
||||
use LotGD\Core\Events\EventContext;
|
||||
use LotGD\Core\Models\Character;
|
||||
use LotGD\Core\Module as ModuleInterface;
|
||||
use LotGD\Core\Models\Module as ModuleModel;
|
||||
|
||||
@@ -18,6 +19,9 @@ class Module implements ModuleInterface {
|
||||
|
||||
public static function onRegister(Game $g, ModuleModel $module)
|
||||
{
|
||||
$character = Character::create(["name" => "Test"]);
|
||||
$character->save($g->getEntityManager());
|
||||
|
||||
throw new DefectiveModuleException("Exception");
|
||||
}
|
||||
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
entityNamespace: "LotGD\\Core\\Tests\\FakeModule\\Models\\"
|
||||
subscriptionPatterns:
|
||||
- "e/lotgd/core/tests/event"
|
||||
- "e/lotgd/core/tests/defective-event"
|
||||
- "e/lotgd/core/tests/gom-event"
|
||||
|
||||
@@ -96,6 +96,7 @@ class EventManagerTest extends CoreModelTestCase
|
||||
$library = 'lotgd/tests';
|
||||
|
||||
$em->subscribe($pattern, $class, $library);
|
||||
$this->getEntityManager()->flush();
|
||||
|
||||
$sub = EventSubscription::create([
|
||||
'pattern' => $pattern,
|
||||
|
||||
+26
-19
@@ -37,15 +37,16 @@ class DefaultSceneProvider implements EventHandler
|
||||
));
|
||||
}
|
||||
|
||||
$context->setDataField("scene", $g->getEntityManager()->getRepository(Scene::class)->find(1));
|
||||
$context->setDataField("scene", $g->getEntityManager()->getRepository(Scene::class)
|
||||
->find("30000000-0000-0000-0000-000000000001"));
|
||||
break;
|
||||
case 'h/lotgd/core/navigate-to/lotgd/tests/village':
|
||||
$v = $context->getDataField('viewpoint');
|
||||
|
||||
self::$actionGroups = [new ActionGroup('default', 'Title', 0)];
|
||||
self::$actionGroups[0]->setActions([
|
||||
new Action(2), // This is a real sceneId in game.yml
|
||||
new Action(101),
|
||||
new Action("30000000-0000-0000-0000-000000000002"), // This is a real sceneId in game.yml
|
||||
new Action("30000000-0000-0000-0000-000000000101"),
|
||||
]);
|
||||
$v->setActionGroups(self::$actionGroups);
|
||||
|
||||
@@ -128,7 +129,7 @@ class GameTest extends CoreModelTestCase
|
||||
|
||||
public function testSetGetCharacter()
|
||||
{
|
||||
$c = $this->getEntityManager()->getRepository(Character::class)->find(1);
|
||||
$c = $this->getEntityManager()->getRepository(Character::class)->find("10000000-0000-0000-0000-000000000001");
|
||||
|
||||
$this->g->setCharacter($c);
|
||||
$this->assertEquals($c, $this->g->getCharacter());
|
||||
@@ -136,7 +137,7 @@ class GameTest extends CoreModelTestCase
|
||||
|
||||
public function testGetViewpointException()
|
||||
{
|
||||
$c = $this->getEntityManager()->getRepository(Character::class)->find(1);
|
||||
$c = $this->getEntityManager()->getRepository(Character::class)->find("10000000-0000-0000-0000-000000000001");
|
||||
$this->g->setCharacter($c);
|
||||
|
||||
// There should'nt be any listeners to provide a default scene.
|
||||
@@ -146,7 +147,7 @@ class GameTest extends CoreModelTestCase
|
||||
|
||||
public function testGetViewpointStored()
|
||||
{
|
||||
$c = $this->getEntityManager()->getRepository(Character::class)->find(2);
|
||||
$c = $this->getEntityManager()->getRepository(Character::class)->find("10000000-0000-0000-0000-000000000002");
|
||||
$this->g->setCharacter($c);
|
||||
|
||||
$this->assertNotNull($this->g->getViewpoint());
|
||||
@@ -154,11 +155,12 @@ class GameTest extends CoreModelTestCase
|
||||
|
||||
public function testGetViewpointDefault()
|
||||
{
|
||||
$c = $this->getEntityManager()->getRepository(Character::class)->find(1);
|
||||
$c = $this->getEntityManager()->getRepository(Character::class)->find("10000000-0000-0000-0000-000000000001");
|
||||
$this->g->setCharacter($c);
|
||||
|
||||
$this->g->getEventManager()->subscribe('/h\/lotgd\/core\/default-scene/', DefaultSceneProvider::class, 'lotgd/core/tests');
|
||||
$this->g->getEventManager()->subscribe('/h\/lotgd\/core\/navigate-to\/.*/', DefaultSceneProvider::class, 'lotgd/core/tests');
|
||||
$this->getEntityManager()->flush();
|
||||
|
||||
$v = $this->g->getViewpoint();
|
||||
// Run it twice to make sure no additional DB operations happen.
|
||||
@@ -175,7 +177,7 @@ class GameTest extends CoreModelTestCase
|
||||
|
||||
public function testTakeActionNonExistant()
|
||||
{
|
||||
$c = $this->getEntityManager()->getRepository(Character::class)->find(1);
|
||||
$c = $this->getEntityManager()->getRepository(Character::class)->find("10000000-0000-0000-0000-000000000001");
|
||||
$this->g->setCharacter($c);
|
||||
|
||||
// For now, I cant seem to serialize a proper ActionGroup to store in
|
||||
@@ -188,7 +190,7 @@ class GameTest extends CoreModelTestCase
|
||||
|
||||
public function testTakeActionNavigate()
|
||||
{
|
||||
$c = $this->getEntityManager()->getRepository(Character::class)->find(3);
|
||||
$c = $this->getEntityManager()->getRepository(Character::class)->find("10000000-0000-0000-0000-000000000003");
|
||||
$this->g->setCharacter($c);
|
||||
|
||||
// For now, I cant seem to serialize a proper ActionGroup to store in
|
||||
@@ -209,13 +211,14 @@ class GameTest extends CoreModelTestCase
|
||||
public function testIfActionParametersAreRelayedToEvent()
|
||||
{
|
||||
/* @var $c Character */
|
||||
$c = $this->getEntityManager()->getRepository(Character::class)->find(2);
|
||||
$c = $this->getEntityManager()->getRepository(Character::class)->find("10000000-0000-0000-0000-000000000002");
|
||||
$this->g->setCharacter($c);
|
||||
|
||||
// subscribe event
|
||||
$this->g->getEventManager()->subscribe('#h/lotgd/core/navigate-to/lotgd/tests/paramaters#', DefaultSceneProvider::class, 'lotgd/core/tests');
|
||||
$this->getEntityManager()->flush();
|
||||
|
||||
$action = new Action(7, null, ["foo" => "baz"]);
|
||||
$action = new Action("30000000-0000-0000-0000-000000000007", null, ["foo" => "baz"]);
|
||||
$actionId = $action->getId();
|
||||
|
||||
$ag = new ActionGroup("group1", "Group 1", 5);
|
||||
@@ -238,13 +241,14 @@ class GameTest extends CoreModelTestCase
|
||||
public function testIfActionParametersTakePriorityToOtherParameters()
|
||||
{
|
||||
/* @var $c Character */
|
||||
$c = $this->getEntityManager()->getRepository(Character::class)->find(2);
|
||||
$c = $this->getEntityManager()->getRepository(Character::class)->find("10000000-0000-0000-0000-000000000002");
|
||||
$this->g->setCharacter($c);
|
||||
|
||||
// subscribe event
|
||||
$this->g->getEventManager()->subscribe('#h/lotgd/core/navigate-to/lotgd/tests/paramaters#', DefaultSceneProvider::class, 'lotgd/core/tests');
|
||||
$this->getEntityManager()->flush();
|
||||
|
||||
$action = new Action(7, null, ["foo" => "baz"]);
|
||||
$action = new Action("30000000-0000-0000-0000-000000000007", null, ["foo" => "baz"]);
|
||||
$actionId = $action->getId();
|
||||
|
||||
$ag = new ActionGroup("group1", "Group 1", 5);
|
||||
@@ -285,7 +289,7 @@ class GameTest extends CoreModelTestCase
|
||||
return $values;
|
||||
};
|
||||
|
||||
$c = $this->getEntityManager()->getRepository(Character::class)->find(3);
|
||||
$c = $this->getEntityManager()->getRepository(Character::class)->find("10000000-0000-0000-0000-000000000003");
|
||||
$this->g->setCharacter($c);
|
||||
|
||||
$v0 = $this->g->getViewpoint();
|
||||
@@ -295,9 +299,9 @@ class GameTest extends CoreModelTestCase
|
||||
$this->assertSame([
|
||||
"Parent Scene",
|
||||
[
|
||||
ActionGroup::DefaultGroup => [1],
|
||||
"lotgd/tests/none/child1" => [5],
|
||||
"lotgd/tests/none/child2" => [6],
|
||||
ActionGroup::DefaultGroup => ["30000000-0000-0000-0000-000000000001"],
|
||||
"lotgd/tests/none/child1" => ["30000000-0000-0000-0000-000000000005"],
|
||||
"lotgd/tests/none/child2" => ["30000000-0000-0000-0000-000000000006"],
|
||||
ActionGroup::HiddenGroup => [],
|
||||
]
|
||||
], $viewpointToArray($v1));
|
||||
@@ -307,7 +311,10 @@ class GameTest extends CoreModelTestCase
|
||||
$this->assertSame([
|
||||
"Child Scene 1",
|
||||
[
|
||||
ActionGroup::DefaultGroup => [6, 4],
|
||||
ActionGroup::DefaultGroup => [
|
||||
"30000000-0000-0000-0000-000000000006",
|
||||
"30000000-0000-0000-0000-000000000004"
|
||||
],
|
||||
ActionGroup::HiddenGroup => [],
|
||||
]
|
||||
], $viewpointToArray($v2));
|
||||
@@ -317,7 +324,7 @@ class GameTest extends CoreModelTestCase
|
||||
$this->assertSame([
|
||||
"Child Scene 2",
|
||||
[
|
||||
ActionGroup::DefaultGroup => [4],
|
||||
ActionGroup::DefaultGroup => ["30000000-0000-0000-0000-000000000004"],
|
||||
ActionGroup::HiddenGroup => [],
|
||||
]
|
||||
], $viewpointToArray($v3));
|
||||
|
||||
@@ -63,6 +63,9 @@ abstract class ModelTestCase extends \PHPUnit_Extensions_Database_TestCase
|
||||
|
||||
self::$em = EntityManager::create(["pdo" => self::$pdo], $configuration);
|
||||
|
||||
// Register uuid type
|
||||
\Doctrine\DBAL\Types\Type::addType('uuid', 'Ramsey\Uuid\Doctrine\UuidType');
|
||||
|
||||
// Create Schema
|
||||
$metaData = self::$em->getMetadataFactory()->getAllMetadata();
|
||||
$schemaTool = new SchemaTool(self::$em);
|
||||
|
||||
@@ -12,6 +12,7 @@ use LotGD\Core\Models\Character;
|
||||
use LotGD\Core\Models\CharacterProperty;
|
||||
use LotGD\Core\Tests\CoreModelTestCase;
|
||||
use LotGD\Core\Models\Repositories\CharacterRepository;
|
||||
use Ramsey\Uuid\UuidInterface;
|
||||
|
||||
/**
|
||||
* Tests the management of Characters
|
||||
@@ -26,13 +27,13 @@ class CharacterModelTest extends CoreModelTestCase
|
||||
*/
|
||||
public function testSoftDeletion()
|
||||
{
|
||||
$chars = $this->getEntityManager()->getRepository(Character::class)->find(3);
|
||||
$chars = $this->getEntityManager()->getRepository(Character::class)->find("10000000-0000-0000-0000-000000000003");
|
||||
$this->assertSame(null, $chars);
|
||||
|
||||
$allChars = $this->getEntityManager()->getRepository(Character::class)->findAll();
|
||||
$this->assertSame(2, count($allChars));
|
||||
|
||||
$char = $this->getEntityManager()->getRepository(Character::class)->find(1);
|
||||
$char = $this->getEntityManager()->getRepository(Character::class)->find("10000000-0000-0000-0000-000000000001");
|
||||
$char->delete($this->getEntityManager());
|
||||
$this->getEntityManager()->flush();
|
||||
$this->getEntityManager()->clear();
|
||||
@@ -101,7 +102,7 @@ class CharacterModelTest extends CoreModelTestCase
|
||||
|
||||
$em->flush();
|
||||
|
||||
$this->assertInternalType("int", $characterEntity->getId());
|
||||
$this->assertInstanceOf(UuidInterface::class, $characterEntity->getId());
|
||||
$this->assertSame(16, $characterEntity->getProperty("a property"));
|
||||
|
||||
$em->flush();
|
||||
@@ -142,7 +143,7 @@ class CharacterModelTest extends CoreModelTestCase
|
||||
$rowsBefore = count($em->getRepository(Character::class)->findAll());
|
||||
|
||||
// Delete one row
|
||||
$character = $em->getRepository(Character::class)->find(1);
|
||||
$character = $em->getRepository(Character::class)->find("10000000-0000-0000-0000-000000000001");
|
||||
$character->delete($em);
|
||||
|
||||
$em->clear();
|
||||
@@ -163,7 +164,7 @@ class CharacterModelTest extends CoreModelTestCase
|
||||
$em = $this->getEntityManager();
|
||||
|
||||
// test default values
|
||||
$firstCharacter = $em->getRepository(Character::class)->find(1);
|
||||
$firstCharacter = $em->getRepository(Character::class)->find("10000000-0000-0000-0000-000000000001");
|
||||
$this->assertSame(5, $firstCharacter->getProperty("dragonkills", 5));
|
||||
$this->assertNotSame(5, $firstCharacter->getProperty("dragonkills", "5"));
|
||||
$this->assertSame("hanniball", $firstCharacter->getProperty("petname", "hanniball"));
|
||||
@@ -226,6 +227,7 @@ class CharacterModelTest extends CoreModelTestCase
|
||||
|
||||
$eventManager->subscribe("#h/lotgd/core/getCharacterAttack#", get_class($detectionClass), "test");
|
||||
$eventManager->subscribe("#h/lotgd/core/getCharacterDefense#", get_class($detectionClass), "test");
|
||||
$this->getEntityManager()->flush();
|
||||
|
||||
$this->assertSame($level*2, $character1->getAttack());
|
||||
$this->assertSame($level*4, $character2->getDefense());
|
||||
|
||||
@@ -24,8 +24,8 @@ class MessageModelTest extends CoreModelTestCase
|
||||
$em = $this->getEntityManager();
|
||||
$mm=new MessageManager();
|
||||
|
||||
$character1 = $em->getRepository(Character::class)->find(1);
|
||||
$character2 = $em->getRepository(Character::class)->find(4);
|
||||
$character1 = $em->getRepository(Character::class)->find("10000000-0000-0000-0000-000000000001");
|
||||
$character2 = $em->getRepository(Character::class)->find("10000000-0000-0000-0000-000000000004");
|
||||
|
||||
$thread1 = $em->getRepository(MessageThread::class)->findOrCreateFor([$character1, $character2]);
|
||||
$thread2 = $em->getRepository(MessageThread::class)->findOrCreateFor([$character2, $character1]);
|
||||
@@ -42,8 +42,8 @@ class MessageModelTest extends CoreModelTestCase
|
||||
$em->flush();
|
||||
$em->clear();
|
||||
|
||||
$character1 = $em->getRepository(Character::class)->find(1);
|
||||
$character2 = $em->getRepository(Character::class)->find(4);
|
||||
$character1 = $em->getRepository(Character::class)->find("10000000-0000-0000-0000-000000000001");
|
||||
$character2 = $em->getRepository(Character::class)->find("10000000-0000-0000-0000-000000000004");
|
||||
|
||||
$thread1 = $em->getRepository(MessageThread::class)->findOrCreateFor([$character1, $character2]);
|
||||
|
||||
@@ -62,10 +62,10 @@ class MessageModelTest extends CoreModelTestCase
|
||||
$em = $this->getEntityManager();
|
||||
$mm=new MessageManager();
|
||||
|
||||
$character1 = $em->getRepository(Character::class)->find(1);
|
||||
$character2 = $em->getRepository(Character::class)->find(2);
|
||||
$character3 = $em->getRepository(Character::class)->find(3, NULL, NULL, CharacterRepository::INCLUDE_SOFTDELETED);
|
||||
$character4 = $em->getRepository(Character::class)->find(4);
|
||||
$character1 = $em->getRepository(Character::class)->find("10000000-0000-0000-0000-000000000001");
|
||||
$character2 = $em->getRepository(Character::class)->find("10000000-0000-0000-0000-000000000002");
|
||||
$character3 = $em->getRepository(Character::class)->findWithSoftDeleted("10000000-0000-0000-0000-000000000003");
|
||||
$character4 = $em->getRepository(Character::class)->find("10000000-0000-0000-0000-000000000004");
|
||||
|
||||
$thread1 = $em->getRepository(MessageThread::class)->findOrCreateFor([$character1, $character2, $character3, $character4]);
|
||||
$thread2 = $em->getRepository(MessageThread::class)->findOrCreateFor([$character4, $character2, $character1, $character3]);
|
||||
@@ -89,11 +89,11 @@ class MessageModelTest extends CoreModelTestCase
|
||||
$this->assertSame(1, count($character4->getMessageThreads()));
|
||||
|
||||
$em->flush();
|
||||
|
||||
$character1 = $em->getRepository(Character::class)->find(1);
|
||||
$character2 = $em->getRepository(Character::class)->find(2);
|
||||
$character3 = $em->getRepository(Character::class)->find(3, NULL, NULL, CharacterRepository::INCLUDE_SOFTDELETED);
|
||||
$character4 = $em->getRepository(Character::class)->find(4);
|
||||
|
||||
$character1 = $em->getRepository(Character::class)->find("10000000-0000-0000-0000-000000000001");
|
||||
$character2 = $em->getRepository(Character::class)->find("10000000-0000-0000-0000-000000000002");
|
||||
$character3 = $em->getRepository(Character::class)->findWithSoftDeleted("10000000-0000-0000-0000-000000000003");
|
||||
$character4 = $em->getRepository(Character::class)->find("10000000-0000-0000-0000-000000000004");
|
||||
|
||||
$thread1 = $em->getRepository(MessageThread::class)->findOrCreateFor([$character1, $character2, $character3, $character4]);
|
||||
|
||||
@@ -111,8 +111,8 @@ class MessageModelTest extends CoreModelTestCase
|
||||
$em = $this->getEntityManager();
|
||||
$mm=new MessageManager();
|
||||
|
||||
$character1 = $em->getRepository(Character::class)->find(1);
|
||||
$character2 = $em->getRepository(Character::class)->find(2);
|
||||
$character1 = $em->getRepository(Character::class)->find("10000000-0000-0000-0000-000000000001");
|
||||
$character2 = $em->getRepository(Character::class)->find("10000000-0000-0000-0000-000000000002");
|
||||
|
||||
$thread1 = $em->getRepository(MessageThread::class)->findOrCreateReadonlyFor([$character1]);
|
||||
$thread2 = $em->getRepository(MessageThread::class)->findOrCreateReadonlyFor([$character2]);
|
||||
@@ -124,9 +124,9 @@ class MessageModelTest extends CoreModelTestCase
|
||||
|
||||
$em->flush();
|
||||
$em->clear();
|
||||
|
||||
$character1 = $em->getRepository(Character::class)->find(1);
|
||||
$character2 = $em->getRepository(Character::class)->find(2);
|
||||
|
||||
$character1 = $em->getRepository(Character::class)->find("10000000-0000-0000-0000-000000000001");
|
||||
$character2 = $em->getRepository(Character::class)->find("10000000-0000-0000-0000-000000000002");
|
||||
|
||||
$thread1 = $em->getRepository(MessageThread::class)->findOrCreateReadonlyFor([$character1]);
|
||||
$thread2 = $em->getRepository(MessageThread::class)->findOrCreateReadonlyFor([$character2]);
|
||||
@@ -154,8 +154,8 @@ class MessageModelTest extends CoreModelTestCase
|
||||
$em = $this->getEntityManager();
|
||||
$mm=new MessageManager();
|
||||
|
||||
$character1 = $em->getRepository(Character::class)->find(1);
|
||||
$character2 = $em->getRepository(Character::class)->find(2);
|
||||
$character1 = $em->getRepository(Character::class)->find("10000000-0000-0000-0000-000000000001");
|
||||
$character2 = $em->getRepository(Character::class)->find("10000000-0000-0000-0000-000000000002");
|
||||
|
||||
$thread1 = $em->getRepository(MessageThread::class)->findOrCreateReadonlyFor([$character1, $character2]);
|
||||
$thread2 = $em->getRepository(MessageThread::class)->findOrCreateFor([$character1, $character2]);
|
||||
@@ -166,9 +166,9 @@ class MessageModelTest extends CoreModelTestCase
|
||||
|
||||
$em->flush();
|
||||
$em->clear();
|
||||
|
||||
$character1 = $em->getRepository(Character::class)->find(1);
|
||||
$character2 = $em->getRepository(Character::class)->find(2);
|
||||
|
||||
$character1 = $em->getRepository(Character::class)->find("10000000-0000-0000-0000-000000000001");
|
||||
$character2 = $em->getRepository(Character::class)->find("10000000-0000-0000-0000-000000000002");
|
||||
|
||||
$thread1 = $em->getRepository(MessageThread::class)->findOrCreateReadonlyFor([$character1, $character2]);
|
||||
|
||||
|
||||
@@ -19,10 +19,10 @@ class MotDModelTest extends CoreModelTestCase
|
||||
{
|
||||
$em = $this->getEntityManager();
|
||||
|
||||
$author = $em->getRepository(Character::class)->find(1);
|
||||
$author = $em->getRepository(Character::class)->find("10000000-0000-0000-0000-000000000001");
|
||||
|
||||
// Test normal message
|
||||
$motd1 = $em->getRepository(MotD::class)->find(1);
|
||||
$motd1 = $em->getRepository(MotD::class)->find("20000000-0000-0000-0000-000000000001");
|
||||
$this->assertSame("This is the title", $motd1->getTitle());
|
||||
$this->assertSame("This is the body of the message", $motd1->getBody());
|
||||
$this->assertSame($author, $motd1->getAuthor());
|
||||
@@ -30,14 +30,14 @@ class MotDModelTest extends CoreModelTestCase
|
||||
$this->assertFalse($motd1->getSystemMessage());
|
||||
|
||||
// Test System message
|
||||
$motd2 = $em->getRepository(MotD::class)->find(2);
|
||||
$motd2 = $em->getRepository(MotD::class)->find("20000000-0000-0000-0000-000000000002");
|
||||
$this->assertTrue($motd2->getSystemMessage());
|
||||
$this->assertNotSame($motd2->getAuthor(), $motd2->getApparantAuthor());
|
||||
$this->assertSame($author, $motd2->getAuthor());
|
||||
$this->assertNotSame("Deleted Character Name", $motd2->getAuthor()->getDisplayName());
|
||||
|
||||
// Test message with unknown author
|
||||
$motd3 = $em->getRepository(Motd::class)->find(3);
|
||||
$motd3 = $em->getRepository(Motd::class)->find("20000000-0000-0000-0000-000000000003");
|
||||
$this->assertSame("Deleted Testcharacter", $motd3->getAuthor()->getDisplayName());
|
||||
}
|
||||
|
||||
@@ -45,7 +45,7 @@ class MotDModelTest extends CoreModelTestCase
|
||||
{
|
||||
$em = $this->getEntityManager();
|
||||
|
||||
$time1 = $em->getRepository(MotD::class)->find(1)->getCreationTime();
|
||||
$time1 = $em->getRepository(MotD::class)->find("20000000-0000-0000-0000-000000000001")->getCreationTime();
|
||||
$time2 = new \DateTime("2016-05-03 14:19:12");
|
||||
$time3 = $time2->setTimezone(new \DateTimeZone("Europe/Zurich"));
|
||||
$time4 = new \DateTime("2016-05-03 14:19:12");
|
||||
@@ -63,13 +63,13 @@ class MotDModelTest extends CoreModelTestCase
|
||||
{
|
||||
return [
|
||||
[[
|
||||
"author" => 1,
|
||||
"author" => "10000000-0000-0000-0000-000000000001",
|
||||
"title" => "ABC_\"EFG",
|
||||
"body" => "Lorem îpsum etc pp",
|
||||
"systemMessage" => false,
|
||||
]],
|
||||
[[
|
||||
"author" => 1,
|
||||
"author" => "10000000-0000-0000-0000-000000000001",
|
||||
"title" => "AnotherOne",
|
||||
"body" => "Test a Second One",
|
||||
"systemMessage" => true,
|
||||
@@ -87,10 +87,9 @@ class MotDModelTest extends CoreModelTestCase
|
||||
$motdCreationArguments["author"] = $em->getRepository(Character::class)->find($motdCreationArguments["author"]);
|
||||
|
||||
$motd = MotD::create($motdCreationArguments);
|
||||
$motd->save($em);
|
||||
|
||||
$id = $motd->getId();
|
||||
|
||||
|
||||
$em->persist($motd);
|
||||
$em->flush();
|
||||
$em->clear();
|
||||
|
||||
|
||||
@@ -3,8 +3,6 @@ declare(strict_types=1);
|
||||
|
||||
namespace LotGD\Core\Tests\Models;
|
||||
|
||||
use Doctrine\Common\Collections\ArrayCollection;
|
||||
|
||||
use LotGD\Core\Exceptions\ArgumentException;
|
||||
use LotGD\Core\Models\{Scene, SceneConnection, SceneConnectionGroup};
|
||||
use LotGD\Core\Tests\CoreModelTestCase;
|
||||
@@ -54,6 +52,8 @@ class SceneModelTest extends CoreModelTestCase
|
||||
|
||||
// create new scene, flush and clear. Number of scenes in db should be +1
|
||||
$newScene = Scene::create($this->getTestSceneData());
|
||||
$id = $newScene->getId();
|
||||
|
||||
$newScene->save($em);
|
||||
$this->flushAndClear();
|
||||
unset($newScene);
|
||||
@@ -63,7 +63,7 @@ class SceneModelTest extends CoreModelTestCase
|
||||
$this->assertSame($n1 + 1, $n2);
|
||||
|
||||
// fetch new scene, delete, flush and clear.
|
||||
$newScene = $em->getRepository(Scene::class)->findOneBy($this->getTestSceneData());
|
||||
$newScene = $em->getRepository(Scene::class)->find($id);
|
||||
$newScene->delete($em);
|
||||
$this->flushAndClear();
|
||||
|
||||
@@ -87,7 +87,7 @@ class SceneModelTest extends CoreModelTestCase
|
||||
// create new scene, connect to another one. Number of scenes must be +1, number of connections must be +1
|
||||
// this tests for cascade=persist
|
||||
$scene = Scene::create($this->getTestSceneData());
|
||||
$scene->connect($em->getRepository(Scene::class)->find(1));
|
||||
$scene->connect($em->getRepository(Scene::class)->find("30000000-0000-0000-0000-000000000001"));
|
||||
$scene->save($em);
|
||||
$this->flushAndClear();
|
||||
unset($scene);
|
||||
@@ -144,7 +144,7 @@ class SceneModelTest extends CoreModelTestCase
|
||||
public function testGetters()
|
||||
{
|
||||
$em = $this->getEntityManager();
|
||||
$scene = $em->getRepository(Scene::class)->find(2);
|
||||
$scene = $em->getRepository(Scene::class)->find("30000000-0000-0000-0000-000000000002");
|
||||
|
||||
$this->assertEquals("The Forest", $scene->getTitle());
|
||||
$this->assertEquals("This is a very dangerous and dark forest", $scene->getDescription());
|
||||
@@ -154,7 +154,7 @@ class SceneModelTest extends CoreModelTestCase
|
||||
|
||||
public function testIfHasConnectionGroupReturnsTrueIfConnectionGroupExists()
|
||||
{
|
||||
$scene = $this->getEntityManager()->getRepository(Scene::class)->find(1);
|
||||
$scene = $this->getEntityManager()->getRepository(Scene::class)->find( "30000000-0000-0000-0000-000000000001");
|
||||
|
||||
$this->assertTrue($scene->hasConnectionGroup("lotgd/tests/village/outside"));
|
||||
$this->assertTrue($scene->hasConnectionGroup("lotgd/tests/village/market"));
|
||||
@@ -163,14 +163,14 @@ class SceneModelTest extends CoreModelTestCase
|
||||
|
||||
public function testIfHasConnectionGroupReturnsFalseIfConnectionGroupDoesNotExist()
|
||||
{
|
||||
$scene2 = $this->getEntityManager()->getRepository(Scene::class)->find(2);
|
||||
$scene2 = $this->getEntityManager()->getRepository(Scene::class)->find( "30000000-0000-0000-0000-000000000002");
|
||||
|
||||
$this->assertFalse($scene2->hasConnectionGroup("lotgd/tests/village/outside"));
|
||||
$this->assertFalse($scene2->hasConnectionGroup("lotgd/tests/village/market"));
|
||||
$this->assertFalse($scene2->hasConnectionGroup("lotgd/tests/village/empty"));
|
||||
|
||||
|
||||
$scene1 = $this->getEntityManager()->getRepository(Scene::class)->find(1);
|
||||
$scene1 = $this->getEntityManager()->getRepository(Scene::class)->find("30000000-0000-0000-0000-000000000001");
|
||||
|
||||
$this->assertFalse($scene1->hasConnectionGroup("lotgd/tests/village/23426"));
|
||||
}
|
||||
@@ -178,7 +178,7 @@ class SceneModelTest extends CoreModelTestCase
|
||||
public function testIfAddConnectionGroupWorks()
|
||||
{
|
||||
$connectionGroup = new SceneConnectionGroup("lotgd/tests/village/new", "New Street");
|
||||
$scene = $this->getEntityManager()->getRepository(Scene::class)->find(1);
|
||||
$scene = $this->getEntityManager()->getRepository(Scene::class)->find("30000000-0000-0000-0000-000000000001");
|
||||
|
||||
$this->assertFalse($scene->hasConnectionGroup("lotgd/tests/village/new"));
|
||||
|
||||
@@ -191,8 +191,9 @@ class SceneModelTest extends CoreModelTestCase
|
||||
|
||||
public function testIfAddConnectionGroupThrowsArgumentExceptionIfGroupIsAlreadyAssignedToItself()
|
||||
{
|
||||
$scene = $this->getEntityManager()->getRepository(Scene::class)->find(1);
|
||||
$connectionGroup = $this->getEntityManager()->getRepository(SceneConnectionGroup::class)->findOneBy(["scene" => 1, "name" => "lotgd/tests/village/outside"]);
|
||||
$scene = $this->getEntityManager()->getRepository(Scene::class)->find("30000000-0000-0000-0000-000000000001");
|
||||
$connectionGroup = $this->getEntityManager()->getRepository(SceneConnectionGroup::class)
|
||||
->findOneBy(["scene" => "30000000-0000-0000-0000-000000000001", "name" => "lotgd/tests/village/outside"]);
|
||||
|
||||
$this->expectException(ArgumentException::class);
|
||||
$scene->addConnectionGroup($connectionGroup);
|
||||
@@ -200,8 +201,9 @@ class SceneModelTest extends CoreModelTestCase
|
||||
|
||||
public function testIfAddConnectionGroupThrowsArgumentExceptionIfGroupIsAlreadyAssignedToSomwhereElse()
|
||||
{
|
||||
$scene = $this->getEntityManager()->getRepository(Scene::class)->find(2);
|
||||
$connectionGroup = $this->getEntityManager()->getRepository(SceneConnectionGroup::class)->findOneBy(["scene" => 1, "name" => "lotgd/tests/village/outside"]);
|
||||
$scene = $this->getEntityManager()->getRepository(Scene::class)->find("30000000-0000-0000-0000-000000000002");
|
||||
$connectionGroup = $this->getEntityManager()->getRepository(SceneConnectionGroup::class)
|
||||
->findOneBy(["scene" => "30000000-0000-0000-0000-000000000001", "name" => "lotgd/tests/village/outside"]);
|
||||
|
||||
$this->expectException(ArgumentException::class);
|
||||
$scene->addConnectionGroup($connectionGroup);
|
||||
@@ -209,8 +211,9 @@ class SceneModelTest extends CoreModelTestCase
|
||||
|
||||
public function testifDropConnectionGroupWorks()
|
||||
{
|
||||
$scene = $this->getEntityManager()->getRepository(Scene::class)->find(1);
|
||||
$connectionGroup = $this->getEntityManager()->getRepository(SceneConnectionGroup::class)->findOneBy(["scene" => 1, "name" => "lotgd/tests/village/outside"]);
|
||||
$scene = $this->getEntityManager()->getRepository(Scene::class)->find("30000000-0000-0000-0000-000000000001");
|
||||
$connectionGroup = $this->getEntityManager()->getRepository(SceneConnectionGroup::class)
|
||||
->findOneBy(["scene" => "30000000-0000-0000-0000-000000000001", "name" => "lotgd/tests/village/outside"]);
|
||||
|
||||
$this->assertTrue($scene->hasConnectionGroup("lotgd/tests/village/outside"));
|
||||
|
||||
@@ -223,8 +226,9 @@ class SceneModelTest extends CoreModelTestCase
|
||||
|
||||
public function testIfDropConnectionGroupThrowsArgumentExceptionIfEntityIsRemovedFromNonOwningScene()
|
||||
{
|
||||
$scene = $this->getEntityManager()->getRepository(Scene::class)->find(2);
|
||||
$connectionGroup = $this->getEntityManager()->getRepository(SceneConnectionGroup::class)->findOneBy(["scene" => 1, "name" => "lotgd/tests/village/outside"]);
|
||||
$scene = $this->getEntityManager()->getRepository(Scene::class)->find("30000000-0000-0000-0000-000000000002");
|
||||
$connectionGroup = $this->getEntityManager()->getRepository(SceneConnectionGroup::class)
|
||||
->findOneBy(["scene" => "30000000-0000-0000-0000-000000000001", "name" => "lotgd/tests/village/outside"]);
|
||||
|
||||
$this->expectException(ArgumentException::class);
|
||||
$scene->dropConnectionGroup($connectionGroup);
|
||||
@@ -232,8 +236,8 @@ class SceneModelTest extends CoreModelTestCase
|
||||
|
||||
public function testIfGetConnectedScenesReturnsConnectedScenes()
|
||||
{
|
||||
$scene1 = $this->getEntityManager()->getRepository(Scene::class)->find(1);
|
||||
$scene2 = $this->getEntityManager()->getRepository(Scene::class)->find(2);
|
||||
$scene1 = $this->getEntityManager()->getRepository(Scene::class)->find("30000000-0000-0000-0000-000000000001");
|
||||
$scene2 = $this->getEntityManager()->getRepository(Scene::class)->find("30000000-0000-0000-0000-000000000002");
|
||||
|
||||
$this->assertCount(3, $scene1->getConnectedScenes());
|
||||
$this->assertCount(1, $scene2->getConnectedScenes());
|
||||
@@ -246,9 +250,9 @@ class SceneModelTest extends CoreModelTestCase
|
||||
|
||||
public function testIfIsConnectedToReturnsExpectedReturnValue()
|
||||
{
|
||||
$scene1 = $this->getEntityManager()->getRepository(Scene::class)->find(1);
|
||||
$scene2 = $this->getEntityManager()->getRepository(Scene::class)->find(2);
|
||||
$scene5 = $this->getEntityManager()->getRepository(Scene::class)->find(5);
|
||||
$scene1 = $this->getEntityManager()->getRepository(Scene::class)->find("30000000-0000-0000-0000-000000000001");
|
||||
$scene2 = $this->getEntityManager()->getRepository(Scene::class)->find("30000000-0000-0000-0000-000000000002");
|
||||
$scene5 = $this->getEntityManager()->getRepository(Scene::class)->find("30000000-0000-0000-0000-000000000005");
|
||||
|
||||
$this->assertTrue($scene1->isConnectedTo($scene2));
|
||||
$this->assertTrue($scene2->isConnectedTo($scene1));
|
||||
@@ -260,8 +264,8 @@ class SceneModelTest extends CoreModelTestCase
|
||||
|
||||
public function testIfTwoScenesCanGetConnected()
|
||||
{
|
||||
$scene1 = $this->getEntityManager()->getRepository(Scene::class)->find(2);
|
||||
$scene2 = $this->getEntityManager()->getRepository(Scene::class)->find(5);
|
||||
$scene1 = $this->getEntityManager()->getRepository(Scene::class)->find("30000000-0000-0000-0000-000000000002");
|
||||
$scene2 = $this->getEntityManager()->getRepository(Scene::class)->find("30000000-0000-0000-0000-000000000005");
|
||||
|
||||
$scene1->connect($scene2);
|
||||
|
||||
@@ -275,8 +279,8 @@ class SceneModelTest extends CoreModelTestCase
|
||||
|
||||
public function testIfASceneConnectionGroupCanGetConnectedToAScene()
|
||||
{
|
||||
$scene1 = $this->getEntityManager()->getRepository(Scene::class)->find(1);
|
||||
$scene2 = $this->getEntityManager()->getRepository(Scene::class)->find(5);
|
||||
$scene1 = $this->getEntityManager()->getRepository(Scene::class)->find("30000000-0000-0000-0000-000000000001");
|
||||
$scene2 = $this->getEntityManager()->getRepository(Scene::class)->find("30000000-0000-0000-0000-000000000005");
|
||||
|
||||
$scene1->getConnectionGroup("lotgd/tests/village/outside")->connect($scene2);
|
||||
|
||||
@@ -290,8 +294,8 @@ class SceneModelTest extends CoreModelTestCase
|
||||
|
||||
public function testIfASceneCanGetConnectedToASceneConnectionGroup()
|
||||
{
|
||||
$scene1 = $this->getEntityManager()->getRepository(Scene::class)->find(1);
|
||||
$scene2 = $this->getEntityManager()->getRepository(Scene::class)->find(5);
|
||||
$scene1 = $this->getEntityManager()->getRepository(Scene::class)->find("30000000-0000-0000-0000-000000000001");
|
||||
$scene2 = $this->getEntityManager()->getRepository(Scene::class)->find("30000000-0000-0000-0000-000000000005");
|
||||
|
||||
$scene2->connect($scene1->getConnectionGroup("lotgd/tests/village/outside"));
|
||||
|
||||
@@ -305,8 +309,8 @@ class SceneModelTest extends CoreModelTestCase
|
||||
|
||||
public function testIfASceneConnectionGroupCanGetConnectedToAnotherSceneConnectionGroup()
|
||||
{
|
||||
$scene1 = $this->getEntityManager()->getRepository(Scene::class)->find(1);
|
||||
$scene2 = $this->getEntityManager()->getRepository(Scene::class)->find(5);
|
||||
$scene1 = $this->getEntityManager()->getRepository(Scene::class)->find("30000000-0000-0000-0000-000000000001");
|
||||
$scene2 = $this->getEntityManager()->getRepository(Scene::class)->find("30000000-0000-0000-0000-000000000005");
|
||||
$scene2->addConnectionGroup(new SceneConnectionGroup("test/orphaned", "Orphan group"));
|
||||
|
||||
$scene1
|
||||
@@ -325,7 +329,7 @@ class SceneModelTest extends CoreModelTestCase
|
||||
|
||||
public function testIfConnectingASceneToItselfThrowsAnException()
|
||||
{
|
||||
$scene1 = $this->getEntityManager()->getRepository(Scene::class)->find(1);
|
||||
$scene1 = $this->getEntityManager()->getRepository(Scene::class)->find("30000000-0000-0000-0000-000000000001");
|
||||
|
||||
$this->expectException(ArgumentException::class);
|
||||
$scene1->connect($scene1);
|
||||
@@ -344,8 +348,8 @@ class SceneModelTest extends CoreModelTestCase
|
||||
|
||||
public function testIfConnectingASceneToAnotherAlreadyConnectedSceneThrowsAnException()
|
||||
{
|
||||
$scene1 = $this->getEntityManager()->getRepository(Scene::class)->find(1);
|
||||
$scene2 = $this->getEntityManager()->getRepository(Scene::class)->find(2);
|
||||
$scene1 = $this->getEntityManager()->getRepository(Scene::class)->find("30000000-0000-0000-0000-000000000001");
|
||||
$scene2 = $this->getEntityManager()->getRepository(Scene::class)->find("30000000-0000-0000-0000-000000000002");
|
||||
|
||||
$this->expectException(ArgumentException::class);
|
||||
$scene1->connect($scene2);
|
||||
|
||||
@@ -40,8 +40,8 @@ class ViewpointTest extends CoreModelTestCase
|
||||
$em = $this->getEntityManager();
|
||||
|
||||
// Test character with a characterScene
|
||||
$testCharacter = $em->getRepository(Character::class)->find(2);
|
||||
$this->assertSame(2, $testCharacter->getId());
|
||||
$testCharacter = $em->getRepository(Character::class)->find("10000000-0000-0000-0000-000000000002");
|
||||
$this->assertSame("10000000-0000-0000-0000-000000000002", (string)$testCharacter->getId());
|
||||
$characterScene = $testCharacter->getViewpoint();
|
||||
|
||||
$this->assertInstanceOf(Viewpoint::class, $characterScene);
|
||||
@@ -49,8 +49,8 @@ class ViewpointTest extends CoreModelTestCase
|
||||
$this->assertSame("This is the village.", $characterScene->getDescription());
|
||||
|
||||
// Test character without a characterScene
|
||||
$testCharacter = $em->getRepository(Character::class)->find(1);
|
||||
$this->assertSame(1, $testCharacter->getId());
|
||||
$testCharacter = $em->getRepository(Character::class)->find("10000000-0000-0000-0000-000000000001");
|
||||
$this->assertSame("10000000-0000-0000-0000-000000000001", (string)$testCharacter->getId());
|
||||
$characterScene = $testCharacter->getViewpoint();
|
||||
|
||||
$this->assertNull($characterScene);
|
||||
@@ -63,9 +63,9 @@ class ViewpointTest extends CoreModelTestCase
|
||||
{
|
||||
$em = $this->getEntityManager();
|
||||
|
||||
$testCharacter = $em->getRepository(Character::class)->find(2);
|
||||
$testCharacter = $em->getRepository(Character::class)->find("10000000-0000-0000-0000-000000000002");
|
||||
|
||||
$testScene = $em->getRepository(Scene::class)->find(2);
|
||||
$testScene = $em->getRepository(Scene::class)->find("30000000-0000-0000-0000-000000000002");
|
||||
|
||||
$this->assertSame("The Village", $testCharacter->getViewpoint()->getTitle());
|
||||
|
||||
@@ -82,12 +82,12 @@ class ViewpointTest extends CoreModelTestCase
|
||||
|
||||
$ag1 = new ActionGroup('id1', 'title1', 42);
|
||||
$ag1->setActions([
|
||||
new Action(1),
|
||||
new Action(2)
|
||||
new Action("30000000-0000-0000-0000-000000000001"),
|
||||
new Action("30000000-0000-0000-0000-000000000002")
|
||||
]);
|
||||
$ag2 = new ActionGroup('id2', 'title2', 101);
|
||||
$ag2->setActions([
|
||||
new Action(3)
|
||||
new Action("30000000-0000-0000-0000-000000000003")
|
||||
]);
|
||||
|
||||
$actionGroups = [
|
||||
@@ -95,19 +95,19 @@ class ViewpointTest extends CoreModelTestCase
|
||||
$ag2
|
||||
];
|
||||
|
||||
$input = $em->getRepository(Viewpoint::class)->find(2);
|
||||
$input = $em->getRepository(Viewpoint::class)->find("10000000-0000-0000-0000-000000000002");
|
||||
$input->setActionGroups($actionGroups);
|
||||
$input->save($em);
|
||||
|
||||
$em->clear();
|
||||
|
||||
$output = $em->getRepository(Viewpoint::class)->find(2);
|
||||
$output = $em->getRepository(Viewpoint::class)->find("10000000-0000-0000-0000-000000000002");
|
||||
$this->assertEquals($actionGroups, $output->getActionGroups());
|
||||
|
||||
$this->assertEquals($ag2, $input->findActionGroupById('id2'));
|
||||
$this->assertNull($input->findActionGroupById('not-there'));
|
||||
|
||||
$testAction = new Action(4);
|
||||
$testAction = new Action("30000000-0000-0000-0000-000000000004");
|
||||
$input->addActionToGroupId($testAction, 'not-there');
|
||||
$this->assertNull($input->findActionById($testAction->getId()));
|
||||
|
||||
@@ -124,13 +124,13 @@ class ViewpointTest extends CoreModelTestCase
|
||||
|
||||
$attachments = [$a1, $a2];
|
||||
|
||||
$input = $em->getRepository(Viewpoint::class)->find(2);
|
||||
$input = $em->getRepository(Viewpoint::class)->find("10000000-0000-0000-0000-000000000002");
|
||||
$input->setAttachments($attachments);
|
||||
$input->save($em);
|
||||
|
||||
$em->clear();
|
||||
|
||||
$output = $em->getRepository(Viewpoint::class)->find(2);
|
||||
$output = $em->getRepository(Viewpoint::class)->find("10000000-0000-0000-0000-000000000002");
|
||||
$this->assertEquals($attachments, $output->getAttachments());
|
||||
$this->assertEquals('baz', $output->getAttachments()[0]->getFoo());
|
||||
$this->assertEquals('fiz', $output->getAttachments()[1]->getFoo());
|
||||
@@ -140,9 +140,9 @@ class ViewpointTest extends CoreModelTestCase
|
||||
{
|
||||
$em = $this->getEntityManager();
|
||||
|
||||
$a1 = new Action(1);
|
||||
$a2 = new Action(2);
|
||||
$a3 = new Action(3);
|
||||
$a1 = new Action("30000000-0000-0000-0000-000000000001");
|
||||
$a2 = new Action("30000000-0000-0000-0000-000000000002");
|
||||
$a3 = new Action("30000000-0000-0000-0000-000000000003");
|
||||
|
||||
$ag1 = new ActionGroup('id1', 'title1', 42);
|
||||
$ag1->setActions([
|
||||
@@ -152,7 +152,7 @@ class ViewpointTest extends CoreModelTestCase
|
||||
]);
|
||||
$ag2 = new ActionGroup('id2', 'title2', 101);
|
||||
$ag2->setActions([
|
||||
new Action(4)
|
||||
new Action("30000000-0000-0000-0000-000000000004")
|
||||
]);
|
||||
|
||||
$actionGroups = [
|
||||
@@ -160,16 +160,16 @@ class ViewpointTest extends CoreModelTestCase
|
||||
$ag2
|
||||
];
|
||||
|
||||
$input = $em->getRepository(Viewpoint::class)->find(2);
|
||||
$input = $em->getRepository(Viewpoint::class)->find("10000000-0000-0000-0000-000000000002");
|
||||
$input->setActionGroups($actionGroups);
|
||||
$input->save($em);
|
||||
|
||||
$em->clear();
|
||||
|
||||
$output = $em->getRepository(Viewpoint::class)->find(2);
|
||||
$output = $em->getRepository(Viewpoint::class)->find("10000000-0000-0000-0000-000000000002");
|
||||
|
||||
// Not finding the scene ID should change nothing.
|
||||
$output->removeActionsWithSceneId(1000);
|
||||
$output->removeActionsWithSceneId("30000000-0000-0000-0000-000000001000");
|
||||
$this->assertEquals($actionGroups, $output->getActionGroups());
|
||||
|
||||
$ag1_output = new ActionGroup('id1', 'title1', 42);
|
||||
@@ -182,14 +182,14 @@ class ViewpointTest extends CoreModelTestCase
|
||||
$ag1_output,
|
||||
$ag2
|
||||
];
|
||||
$output->removeActionsWithSceneId(2);
|
||||
$output->removeActionsWithSceneId("30000000-0000-0000-0000-000000000002");
|
||||
$this->assertEquals($actionGroupsWithout2, $output->getActionGroups());
|
||||
}
|
||||
|
||||
public function testChangingSceneDescription()
|
||||
{
|
||||
$em = $this->getEntityManager();
|
||||
$testCharacter = $em->getRepository(Character::class)->find(2);
|
||||
$testCharacter = $em->getRepository(Character::class)->find("10000000-0000-0000-0000-000000000002");
|
||||
$characterScene = $testCharacter->getViewpoint();
|
||||
|
||||
$this->assertSame("This is the village.", $characterScene->getDescription());
|
||||
@@ -201,7 +201,7 @@ class ViewpointTest extends CoreModelTestCase
|
||||
public function testClearingSceneDescription()
|
||||
{
|
||||
$em = $this->getEntityManager();
|
||||
$testCharacter = $em->getRepository(Character::class)->find(2);
|
||||
$testCharacter = $em->getRepository(Character::class)->find("10000000-0000-0000-0000-000000000002");
|
||||
$characterScene = $testCharacter->getViewpoint();
|
||||
|
||||
$characterScene->clearDescription();
|
||||
@@ -215,9 +215,9 @@ class ViewpointTest extends CoreModelTestCase
|
||||
{
|
||||
$em = $this->getEntityManager();
|
||||
|
||||
$a1 = new Action(1);
|
||||
$a2 = new Action(2);
|
||||
$a3 = new Action(3);
|
||||
$a1 = new Action("30000000-0000-0000-0000-000000000001");
|
||||
$a2 = new Action("30000000-0000-0000-0000-000000000002");
|
||||
$a3 = new Action("30000000-0000-0000-0000-000000000003");
|
||||
|
||||
$ag1 = new ActionGroup('id1', 'title1', 42);
|
||||
$ag1->setActions([
|
||||
@@ -227,7 +227,7 @@ class ViewpointTest extends CoreModelTestCase
|
||||
]);
|
||||
$ag2 = new ActionGroup('id2', 'title2', 101);
|
||||
$ag2->setActions([
|
||||
new Action(4)
|
||||
new Action("30000000-0000-0000-0000-000000000004")
|
||||
]);
|
||||
|
||||
$actionGroups = [
|
||||
@@ -235,14 +235,14 @@ class ViewpointTest extends CoreModelTestCase
|
||||
$ag2
|
||||
];
|
||||
|
||||
$input = $em->getRepository(Viewpoint::class)->find(2);
|
||||
$input = $em->getRepository(Viewpoint::class)->find("10000000-0000-0000-0000-000000000002");
|
||||
$input->setActionGroups($actionGroups);
|
||||
$input->save($em);
|
||||
|
||||
$em->clear();
|
||||
|
||||
/** @var Viewpoint $viewpoint */
|
||||
$viewpoint = $em->getRepository(Viewpoint::class)->find(2);
|
||||
$viewpoint = $em->getRepository(Viewpoint::class)->find("10000000-0000-0000-0000-000000000002");
|
||||
|
||||
$actionGroupId1 = $viewpoint->findActionGroupById("id1");
|
||||
$actionGroupId2 = $viewpoint->findActionGroupById("id2");
|
||||
|
||||
@@ -13,6 +13,7 @@ use LotGD\Core\EventHandler;
|
||||
use LotGD\Core\EventManager;
|
||||
use LotGD\Core\EventSubscription;
|
||||
use LotGD\Core\LibraryConfiguration;
|
||||
use LotGD\Core\Models\Character;
|
||||
use LotGD\Core\ModuleManager;
|
||||
use LotGD\Core\Module;
|
||||
use LotGD\Core\Exceptions\ModuleAlreadyExistsException;
|
||||
@@ -201,11 +202,53 @@ class ModuleManagerTest extends CoreModelTestCase
|
||||
$this->assertEquals($name, $modules[1]->getLibrary());
|
||||
}
|
||||
|
||||
public function testRegisterWithFailedEvents()
|
||||
{
|
||||
$class = FakeModule::class;
|
||||
$name = 'lotgd/tests2';
|
||||
$subscriptions = array(
|
||||
'/pattern1/',
|
||||
'#asasd/',
|
||||
);
|
||||
$library = $this->getMockBuilder(LibraryConfiguration::class)
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
$library->method('getName')->willReturn($name);
|
||||
$library->method('getRootNamespace')->willReturn('LotGD\\Core\\Tests\\FakeModule\\');
|
||||
$library->method('getSubscriptionPatterns')->willReturn($subscriptions);
|
||||
|
||||
$eventManager = new EventManager($this->g);
|
||||
$this->game->method('getEventManager')->willReturn($eventManager);
|
||||
|
||||
$eventsBefore = count($eventManager->getSubscriptions());
|
||||
|
||||
$subscriptionThrownException = false;
|
||||
try {
|
||||
$this->mm->register($library);
|
||||
} catch(\Throwable $e) {
|
||||
$subscriptionThrownException = true;
|
||||
}
|
||||
|
||||
$this->assertTrue($subscriptionThrownException);
|
||||
|
||||
// Assert module has not been installed.
|
||||
$modules = $this->mm->getModules();
|
||||
$this->assertArrayNotHasKey(1, $modules);
|
||||
|
||||
// Assert events are not registered
|
||||
$eventsAfter = count($eventManager->getSubscriptions());
|
||||
|
||||
// Randomly flush
|
||||
$this->getEntityManager()->flush();
|
||||
|
||||
$this->assertSame($eventsBefore, $eventsAfter, "Events after failed subscription are actually more.");
|
||||
}
|
||||
|
||||
public function testRegisteringDefectiveModule()
|
||||
{
|
||||
$class = DefectiveModule::class;
|
||||
$name = "lotgd/tests3";
|
||||
$subscriptions = [];
|
||||
$subscriptions = ["#e/lotgd/core/tests/dat-event#"];
|
||||
$library = $this->getMockBuilder(LibraryConfiguration::class)
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
@@ -213,11 +256,12 @@ class ModuleManagerTest extends CoreModelTestCase
|
||||
$library->method('getRootNamespace')->willReturn('LotGD\\Core\\Tests\\DefectiveModule\\');
|
||||
$library->method('getSubscriptionPatterns')->willReturn($subscriptions);
|
||||
|
||||
$eventManager = $this->getMockBuilder(EventManager::class)
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
// Defective Module adds a character. Count the characters before.
|
||||
$charactersBefore = count($this->getEntityManager()->getRepository(Character::class)->findAll());
|
||||
|
||||
$eventManager = new EventManager($this->g);
|
||||
$this->game->method('getEventManager')->willReturn($eventManager);
|
||||
|
||||
$modulesBefore = $this->mm->getModules();
|
||||
try {
|
||||
// onRegister throws an exception. This exception needs to be captured and handled by mm->register without actually
|
||||
@@ -229,7 +273,21 @@ class ModuleManagerTest extends CoreModelTestCase
|
||||
}
|
||||
$modulesAfter = $this->mm->getModules();
|
||||
|
||||
$this->assertFalse($exceptionCaptured);
|
||||
$this->assertTrue($exceptionCaptured);
|
||||
$this->assertCount(count($modulesBefore), $modulesAfter);
|
||||
|
||||
// Make sure there are no event leftovers.
|
||||
$subscriptions_db = $eventManager->getSubscriptions();
|
||||
$found = 0;
|
||||
foreach($subscriptions_db as $subscription) {
|
||||
if (in_array($subscription->getPattern(), $subscriptions)) {
|
||||
$found++;
|
||||
}
|
||||
}
|
||||
$this->assertSame(0, $found);
|
||||
|
||||
// Count characters. Must stay the same!
|
||||
$charactersAfter = count($this->getEntityManager()->getRepository(Character::class)->findAll());
|
||||
$this->assertSame($charactersBefore, $charactersAfter, "Modules flushed did not get not added to the database.");
|
||||
}
|
||||
}
|
||||
|
||||
+13
-13
@@ -1,48 +1,48 @@
|
||||
characters:
|
||||
-
|
||||
id: 1
|
||||
id: "d363c077-234a-433d-834e-f1a1d3b281d8"
|
||||
name: "Player"
|
||||
displayName: "The Player"
|
||||
health: 100
|
||||
maxhealth: 100
|
||||
level: 10
|
||||
-
|
||||
id: 2
|
||||
id: "4d01c29b-d825-4bc7-9e6e-63525155fd37"
|
||||
name: "High Level Char"
|
||||
displayName: "High Level Char"
|
||||
health: 1000
|
||||
maxhealth: 1000
|
||||
level: 100
|
||||
-
|
||||
id: 3
|
||||
id: "c3792b61-4e34-4710-9871-65a68ac30bb4"
|
||||
name: "Low Level Char"
|
||||
displayName: "Low Level Char"
|
||||
health: 10
|
||||
maxhealth: 10
|
||||
level: 1
|
||||
-
|
||||
id: 4
|
||||
id: "6565b418-55f5-4a6b-8d92-a9ef81329912"
|
||||
name: "Low Damage Char"
|
||||
displayName: "Low Damage Char"
|
||||
health: 500
|
||||
maxhealth: 500
|
||||
level: 0
|
||||
-
|
||||
id: 10
|
||||
id: "539e4bb0-84d1-49ed-a697-ff449991e9b7"
|
||||
name: "Level 10 Character"
|
||||
displayName: "Level 10 Character"
|
||||
health: 100
|
||||
maxhealth: 100
|
||||
level: 10
|
||||
-
|
||||
id: 11
|
||||
id: "24d71c26-f915-401c-8b3e-1932edf650ce"
|
||||
name: "Level 11 Character"
|
||||
displayName: "Level 11 Character"
|
||||
health: 110
|
||||
maxhealth: 110
|
||||
level: 11
|
||||
-
|
||||
id: 13
|
||||
id: "1a9f63f2-3006-4e12-b272-4fd6be518a93"
|
||||
name: "Level 13 Character"
|
||||
displayName: "Level 13 Character"
|
||||
health: 130
|
||||
@@ -50,26 +50,26 @@ characters:
|
||||
level: 13
|
||||
monsters:
|
||||
-
|
||||
id: 1
|
||||
id: "de84c507-9673-44e7-b665-9e43416b9c2f"
|
||||
name: "Evil Monster"
|
||||
level: 5
|
||||
-
|
||||
id: 2
|
||||
id: "b636df29-f72d-4e2d-9850-982e783a9e94"
|
||||
name: "High Dragon"
|
||||
level: 100
|
||||
-
|
||||
id: 3
|
||||
id: "c004bcb6-a7c1-4f9a-abc2-1711c64e23a0"
|
||||
name: "Stone"
|
||||
level: 1
|
||||
-
|
||||
id: 10
|
||||
id: "f1d1f672-e308-420e-939f-cbb39285b222"
|
||||
name: "Level 10 Monster"
|
||||
level: 10
|
||||
-
|
||||
id: 11
|
||||
id: "7ca9c141-aaf8-44a5-9d04-b6f9923f3c66"
|
||||
name: "Level 11 Monster"
|
||||
level: 11
|
||||
-
|
||||
id: 13
|
||||
id: "09540b93-63c9-4d82-8501-f569f63dfc4c"
|
||||
name: "Level 13 Monster"
|
||||
level: 13
|
||||
@@ -1,18 +1,18 @@
|
||||
characters:
|
||||
-
|
||||
id: 1
|
||||
id: "10000000-0000-0000-0000-000000000001"
|
||||
name: "Testcharacter 1"
|
||||
displayName: "Testcharacter 1"
|
||||
health: 0
|
||||
maxhealth: 100
|
||||
-
|
||||
id: 2
|
||||
id: "10000000-0000-0000-0000-000000000002"
|
||||
name: "Testcharacter 2"
|
||||
displayName: "Testcharacter 2"
|
||||
health: 90
|
||||
maxhealth: 90
|
||||
-
|
||||
id: 3
|
||||
id: "10000000-0000-0000-0000-000000000003"
|
||||
name: "Testcharacter 3"
|
||||
displayName: "Testcharacter 3 (deleted)"
|
||||
health: 90
|
||||
@@ -20,6 +20,6 @@ characters:
|
||||
deletedAt: "2011-11-11 11:11:11"
|
||||
character_properties:
|
||||
-
|
||||
owner_id: 1
|
||||
owner_id: "10000000-0000-0000-0000-000000000001"
|
||||
propertyName: "test"
|
||||
propertyValue: 's:5:"hallo";'
|
||||
+25
-25
@@ -1,19 +1,19 @@
|
||||
characters:
|
||||
-
|
||||
id: 1
|
||||
id: "10000000-0000-0000-0000-000000000001"
|
||||
name: "Char without a Scene"
|
||||
displayName: "A"
|
||||
-
|
||||
id: 2
|
||||
id: "10000000-0000-0000-0000-000000000002"
|
||||
name: "Char with a Scene"
|
||||
displayName: "B"
|
||||
-
|
||||
id: 3
|
||||
id: "10000000-0000-0000-0000-000000000003"
|
||||
name: "Char without a Scene"
|
||||
displayName: "C"
|
||||
viewpoints:
|
||||
-
|
||||
owner_id: 2
|
||||
owner_id: "10000000-0000-0000-0000-000000000002"
|
||||
title: "The Village"
|
||||
description: "This is the village."
|
||||
template: "lotgd/tests/village"
|
||||
@@ -22,74 +22,74 @@ viewpoints:
|
||||
actionGroups: "a:0:{}"
|
||||
scenes:
|
||||
-
|
||||
id: 1
|
||||
id: "30000000-0000-0000-0000-000000000001"
|
||||
title: "The Village"
|
||||
description: "This is the village."
|
||||
template: "lotgd/tests/village"
|
||||
-
|
||||
id: 2
|
||||
id: "30000000-0000-0000-0000-000000000002"
|
||||
title: "The Forest"
|
||||
description: "This is a very dangerous and dark forest"
|
||||
template: "lotgd/tests/forest"
|
||||
-
|
||||
id: 3
|
||||
id: "30000000-0000-0000-0000-000000000003"
|
||||
title: "The Weaponry"
|
||||
description: "This is the place where you can buy awesome weapons"
|
||||
template: "lotgd/tests/weaponry"
|
||||
-
|
||||
id: 4
|
||||
id: "30000000-0000-0000-0000-000000000004"
|
||||
title: "Parent Scene"
|
||||
description: "This is a parent scene that connects to two children."
|
||||
template: "lotgd/tests/none"
|
||||
-
|
||||
id: 5
|
||||
id: "30000000-0000-0000-0000-000000000005"
|
||||
title: "Child Scene 1"
|
||||
description: "This is a parent scene that connects to two children."
|
||||
template: "lotgd/tests/none"
|
||||
-
|
||||
id: 6
|
||||
id: "30000000-0000-0000-0000-000000000006"
|
||||
title: "Child Scene 2"
|
||||
description: "This is a parent scene that connects to two children."
|
||||
template: "lotgd/tests/none"
|
||||
-
|
||||
id: 7
|
||||
id: "30000000-0000-0000-0000-000000000007"
|
||||
title: "Parameter test"
|
||||
description: "This is a parameter test"
|
||||
template: "lotgd/tests/paramaters"
|
||||
scene_connection_groups:
|
||||
-
|
||||
scene: 4
|
||||
scene: "30000000-0000-0000-0000-000000000004"
|
||||
name: "lotgd/tests/none/child1"
|
||||
title: "Child 1"
|
||||
-
|
||||
scene: 4
|
||||
scene: "30000000-0000-0000-0000-000000000004"
|
||||
name: "lotgd/tests/none/child2"
|
||||
title: "Child 2"
|
||||
scene_connections:
|
||||
-
|
||||
outgoingScene: 1
|
||||
incomingScene: 2
|
||||
outgoingScene: "30000000-0000-0000-0000-000000000001"
|
||||
incomingScene: "30000000-0000-0000-0000-000000000002"
|
||||
directionality: 0
|
||||
-
|
||||
outgoingScene: 1
|
||||
incomingScene: 3
|
||||
outgoingScene: "30000000-0000-0000-0000-000000000001"
|
||||
incomingScene: "30000000-0000-0000-0000-000000000003"
|
||||
directionality: 0
|
||||
-
|
||||
outgoingScene: 1
|
||||
incomingScene: 4
|
||||
outgoingScene: "30000000-0000-0000-0000-000000000001"
|
||||
incomingScene: "30000000-0000-0000-0000-000000000004"
|
||||
directionality: 0
|
||||
-
|
||||
outgoingScene: 4
|
||||
incomingScene: 5
|
||||
outgoingScene: "30000000-0000-0000-0000-000000000004"
|
||||
incomingScene: "30000000-0000-0000-0000-000000000005"
|
||||
outgoingConnectionGroupName: "lotgd/tests/none/child1"
|
||||
directionality: 0
|
||||
-
|
||||
outgoingScene: 4
|
||||
incomingScene: 6
|
||||
outgoingScene: "30000000-0000-0000-0000-000000000004"
|
||||
incomingScene: "30000000-0000-0000-0000-000000000006"
|
||||
outgoingConnectionGroupName: "lotgd/tests/none/child2"
|
||||
directionality: 0
|
||||
-
|
||||
outgoingScene: 5
|
||||
incomingScene: 6
|
||||
outgoingScene: "30000000-0000-0000-0000-000000000005"
|
||||
incomingScene: "30000000-0000-0000-0000-000000000006"
|
||||
directionality: 1
|
||||
|
||||
|
||||
@@ -1,19 +1,19 @@
|
||||
characters:
|
||||
-
|
||||
id: 1
|
||||
id: "10000000-0000-0000-0000-000000000001"
|
||||
name: "Testcharacter 1"
|
||||
displayName: "Testcharacter 1"
|
||||
-
|
||||
id: 2
|
||||
id: "10000000-0000-0000-0000-000000000002"
|
||||
name: "Testcharacter 2"
|
||||
displayName: "Testcharacter 2"
|
||||
-
|
||||
id: 3
|
||||
id: "10000000-0000-0000-0000-000000000003"
|
||||
name: "Testcharacter 1"
|
||||
displayName: "Deleted Testcharacter"
|
||||
deletedAt: "2011-11-11 11:11:11"
|
||||
-
|
||||
id: 4
|
||||
id: "10000000-0000-0000-0000-000000000004"
|
||||
name: "Testcharacter 3"
|
||||
displayName: "Testcharacter 3"
|
||||
message_threads:
|
||||
@@ -23,7 +23,7 @@ message_threads:
|
||||
messages:
|
||||
-
|
||||
id: 1
|
||||
author_id: 1
|
||||
author_id: "10000000-0000-0000-0000-000000000001"
|
||||
thread_id: 1
|
||||
message: "Hi!"
|
||||
createdAt: "2000-01-01 00:00:01"
|
||||
@@ -31,7 +31,7 @@ messages:
|
||||
message_threads_x_characters:
|
||||
-
|
||||
messagethread_id: 1
|
||||
character_id: 1
|
||||
character_id: "10000000-0000-0000-0000-000000000001"
|
||||
-
|
||||
messagethread_id: 1
|
||||
character_id: 2
|
||||
character_id: "10000000-0000-0000-0000-000000000002"
|
||||
@@ -1,18 +1,18 @@
|
||||
characters:
|
||||
-
|
||||
id: 1
|
||||
id: "10000000-0000-0000-0000-000000000001"
|
||||
name: "Testcharacter 1"
|
||||
displayName: "Testcharacter 1"
|
||||
health: 0
|
||||
maxhealth: 100
|
||||
-
|
||||
id: 2
|
||||
id: "10000000-0000-0000-0000-000000000002"
|
||||
name: "Testcharacter 2"
|
||||
displayName: "Testcharacter 2"
|
||||
health: 90
|
||||
maxhealth: 90
|
||||
-
|
||||
id: 3
|
||||
id: "10000000-0000-0000-0000-000000000003"
|
||||
name: "Testcharacter 1"
|
||||
displayName: "Deleted Testcharacter"
|
||||
health: 200
|
||||
@@ -20,22 +20,22 @@ characters:
|
||||
deletedAt: "2011-11-11 11:11:11"
|
||||
motd:
|
||||
-
|
||||
id: 1
|
||||
author_id: 1
|
||||
id: "20000000-0000-0000-0000-000000000001"
|
||||
author_id: "10000000-0000-0000-0000-000000000001"
|
||||
title: "This is the title"
|
||||
body: "This is the body of the message"
|
||||
creationTime: "2016-05-03 14:19:12"
|
||||
systemMessage: false
|
||||
-
|
||||
id: 2
|
||||
author_id: 1
|
||||
id: "20000000-0000-0000-0000-000000000002"
|
||||
author_id: "10000000-0000-0000-0000-000000000001"
|
||||
title: "This is a system message"
|
||||
body: "This is the body of the system message"
|
||||
creationTime: "2016-05-04 14:19:12"
|
||||
systemMessage: true
|
||||
-
|
||||
id: 3
|
||||
author_id: 3
|
||||
id: "20000000-0000-0000-0000-000000000003"
|
||||
author_id: "10000000-0000-0000-0000-000000000003"
|
||||
title: "This is an old message."
|
||||
body: "This is an old message."
|
||||
creationTime: "2002-12-09 15:13:59"
|
||||
|
||||
+15
-15
@@ -1,53 +1,53 @@
|
||||
scenes:
|
||||
-
|
||||
id: 1
|
||||
id: "30000000-0000-0000-0000-000000000001"
|
||||
title: "The Village"
|
||||
description: "This is the village."
|
||||
template: "lotgd/tests/village"
|
||||
-
|
||||
id: 2
|
||||
id: "30000000-0000-0000-0000-000000000002"
|
||||
title: "The Forest"
|
||||
description: "This is a very dangerous and dark forest"
|
||||
template: "lotgd/tests/forest"
|
||||
-
|
||||
id: 3
|
||||
id: "30000000-0000-0000-0000-000000000003"
|
||||
title: "The Weaponry"
|
||||
description: "This is the place where you can buy awesome weapons"
|
||||
template: "lotgd/tests/weaponry"
|
||||
-
|
||||
id: 4
|
||||
id: "30000000-0000-0000-0000-000000000004"
|
||||
title: "Another Village"
|
||||
description: "This is another village"
|
||||
template: "lotgd/tests/village"
|
||||
-
|
||||
id: 5
|
||||
id: "30000000-0000-0000-0000-000000000005"
|
||||
title: "Orphan"
|
||||
description: "This is an orphan scene"
|
||||
template: "lotgd/tests/orphan"
|
||||
scene_connection_groups:
|
||||
-
|
||||
scene: 1
|
||||
scene: "30000000-0000-0000-0000-000000000001"
|
||||
name: "lotgd/tests/village/outside"
|
||||
title: "Outside"
|
||||
-
|
||||
scene: 1
|
||||
scene: "30000000-0000-0000-0000-000000000001"
|
||||
name: "lotgd/tests/village/market"
|
||||
title: "Market"
|
||||
-
|
||||
scene: 1
|
||||
scene: "30000000-0000-0000-0000-000000000001"
|
||||
name: "lotgd/tests/village/empty"
|
||||
title: "Empty"
|
||||
-
|
||||
scene: 2
|
||||
scene: "30000000-0000-0000-0000-000000000002"
|
||||
name: "lotgd/tests/forest/category"
|
||||
title: "Empty"
|
||||
scene_connections:
|
||||
-
|
||||
outgoingScene: 1
|
||||
incomingScene: 2
|
||||
outgoingScene: "30000000-0000-0000-0000-000000000001"
|
||||
incomingScene: "30000000-0000-0000-0000-000000000002"
|
||||
-
|
||||
outgoingScene: 1
|
||||
incomingScene: 3
|
||||
outgoingScene: "30000000-0000-0000-0000-000000000001"
|
||||
incomingScene: "30000000-0000-0000-0000-000000000003"
|
||||
-
|
||||
outgoingScene: 1
|
||||
incomingScene: 4
|
||||
outgoingScene: "30000000-0000-0000-0000-000000000001"
|
||||
incomingScene: "30000000-0000-0000-0000-000000000004"
|
||||
@@ -1,15 +1,15 @@
|
||||
characters:
|
||||
-
|
||||
id: 1
|
||||
id: "10000000-0000-0000-0000-000000000001"
|
||||
name: "Char without a Scene"
|
||||
displayName: "A"
|
||||
-
|
||||
id: 2
|
||||
id: "10000000-0000-0000-0000-000000000002"
|
||||
name: "Char with a Scene"
|
||||
displayName: "B"
|
||||
viewpoints:
|
||||
-
|
||||
owner_id: 2
|
||||
owner_id: "10000000-0000-0000-0000-000000000002"
|
||||
title: "The Village"
|
||||
description: "This is the village."
|
||||
template: "lotgd/tests/village"
|
||||
@@ -18,24 +18,24 @@ viewpoints:
|
||||
actionGroups: "a:0:{}"
|
||||
scenes:
|
||||
-
|
||||
id: 1
|
||||
id: "30000000-0000-0000-0000-000000000001"
|
||||
title: "The Village"
|
||||
description: "This is the village."
|
||||
template: "lotgd/tests/village"
|
||||
-
|
||||
id: 2
|
||||
id: "30000000-0000-0000-0000-000000000002"
|
||||
title: "The Forest"
|
||||
description: "This is a very dangerous and dark forest"
|
||||
template: "lotgd/tests/forest"
|
||||
-
|
||||
id: 3
|
||||
id: "30000000-0000-0000-0000-000000000003"
|
||||
title: "The Weaponry"
|
||||
description: "This is the place where you can buy awesome weapons"
|
||||
template: "lotgd/tests/weaponry"
|
||||
scene_connections:
|
||||
-
|
||||
outgoingScene: 1
|
||||
incomingScene: 2
|
||||
outgoingScene: "30000000-0000-0000-0000-000000000001"
|
||||
incomingScene: "30000000-0000-0000-0000-000000000002"
|
||||
-
|
||||
outgoingScene: 1
|
||||
incomingScene: 3
|
||||
outgoingScene: "30000000-0000-0000-0000-000000000001"
|
||||
incomingScene: "30000000-0000-0000-0000-000000000003"
|
||||
Reference in New Issue
Block a user