Automatic changes from 'php cs fixer'

This commit is contained in:
Basilius Sauter
2019-06-25 20:42:44 +02:00
parent 8612a53538
commit e74dcbdfde
134 changed files with 896 additions and 1068 deletions
-1
View File
@@ -77,7 +77,6 @@ return PhpCsFixer\Config::create()
'no_spaces_after_function_name' => true,
'no_spaces_around_offset' => true,
'no_spaces_inside_parenthesis' => true,
'no_superfluous_phpdoc_tags' => ['allow_mixed' => true],
'no_trailing_comma_in_list_call' => true,
'no_trailing_comma_in_singleline_array' => true,
'no_trailing_whitespace' => true,
+6 -7
View File
@@ -22,7 +22,7 @@ class Action
*/
public function __construct(string $destinationSceneId, ?string $title = null, array $parameters = [])
{
$this->id = bin2hex(random_bytes(8));
$this->id = \bin2hex(\random_bytes(8));
$this->destinationSceneId = $destinationSceneId;
$this->title = $title;
$this->parameters = $parameters;
@@ -49,7 +49,7 @@ class Action
}
/**
* @return null|string
* @return string|null
*/
public function getTitle(): ?string
{
@@ -58,15 +58,15 @@ class Action
/**
* @param string $title
* @return null|string
* @return string|null
*/
public function setTitle(?string $title)
public function setTitle(?string $title): ?string
{
$this->title = $title;
}
/**
* Returns all parameters for this action
* Returns all parameters for this action.
* @return array
*/
public function getParameters(): array
@@ -75,9 +75,8 @@ class Action
}
/**
* Sets all parameters for this action
* Sets all parameters for this action.
* @param array $parameters
* @return void
*/
public function setParameters(array $parameters): void
{
+2 -2
View File
@@ -1,5 +1,5 @@
<?php
declare (strict_types=1);
declare(strict_types=1);
namespace LotGD\Core;
@@ -36,7 +36,7 @@ class ActionGroup implements \Countable
*/
public function count(): int
{
return count($this->actions);
return \count($this->actions);
}
/**
+1 -1
View File
@@ -19,7 +19,7 @@ abstract class Attachment
*/
public function __construct(string $type)
{
$this->id = bin2hex(random_bytes(8));
$this->id = \bin2hex(\random_bytes(8));
$this->type = $type;
}
+41 -45
View File
@@ -3,21 +3,17 @@ declare(strict_types=1);
namespace LotGD\Core;
use Doctrine\Common\Collections\{
ArrayCollection,
Collection
};
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use LotGD\Core\{
DiceBag,
Exceptions\ArgumentException,
Exceptions\BattleIsOverException,
Exceptions\BattleNotOverException,
Models\FighterInterface
};
use LotGD\Core\Models\{
Buff, BattleEvents\BuffMessageEvent, BattleEvents\CriticalHitEvent, BattleEvents\DamageEvent, BattleEvents\DeathEvent, Scene
};
use LotGD\Core\Exceptions\ArgumentException;
use LotGD\Core\Exceptions\BattleIsOverException;
use LotGD\Core\Exceptions\BattleNotOverException;
use LotGD\Core\Models\BattleEvents\CriticalHitEvent;
use LotGD\Core\Models\BattleEvents\DamageEvent;
use LotGD\Core\Models\BattleEvents\DeathEvent;
use LotGD\Core\Models\Buff;
use LotGD\Core\Models\FighterInterface;
/**
* Class for managing and running battles between 2 participants.
@@ -42,7 +38,7 @@ class Battle
protected $round = 0;
/**
* Battle Configuration
* Battle Configuration.
* @var array
*/
protected $configuration = [
@@ -71,7 +67,7 @@ class Battle
*/
public function serialize(): string
{
return serialize([
return \serialize([
"monster" => $this->monster,
"result" => $this->result,
"round" => $this->round,
@@ -88,9 +84,9 @@ class Battle
public static function unserialize(Game $game, FighterInterface $player, string $serialized): self
{
$battle = new self($game, $player, null);
$unserialized = unserialize($serialized);
$unserialized = \unserialize($serialized);
$battle->monster = $unserialized["monster"];
$battle->monster = $unserialized["monster"];
$battle->result = $unserialized["result"];
$battle->round = $unserialized["round"];
$battle->configuration = $unserialized["configuration"];
@@ -99,7 +95,7 @@ class Battle
}
/**
* Returns a list of all battle events
* Returns a list of all battle events.
* @return Collection
*/
public function getEvents(): Collection
@@ -108,7 +104,7 @@ class Battle
}
/**
* Disables ripostes
* Disables ripostes.
*/
public function disableRiposte()
{
@@ -116,7 +112,7 @@ class Battle
}
/**
* Enables ripostes
* Enables ripostes.
*/
public function enableRiposte()
{
@@ -124,7 +120,7 @@ class Battle
}
/**
* Returns true if ripostes are enabled
* Returns true if ripostes are enabled.
* @return bool
*/
public function isRiposteEnabled(): bool
@@ -133,7 +129,7 @@ class Battle
}
/**
* Enables level adjustement
* Enables level adjustement.
*/
public function enableLevelAdjustement()
{
@@ -141,7 +137,7 @@ class Battle
}
/**
* Disables level adjustement
* Disables level adjustement.
*/
public function disableLevelAdjustement()
{
@@ -149,7 +145,7 @@ class Battle
}
/**
* Returns true if level adjustements are enabled
* Returns true if level adjustements are enabled.
* @return bool
*/
public function isLevelAdjustementEnabled(): bool
@@ -158,7 +154,7 @@ class Battle
}
/**
* Returns true if critical hit events are enabled
* Returns true if critical hit events are enabled.
* @return bool
*/
public function isCriticalHitEnabled(): bool
@@ -167,7 +163,7 @@ class Battle
}
/**
* Disable critical hits
* Disable critical hits.
*/
public function disableCriticalHit()
{
@@ -175,7 +171,7 @@ class Battle
}
/**
* enables critical hits
* enables critical hits.
*/
public function enableCriticalHit()
{
@@ -192,7 +188,7 @@ class Battle
}
/**
* Returns the player instance
* Returns the player instance.
* @return FighterInterface
*/
public function getPlayer(): FighterInterface
@@ -201,7 +197,7 @@ class Battle
}
/**
* Returns the montser instance
* Returns the montser instance.
* @return FighterInterface
*/
public function getMonster(): FighterInterface
@@ -210,9 +206,9 @@ class Battle
}
/**
* Returns the winner of this fight
* @return FighterInterface
* Returns the winner of this fight.
* @throws BattleNotOverException if battle is not over.
* @return FighterInterface
*/
public function getWinner(): FighterInterface
{
@@ -224,9 +220,9 @@ class Battle
}
/**
* Returns the loser of this fight
* @return FighterInterface
* Returns the loser of this fight.
* @throws BattleNotOverException if battle is not over.
* @return FighterInterface
*/
public function getLoser(): FighterInterface
{
@@ -242,9 +238,9 @@ class Battle
* of actual rounds fought.
* @param int $n
* @param int $firstDamageRound Which damage rounds are calculated. Cannot be 0.
* @return int Number of fights fought.
* @throws ArgumentException if firstDamageRound is 0.
* @throws BattleIsOverException
* @return int Number of fights fought.
*/
public function fightNRounds(int $n = 1, int $firstDamageRound = self::DAMAGEROUND_BOTH): int
{
@@ -265,11 +261,11 @@ class Battle
}
}
return $count+1;
return $count + 1;
}
/**
* Fights exactly 1 round
* Fights exactly 1 round.
* @param int $firstDamageRound
*/
protected function fightOneRound(int $firstDamageRound)
@@ -285,7 +281,7 @@ class Battle
$offenseTurnEvents = $firstDamageRound & self::DAMAGEROUND_PLAYER ? $this->turn($this->player, $this->monster) : new ArrayCollection();
$defenseTurnEvents = $firstDamageRound & self::DAMAGEROUND_MONSTER ? $this->turn($this->monster, $this->player) : new ArrayCollection();
$events = new ArrayCollection(array_merge($offenseTurnEvents->toArray(), $defenseTurnEvents->toArray()));
$events = new ArrayCollection(\array_merge($offenseTurnEvents->toArray(), $defenseTurnEvents->toArray()));
$eventsToAdd = new ArrayCollection();
foreach ($events as $event) {
@@ -315,7 +311,7 @@ class Battle
$monsterBuffExpiringEvents = $this->monster->getBuffs()->expireOneRound();
$this->events = new ArrayCollection(
array_merge(
\array_merge(
$this->events->toArray(),
$playerBuffStartEvents->toArray(),
$monsterBuffStartEvents->toArray(),
@@ -385,8 +381,8 @@ class Battle
}
// Conversion from float to int, since the random number generator takes int values.
$attackersAttack = (int) round($attackersAttack, 0);
$defendersDefense = (int) round($defendersDefense, 0);
$attackersAttack = (int)\round($attackersAttack, 0);
$defendersDefense = (int)\round($defendersDefense, 0);
// Lets roll the
$attackersAtkRoll = $this->game->getDiceBag()->pseudoBell(0, $attackersAttack);
@@ -414,10 +410,10 @@ class Battle
$damage = 0;
} elseif ($attackerIsInvulnurable) {
// Attaker is invulnurable, damage is always > 0 (there is no riposte)
$damage = abs($damage);
$damage = \abs($damage);
} elseif ($defenderIsInvulnurable) {
// Defender is invulnurable, damage is always < 0 (defender always ripostes)
$damage = - abs($damage);
$damage = -\abs($damage);
}
if ($damage < 0) {
@@ -439,7 +435,7 @@ class Battle
}
// Round the damage value and convert to int.
$damage = (int)round($damage, 0);
$damage = (int)\round($damage, 0);
// Add the damage event
$events->add(new DamageEvent($attacker, $defender, $damage));
@@ -455,7 +451,7 @@ class Battle
$defendersDamageDependentBuffEvents = $defendersBuffs->processDamageDependentBuffs(Buff::ACTIVATE_DEFENSE, -$damage, $this->game, $defender, $attacker);
return new ArrayCollection(
array_merge(
\array_merge(
$attackersBuffStartEvents->toArray(),
$attackersDirectBuffEvents->toArray(),
$defendersBuffStartEvents->toArray(),
+28 -34
View File
@@ -4,29 +4,21 @@ declare(strict_types=1);
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\DBAL\Types\Type;
use Doctrine\ORM\EntityManager;
use Doctrine\ORM\EntityManagerInterface;
use Doctrine\ORM\Events as DoctrineEvents;
use Doctrine\ORM\ {
EntityManager,
EntityManagerInterface,
Mapping\AnsiQuoteStrategy,
Tools\Setup,
Tools\SchemaTool
};
use Monolog\ {
Logger,
Handler\RotatingFileHandler
};
use Doctrine\ORM\Tools\SchemaTool;
use Doctrine\ORM\Tools\Setup;
use LotGD\Core\Doctrine\EntityPostLoadEventListener;
use LotGD\Core\Exceptions\InvalidConfigurationException;
use Monolog\Handler\RotatingFileHandler;
use Monolog\Logger;
use Psr\Log\LoggerInterface;
use Symfony\Component\Console\Application;
use LotGD\Core\{
ComposerManager, BootstrapInterface, Doctrine\EntityPostLoadEventListener, Exceptions\InvalidConfigurationException
};
/**
* The entry point for constructing a properly configured LotGD Game object.
*/
@@ -34,7 +26,7 @@ class Bootstrap
{
private $logger;
private $game;
/** @var LibraryConfigurationManager */
/** @var LibraryConfigurationManager */
private $libraryConfigurationManager;
private $annotationDirectories = [];
@@ -46,12 +38,12 @@ class Bootstrap
public static function createGame(string $cwd = null): Game
{
$game = new self();
$cwd = $cwd ?? getcwd();
$cwd = $cwd ?? \getcwd();
return $game->getGame($cwd);
}
/**
* Starts the game kernel with the most important classes and returns the object
* Starts the game kernel with the most important classes and returns the object.
* @param string $cwd
* @return Game
*/
@@ -65,7 +57,7 @@ class Bootstrap
$composer = $this->createComposerManager($cwd);
$this->libraryConfigurationManager = $this->createLibraryConfigurationManager($composer, $cwd);
list($dsn, $user, $password) = $config->getDatabaseConnectionDetails($cwd);
[$dsn, $user, $password] = $config->getDatabaseConnectionDetails($cwd);
$pdo = $this->connectToDatabase($dsn, $user, $password);
$entityManager = $this->createEntityManager($pdo, $config);
@@ -74,7 +66,8 @@ class Bootstrap
->withLogger($this->logger)
->withEntityManager($entityManager)
->withCwd($cwd)
->create();
->create()
;
// Add Event listener to entity manager
$dem = $entityManager->getEventManager();
@@ -87,7 +80,7 @@ class Bootstrap
}
/**
* Creates a library configuration manager
* Creates a library configuration manager.
* @param ComposerManager $composerManager
* @param string $cwd
* @return LibraryConfigurationManager
@@ -100,7 +93,7 @@ class Bootstrap
}
/**
* Connects to a database using pdo
* Connects to a database using pdo.
* @param string $dsn
* @param string $user
* @param string $password
@@ -112,7 +105,7 @@ class Bootstrap
}
/**
* Creates and returns an instance of ComposerManager
* Creates and returns an instance of ComposerManager.
* @param string $cwd
* @return ComposerManager
*/
@@ -125,16 +118,16 @@ class Bootstrap
/**
* Returns a configuration object reading from the file located at the path stored in $cwd/config/lotgd.yml.
* @param string $cwd
* @return Configuration
* @throws InvalidConfigurationException
* @return Configuration
*/
protected function createConfiguration(string $cwd): Configuration
{
if (empty($configFilePath)) {
$configFilePath = implode(DIRECTORY_SEPARATOR, [$cwd, "config", "lotgd.yml"]);
$configFilePath = \implode(\DIRECTORY_SEPARATOR, [$cwd, "config", "lotgd.yml"]);
}
if ($configFilePath === false || strlen($configFilePath) == 0 || is_file($configFilePath) === false) {
if ($configFilePath === false || \strlen($configFilePath) == 0 || \is_file($configFilePath) === false) {
throw new InvalidConfigurationException("Invalid or missing configuration file: {$configFilePath}.");
}
@@ -143,7 +136,7 @@ class Bootstrap
}
/**
* Returns a logger instance
* Returns a logger instance.
* @param Configuration $config
* @param string $name
* @return LoggerInterface
@@ -152,13 +145,13 @@ class Bootstrap
{
$logger = new Logger($name);
// Add lotgd as the prefix for the log filenames.
$logger->pushHandler(new RotatingFileHandler($config->getLogPath() . DIRECTORY_SEPARATOR . $name, 14));
$logger->pushHandler(new RotatingFileHandler($config->getLogPath() . \DIRECTORY_SEPARATOR . $name, 14));
return $logger;
}
/**
* Creates the EntityManager using the pdo connection given in it's argument
* Creates the EntityManager using the pdo connection given in it's argument.
* @param \PDO $pdo
* @param Configuration
* @return EntityManagerInterface
@@ -178,7 +171,8 @@ class Bootstrap
// Register uuid type
try {
Type::addType('uuid', 'Ramsey\Uuid\Doctrine\UuidType');
} catch (DBALException $e) {}
} catch (DBALException $e) {
}
// Create Schema and update database if needed
if ($config->getDatabaseAutoSchemaUpdate()) {
@@ -197,12 +191,12 @@ class Bootstrap
protected function generateAnnotationDirectories(): array
{
// Read db annotations from our own model files.
$directories = [__DIR__ . DIRECTORY_SEPARATOR . 'Models'];
$directories = [__DIR__ . \DIRECTORY_SEPARATOR . 'Models'];
// Get additional annotation directories from library configs.
$libraryDirectories = $this->libraryConfigurationManager->getEntityDirectories();
return array_merge($directories, $libraryDirectories);
return \array_merge($directories, $libraryDirectories);
}
/**
+45 -55
View File
@@ -3,29 +3,21 @@ declare(strict_types=1);
namespace LotGD\Core;
use Doctrine\Common\Collections\{
ArrayCollection,
Collection
};
use LotGD\Core\Exceptions\{
ArgumentException,
BuffListAlreadyActivatedException
};
use LotGD\Core\Models\{
Buff,
Character,
FighterInterface,
BattleEvents\BuffMessageEvent,
BattleEvents\DamageLifetapEvent,
BattleEvents\DamageReflectionEvent,
BattleEvents\RegenerationBuffEvent,
BattleEvents\MinionDamageEvent
};
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use LotGD\Core\Exceptions\ArgumentException;
use LotGD\Core\Exceptions\BuffListAlreadyActivatedException;
use LotGD\Core\Models\BattleEvents\BuffMessageEvent;
use LotGD\Core\Models\BattleEvents\DamageLifetapEvent;
use LotGD\Core\Models\BattleEvents\DamageReflectionEvent;
use LotGD\Core\Models\BattleEvents\MinionDamageEvent;
use LotGD\Core\Models\BattleEvents\RegenerationBuffEvent;
use LotGD\Core\Models\Buff;
use LotGD\Core\Models\FighterInterface;
/**
* Description of BuffList
* Description of BuffList.
*/
class BuffList
{
@@ -35,9 +27,9 @@ class BuffList
/** @var ArrayCollection */
protected $usedBuffs;
/** @var boolean True of the modifiers have already been calculated */
/** @var bool True of the modifiers have already been calculated */
protected $modifiersCalculated = false;
/** @var boolean True if the badguy is invulnurable */
/** @var bool True if the badguy is invulnurable */
protected $badguyInvulnurable = false;
/** @var float */
protected $badguyDamageModifier = 1.;
@@ -45,7 +37,7 @@ class BuffList
protected $badguyAttackModifier = 1.;
/** @var float */
protected $badguyDefenseModifier = 1.;
/** @var boolean True if the goodguy is invulnurable */
/** @var bool True if the goodguy is invulnurable */
protected $goodguyInvulnurable = false;
/** @var float */
protected $goodguyDamageModifier = 1.;
@@ -58,7 +50,7 @@ class BuffList
protected $loaded = false;
/**
* Initiates some variables
* Initiates some variables.
* @param Collection $buffs
*/
public function __construct(Collection $buffs)
@@ -69,7 +61,7 @@ class BuffList
}
/**
* Loads all buffs (since it's a lazy correlation)
* Loads all buffs (since it's a lazy correlation).
*/
public function loadBuffs()
{
@@ -97,7 +89,7 @@ class BuffList
}
/**
* Marks the given buff as used
* Marks the given buff as used.
* @param Buff $buff
*/
protected function useBuff(Buff $buff)
@@ -106,7 +98,7 @@ class BuffList
}
/**
* Returns the buff's start or round message
* Returns the buff's start or round message.
* @param Buff $buff
* @return string
*/
@@ -125,7 +117,7 @@ class BuffList
}
/**
* Resets the buff usage for a new round
* Resets the buff usage for a new round.
*/
public function resetBuffUsage()
{
@@ -140,19 +132,19 @@ class BuffList
*/
public function hasBuffsInUse(): bool
{
return count($this->usedBuffs) > 0 ? true : false;
return \count($this->usedBuffs) > 0 ? true : false;
}
/**
* Activates all buffs that activate upon the given activation parameter.
* @param int $activation
* @return Collection
* @throws ArgumentException
* @throws BuffListAlreadyActivatedException
* @return Collection
*/
public function activate(int $activation): Collection
{
if ($activation%2 !== 0 && $activation !== 1) {
if ($activation % 2 !== 0 && $activation !== 1) {
throw new ArgumentException("You can only activate one activation type at a time.");
}
@@ -187,7 +179,7 @@ class BuffList
}
/**
* Decreases the rounds left on all used buffs
* Decreases the rounds left on all used buffs.
* @return Collection A Collection containing expire messages (if there are any)
*/
public function expireOneRound(): Collection
@@ -262,10 +254,9 @@ class BuffList
}
/**
* Calculates all total modifiers
* @return type
* Calculates all total modifiers.
*/
protected function calculateModifiers()
protected function calculateModifiers(): void
{
if ($this->modifiersCalculated === true) {
return;
@@ -303,14 +294,13 @@ class BuffList
// Only look at buffs that are activated in battle.
if ($buff->getsActivatedAt(Buff::ACTIVATE_NONE)) {
continue;
} else {
yield $buff;
}
yield $buff;
}
}
/**
* Returns the badguy attack modifier calculated over the whole bufflist
* Returns the badguy attack modifier calculated over the whole bufflist.
* @return float
*/
public function getBadguyAttackModifier(): float
@@ -319,8 +309,8 @@ class BuffList
return $this->badguyAttackModifier;
}
/**
* Returns the badguy defense modifier calculated over the whole bufflist
/**
* Returns the badguy defense modifier calculated over the whole bufflist.
* @return float
*/
public function getBadguyDefenseModifier(): float
@@ -330,7 +320,7 @@ class BuffList
}
/**
* Returns the badguy damage modifier calculated over the whole bufflist
* Returns the badguy damage modifier calculated over the whole bufflist.
* @return float
*/
public function getBadguyDamageModifier(): float
@@ -340,7 +330,7 @@ class BuffList
}
/**
* Returns true if the badguy is invulnurable
* Returns true if the badguy is invulnurable.
* @return bool
*/
public function badguyIsInvulnurable(): bool
@@ -350,7 +340,7 @@ class BuffList
}
/**
* Returns the badguy attack modifier calculated over the whole bufflist
* Returns the badguy attack modifier calculated over the whole bufflist.
* @return float
*/
public function getGoodguyAttackModifier(): float
@@ -359,8 +349,8 @@ class BuffList
return $this->goodguyAttackModifier;
}
/**
* Returns the badguy defense modifier calculated over the whole bufflist
/**
* Returns the badguy defense modifier calculated over the whole bufflist.
* @return float
*/
public function getGoodguyDefenseModifier(): float
@@ -369,8 +359,8 @@ class BuffList
return $this->goodguyDefenseModifier;
}
/**
* Returns the badguy damage modifier calculated over the whole bufflist
/**
* Returns the badguy damage modifier calculated over the whole bufflist.
* @return float
*/
public function getGoodguyDamageModifier(): float
@@ -380,7 +370,7 @@ class BuffList
}
/**
* Returns true if the goodguy is invulnurable
* Returns true if the goodguy is invulnurable.
* @return bool
*/
public function goodguyIsInvulnurable(): bool
@@ -390,7 +380,7 @@ class BuffList
}
/**
* Processes buffs that do direct damage or regeneration
* Processes buffs that do direct damage or regeneration.
* @param int $activation
* @param Game $game
* @param FighterInterface $goodguy
@@ -478,7 +468,7 @@ class BuffList
$events[] = new MinionDamageEvent(
$target,
(int)round($damage, 0),
(int)\round($damage, 0),
$message
);
}
@@ -491,7 +481,7 @@ class BuffList
}
/**
* Processes buffs that are dependant on the damage done in one round
* Processes buffs that are dependant on the damage done in one round.
* @param int $activation
* @param int $damage Positive damage is applied to the badguy, negative damage is applied to the goodguy
* @param Game $game
@@ -519,7 +509,7 @@ class BuffList
$reflectedDamage = 0;
$message = $buff->getNoEffectMessage();
} else {
$reflectedDamage = (int)round($buff->getGoodguyDamageReflection() * $damage * -1, 0);
$reflectedDamage = (int)\round($buff->getGoodguyDamageReflection() * $damage * -1, 0);
if ($reflectedDamage === 0) {
$message = $buff->getNoEffectMessage();
} else {
@@ -537,7 +527,7 @@ class BuffList
if ($buff->getBadguyDamageReflection() !== 0.) {
if ($damage > 0) {
// Damage is > 0, so badguy takes damage, we can normally reflect
$reflectedDamage = (int)round($buff->getBadguyDamageReflection() * $damage, 0);
$reflectedDamage = (int)\round($buff->getBadguyDamageReflection() * $damage, 0);
if ($reflectedDamage === 0) {
$message = $buff->getNoEffectMessage();
} else {
@@ -566,7 +556,7 @@ class BuffList
$message = $buff->getEffectFailsMessage();
} elseif ($damage < 0) {
// Damage is < 0, goodguy takes damage. We act upon this.
$healAmount = (int)round($damage * -$buff->getBadguyLifetap(), 0);
$healAmount = (int)\round($damage * -$buff->getBadguyLifetap(), 0);
if ($healAmount === 0) {
$message = $buff->getNoEffectMessage();
} else {
@@ -587,7 +577,7 @@ class BuffList
if ($buff->getBadguyLifetap() !== 0.) {
if ($damage > 0) {
// Damage is > 0, badguy takes damage. We act upon this to heal goodguy.
$healAmount = (int)round($damage * $buff->getBadguyLifetap(), 0);
$healAmount = (int)\round($damage * $buff->getBadguyLifetap(), 0);
if ($healAmount === 0) {
$message = $buff->getNoEffectMessage();
} else {
+28 -28
View File
@@ -3,15 +3,15 @@ declare(strict_types=1);
namespace LotGD\Core;
use Composer\Composer;
use Composer\Factory;
use Composer\IO\NullIO;
use Composer\Package\CompletePackageInterface;
use Composer\Package\PackageInterface;
use Exception;
use Composer\{
Composer, Factory, IO\NullIO, Package\CompletePackageInterface, Package\PackageInterface
};
use LotGD\Core\{
Exceptions\InvalidConfigurationException,
Exceptions\LibraryDoesNotExistException
};
use LotGD\Core\Exceptions\InvalidConfigurationException;
use LotGD\Core\Exceptions\LibraryDoesNotExistException;
/**
* Helps perform tasks with the composer configuration.
@@ -39,8 +39,8 @@ class ComposerManager
{
if ($this->composer === null) {
// Verify location of composer.json.
$composerConfigPath = $this->cwd . DIRECTORY_SEPARATOR . "composer.json";
if (!file_exists($composerConfigPath)) {
$composerConfigPath = $this->cwd . \DIRECTORY_SEPARATOR . "composer.json";
if (!\file_exists($composerConfigPath)) {
throw new InvalidConfigurationException("composer.json cannot be found at {$composerConfigPath}.");
}
@@ -54,8 +54,8 @@ class ComposerManager
/**
* Return the Composer package for the corresponding library, in vendor/module format.
* @param string $library
* @return CompletePackageInterface Package corresponding to this library.
* @throws LibraryDoesNotExistException
* @return CompletePackageInterface Package corresponding to this library.
*/
public function getPackageForLibrary(string $library): CompletePackageInterface
{
@@ -75,7 +75,7 @@ class ComposerManager
*/
public function getPackages(): array
{
return array_merge(
return \array_merge(
[$this->getComposer()->getPackage()],
$this->getComposer()->getRepositoryManager()->getLocalRepository()->getPackages()
);
@@ -87,11 +87,11 @@ class ComposerManager
*/
public function getModulePackages(): array
{
$result = array();
$result = [];
$packages = $this->getComposer()->getRepositoryManager()->getLocalRepository()->getPackages();
foreach ($packages as $p) {
if ($p->getType() === 'lotgd-module') {
array_push($result, $p);
\array_push($result, $p);
}
}
@@ -104,7 +104,7 @@ class ComposerManager
* @return string|null Path representing $namespace or null if $namespace
* cannot be found or if the path does not exist.
*/
public function translateNamespaceToPath(string $namespace)
public function translateNamespaceToPath(string $namespace): ?string
{
// Find the directory for this namespace by using the autoloader's
// classmap.
@@ -114,32 +114,32 @@ class ComposerManager
// Standardize the namespace to remove any leading \ and add a trailing \
$n = $namespace;
if ('\\' == $n[0]) {
$n = substr($n, 1);
$n = \substr($n, 1);
}
if (strlen($n) > 0 && '\\' != $n[strlen($n) - 1]) {
if (\strlen($n) > 0 && '\\' != $n[\strlen($n) - 1]) {
$n .= '\\';
}
$split = explode('\\', $n);
$suffix = array_splice($split, -1, 1); // starts with ['']
$split = \explode('\\', $n);
$suffix = \array_splice($split, -1, 1); // starts with ['']
$path = null;
while (!empty($split)) {
$key = implode('\\', $split) . '\\';
$dir = implode(DIRECTORY_SEPARATOR, $suffix);
$key = \implode('\\', $split) . '\\';
$dir = \implode(\DIRECTORY_SEPARATOR, $suffix);
// Prefix to directory mappings are arrays in Composer's
// ClassLoader object. Not sure why. This might break in
// some unforseen case.
if (isset($prefixes[$key]) && is_dir($prefixes[$key][0] . DIRECTORY_SEPARATOR . $dir)) {
$path = $prefixes[$key][0] . DIRECTORY_SEPARATOR . $dir;
if (isset($prefixes[$key]) && \is_dir($prefixes[$key][0] . \DIRECTORY_SEPARATOR . $dir)) {
$path = $prefixes[$key][0] . \DIRECTORY_SEPARATOR . $dir;
break;
}
$suffix = array_merge($suffix, array_splice($split, -1, 1));
$suffix = \array_merge($suffix, \array_splice($split, -1, 1));
}
if ($path == null) {
return null;
}
$path = realpath($path);
$path = \realpath($path);
if ($path == false) {
return null;
}
@@ -156,13 +156,13 @@ class ComposerManager
// Dance to find the autoloader.
// TOOD: change this to open up the Composer config and use $c['config']['vendor-dir'] instead of "vendor"
$order = [
implode(DIRECTORY_SEPARATOR, [$this->cwd, "vendor", "autoload.php"]),
implode(DIRECTORY_SEPARATOR, [__DIR__, "..", "vendor", "autoload.php"]),
implode(DIRECTORY_SEPARATOR, [__DIR__, "..", "autoload.php"]),
\implode(\DIRECTORY_SEPARATOR, [$this->cwd, "vendor", "autoload.php"]),
\implode(\DIRECTORY_SEPARATOR, [__DIR__, "..", "vendor", "autoload.php"]),
\implode(\DIRECTORY_SEPARATOR, [__DIR__, "..", "autoload.php"]),
];
foreach ($order as $path) {
if (file_exists($path)) {
if (\file_exists($path)) {
return $path;
}
}
+10 -10
View File
@@ -5,10 +5,10 @@ namespace LotGD\Core;
use DateTime;
use Symfony\Component\Yaml\Exception\ParseException;
use Symfony\Component\Yaml\Yaml;
use LotGD\Core\Exceptions\InvalidConfigurationException;
use Symfony\Component\Yaml\Exception\ParseException;
use Symfony\Component\Yaml\Yaml;
/**
* The configuration information for a LotGD game. Configuration is read from
@@ -42,8 +42,8 @@ class Configuration
// Log dir path is relative to config directory.
$logPath = $rawConfig['logs']['path'] ?? '';
$realLogPath = dirname($configFilePath) . DIRECTORY_SEPARATOR . $logPath;
if ($realLogPath === false || strlen($realLogPath) == 0 || is_dir($realLogPath) === false) {
$realLogPath = \dirname($configFilePath) . \DIRECTORY_SEPARATOR . $logPath;
if ($realLogPath === false || \strlen($realLogPath) == 0 || \is_dir($realLogPath) === false) {
throw new InvalidConfigurationException("Invalid or missing log path: {$realLogPath}");
}
$this->logPath = $realLogPath;
@@ -53,10 +53,10 @@ class Configuration
$passwd = $rawConfig['database']['password'] ?? '';
$name = $rawConfig['database']['name'] ?? '';
if ($dsn === false || strlen($dsn) == 0) {
if ($dsn === false || \strlen($dsn) == 0) {
throw new InvalidConfigurationException("Invalid or missing data source name: {$dsn}");
}
if ($user === false || strlen($user) == 0) {
if ($user === false || \strlen($user) == 0) {
throw new InvalidConfigurationException("Invalid or missing database user: {$user}");
}
if ($passwd === false) {
@@ -105,12 +105,12 @@ class Configuration
*/
protected function retrieveRawConfig(string $configFilePath): array
{
return Yaml::parse(file_get_contents($configFilePath));
return Yaml::parse(\file_get_contents($configFilePath));
}
/**
* Returns database connection details needed for pdo to establish a connection.
*
*
* This function takes optionally replaces the string %cwd% in the database dsn and
* replaces it with the first parameter. This is important to normalize the database location
* across different working directories. Alternatively, SQLite databse names can also directly
@@ -121,7 +121,7 @@ class Configuration
public function getDatabaseConnectionDetails(string $cwd = ""): array
{
return [
str_replace("%cwd%", $cwd . DIRECTORY_SEPARATOR, $this->getDatabaseDSN()),
\str_replace("%cwd%", $cwd . \DIRECTORY_SEPARATOR, $this->getDatabaseDSN()),
$this->getDatabaseUser(),
$this->getDatabasePassword(),
];
+2 -2
View File
@@ -3,10 +3,10 @@ declare(strict_types=1);
namespace LotGD\Core\Console\Command;
use Symfony\Component\Console\Command\Command;
use LotGD\Core\Game;
use Symfony\Component\Console\Command\Command;
/**
* Parent class for daenerys tool commands.
*/
+4 -6
View File
@@ -1,10 +1,8 @@
<?php
declare(strict_types=1);
namespace LotGD\Core\Console\Command;
use LotGD\Core\Models\Character;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
@@ -12,7 +10,6 @@ use Symfony\Component\Console\Style\SymfonyStyle;
/**
* Command to list all characters.
* @package LotGD\Core\Console\Command
*/
class CharacterListCommand extends BaseCommand
{
@@ -22,7 +19,8 @@ class CharacterListCommand extends BaseCommand
protected function configure()
{
$this->setName('character:list')
->setDescription('Lists all characters');
->setDescription('Lists all characters')
;
}
/**
@@ -38,10 +36,10 @@ class CharacterListCommand extends BaseCommand
$table[1][] = [
$character->getId(),
$character->getDisplayName(),
$character->getLevel()
$character->getLevel(),
];
}
$io->table(...$table);
}
}
}
@@ -1,10 +1,8 @@
<?php
declare(strict_types=1);
namespace LotGD\Core\Console\Command;
use LotGD\Core\Models\Character;
use Symfony\Component\Console\Input\InputDefinition;
use Symfony\Component\Console\Input\InputInterface;
@@ -14,7 +12,6 @@ use Symfony\Component\Console\Style\SymfonyStyle;
/**
* Resets the viewpoint of a given character.
* @package LotGD\Core\Console\Command
*/
class CharacterResetViewpointCommand extends BaseCommand
{
@@ -27,9 +24,10 @@ class CharacterResetViewpointCommand extends BaseCommand
->setDescription('Resets the viewpoint of a given character.')
->setDefinition(
new InputDefinition([
new InputOption('id', null, InputOption::VALUE_REQUIRED)
new InputOption('id', null, InputOption::VALUE_REQUIRED),
])
);
)
;
}
/**
@@ -53,4 +51,4 @@ class CharacterResetViewpointCommand extends BaseCommand
$this->game->getEntityManager()->flush();
}
}
}
+11 -10
View File
@@ -17,7 +17,8 @@ class ConsoleCommand extends BaseCommand
protected function configure()
{
$this->setName('console')
->setDescription('Start a shell to interact with the game');
->setDescription('Start a shell to interact with the game')
;
}
/**
@@ -25,18 +26,18 @@ class ConsoleCommand extends BaseCommand
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
print("Daenerys console, the dragon prompt. lotgd/core " . \LotGD\Core\Game::getVersion() . ".\n");
print("Enter some PHP, but be careful, this is live and attached to your currently configured setup:\n\n");
print($this->game->getConfiguration());
print "Daenerys console, the dragon prompt. lotgd/core " . \LotGD\Core\Game::getVersion() . ".\n";
print "Enter some PHP, but be careful, this is live and attached to your currently configured setup:\n\n";
print $this->game->getConfiguration();
print("\n");
print("Try things like `\$g::getVersion()`. To quit, ^D or `exit();`.\n");
print("\n");
print "\n";
print "Try things like `\$g::getVersion()`. To quit, ^D or `exit();`.\n";
print "\n";
$boris = new \Boris\Boris('🐲 > ');
$boris->setLocal(array(
'g' => $this->game
));
$boris->setLocal([
'g' => $this->game,
]);
$boris->start();
}
}
+2 -4
View File
@@ -7,9 +7,6 @@ use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use LotGD\Core\Console\Main;
use LotGD\Core\Game;
/**
* Danerys command to initiate the database with default values.
*/
@@ -21,7 +18,8 @@ class DatabaseInitCommand extends BaseCommand
protected function configure()
{
$this->setName('database:init')
->setDescription('Initiates database with default values.');
->setDescription('Initiates database with default values.')
;
}
/**
@@ -8,9 +8,6 @@ use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use LotGD\Core\Console\Main;
use LotGD\Core\Game;
/**
* Danerys command to initiate the database with default values.
*/
@@ -22,7 +19,8 @@ class DatabaseSchemaUpdateCommand extends BaseCommand
protected function configure()
{
$this->setName('database:schemaUpdate')
->setDescription('Updates the database schema manually.');
->setDescription('Updates the database schema manually.')
;
}
/**
@@ -3,14 +3,12 @@ declare(strict_types=1);
namespace LotGD\Core\Console\Command;
use Composer\Repository\RepositoryInterface;
use LotGD\Core\ModuleManager;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use LotGD\Core\Exceptions\ClassNotFoundException;
use LotGD\Core\Exceptions\ModuleAlreadyExistsException;
use LotGD\Core\LibraryConfiguration;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Style\SymfonyStyle;
/**
@@ -24,7 +22,8 @@ class ModuleRegisterCommand extends BaseCommand
protected function configure()
{
$this->setName('module:register')
->setDescription('Register and initialize any newly installed modules');
->setDescription('Register and initialize any newly installed modules')
;
}
/**
@@ -17,7 +17,8 @@ class ModuleValidateCommand extends BaseCommand
protected function configure()
{
$this->setName('module:validate')
->setDescription('Validate installed modules');
->setDescription('Validate installed modules')
;
}
/**
@@ -27,14 +28,13 @@ class ModuleValidateCommand extends BaseCommand
{
$results = $this->game->getModuleManager()->validate();
if (count($results) > 0) {
if (\count($results) > 0) {
foreach ($results as $r) {
$output->writeln($r);
}
return 1;
} else {
$output->writeln("<info>LotGD modules validated</info>");
return 0;
}
$output->writeln("<info>LotGD modules validated</info>");
return 0;
}
}
+10 -13
View File
@@ -3,19 +3,16 @@ declare(strict_types=1);
namespace LotGD\Core\Console;
use Symfony\Component\Console\Application;
use LotGD\Core\Bootstrap;
use LotGD\Core\Game;
use LotGD\Core\Console\Command\{
CharacterListCommand,
CharacterResetViewpointCommand,
DatabaseInitCommand,
DatabaseSchemaUpdateCommand,
ModuleValidateCommand,
ModuleRegisterCommand,
ConsoleCommand
};
use LotGD\Core\Console\Command\CharacterListCommand;
use LotGD\Core\Console\Command\CharacterResetViewpointCommand;
use LotGD\Core\Console\Command\ConsoleCommand;
use LotGD\Core\Console\Command\DatabaseInitCommand;
use LotGD\Core\Console\Command\DatabaseSchemaUpdateCommand;
use LotGD\Core\Console\Command\ModuleRegisterCommand;
use LotGD\Core\Console\Command\ModuleValidateCommand;
use Symfony\Component\Console\Application;
/**
* Main execution class for the daenerys tool.
@@ -61,7 +58,7 @@ class Main
{
// Bootstrap application
$this->bootstrap = new Bootstrap();
$this->game = $this->bootstrap->getGame(getcwd());
$this->game = $this->bootstrap->getGame(\getcwd());
// Add commands
$this->addCommands();
+13 -14
View File
@@ -28,7 +28,7 @@ class DiceBag
*/
public function uniform(float $min, float $max): float
{
return (mt_rand(0, 100) / 100.0) * ($max - $min) + $min;
return (\mt_rand(0, 100) / 100.0) * ($max - $min) + $min;
}
/**
@@ -49,7 +49,7 @@ class DiceBag
$max = $a;
}
return mt_rand($min, $max);
return \mt_rand($min, $max);
}
/**
@@ -71,9 +71,9 @@ class DiceBag
$mean = ($max - $min) / 2;
$r = 0;
do {
$u1 = mt_rand() / mt_getrandmax();
$u2 = mt_rand() / mt_getrandmax();
$r = sqrt(-2 * log($u1)) * cos(2 * pi() * $u2) + $mean;
$u1 = \mt_rand() / \mt_getrandmax();
$u2 = \mt_rand() / \mt_getrandmax();
$r = \sqrt(-2 * \log($u1)) * \cos(2 * \pi() * $u2) + $mean;
} while ($r < $min || $r > $max);
return $r;
@@ -82,7 +82,7 @@ class DiceBag
/**
* This function has uniform distribution except for the extreme values, which are
* half as likely to happen.
* The code for this function was taken from LotGD in version 0.9.7
* The code for this function was taken from LotGD in version 0.9.7.
* @author MightyE, JT
* @param int $min
* @param int $max
@@ -90,23 +90,22 @@ class DiceBag
*/
public function pseudoBell(int $min = null, int $max = null): int
{
if (is_null($min)) {
return mt_rand();
if (\is_null($min)) {
return \mt_rand();
}
$min *= 1000;
if (is_null($max)) {
return (int)round(mt_rand($min)/1000, 0);
if (\is_null($max)) {
return (int)\round(\mt_rand($min) / 1000, 0);
}
$max *= 1000;
if ($min === $max) {
return (int)round($min/1000, 0);
return (int)\round($min / 1000, 0);
} elseif ($min < $max) {
return (int)round(mt_rand($min, $max)/1000, 0);
} else {
return (int)round(mt_rand($max, $min)/1000, 0);
return (int)\round(\mt_rand($min, $max) / 1000, 0);
}
return (int)\round(\mt_rand($max, $min) / 1000, 0);
}
}
+7 -7
View File
@@ -4,18 +4,17 @@ declare(strict_types=1);
namespace LotGD\Core\Doctrine\Annotations;
use Doctrine\Common\Annotations\Annotation;
use Doctrine\Common\Annotations\Annotation\Attributes;
use Doctrine\Common\Annotations\Annotation\Attribute;
use Doctrine\Common\Annotations\Annotation\Attributes;
use LotGD\Core\Exceptions\ArgumentException;
use LotGD\Core\Models\ExtendableModelInterface;
/**
* Annotation that is used to flag which entity a class extends.
* @package LotGD\Core\Doctrine
* @Annotation
* @Target("CLASS")
* @Attributes({
* @Attribute("of", type = "string")
* @Attribute("of", type="string")
* })
*/
class Extension
@@ -28,14 +27,15 @@ class Extension
* @param array $attributes
* @throws ArgumentException
*/
public function __construct(array $attributes) {
public function __construct(array $attributes)
{
$this->modelClass = $attributes["of"];
if (!class_exists($this->modelClass)) {
if (!\class_exists($this->modelClass)) {
throw new ArgumentException("The class given in of must be a valid class.");
}
if (!in_array(ExtendableModelInterface::class, class_implements($this->modelClass))) {
if (!\in_array(ExtendableModelInterface::class, \class_implements($this->modelClass))) {
throw new ArgumentException("The class given in of must implement the ExtendableModelInterface.");
}
}
@@ -48,4 +48,4 @@ class Extension
{
return $this->modelClass;
}
}
}
+7 -7
View File
@@ -4,17 +4,16 @@ declare(strict_types=1);
namespace LotGD\Core\Doctrine\Annotations;
use Doctrine\Common\Annotations\Annotation;
use Doctrine\Common\Annotations\Annotation\Attributes;
use Doctrine\Common\Annotations\Annotation\Attribute;
use Doctrine\Common\Annotations\Annotation\Attributes;
use LotGD\Core\Exceptions\ArgumentException;
/**
* Annotation that is used to link a static method to a model entity.
* @package LotGD\Core\Doctrine\Annotations
* @Annotation
* @Target("METHOD")
* @Attributes({
* @Attribute("as", type = "string")
* @Attribute("as", type="string")
* })
*/
class ExtensionMethod
@@ -27,14 +26,15 @@ class ExtensionMethod
* @param array $attributes
* @throws ArgumentException
*/
public function __construct(array $attributes) {
public function __construct(array $attributes)
{
$this->methodName = $attributes["as"];
if (!is_string($this->methodName)) {
if (!\is_string($this->methodName)) {
throw new ArgumentException("Property 'as' must be a string.");
}
if (strlen($this->methodName) == 0) {
if (\strlen($this->methodName) == 0) {
throw new ArgumentException("Property 'as' must not be an empty string.");
}
}
@@ -47,4 +47,4 @@ class ExtensionMethod
{
return $this->methodName;
}
}
}
+2 -4
View File
@@ -3,14 +3,12 @@ declare(strict_types=1);
namespace LotGD\Core\Doctrine;
use Doctrine\Common\Util\Debug;
use Doctrine\ORM\Event\LifecycleEventArgs;
use LotGD\Core\Game;
use LotGD\Core\GameAwareInterface;
/**
* Class EntityPostLoadEventListener
* @package LotGD\Core\Doctrine
* Class EntityPostLoadEventListener.
*/
class EntityPostLoadEventListener
{
@@ -37,4 +35,4 @@ class EntityPostLoadEventListener
$entity->setGame($this->game);
}
}
}
}
+1
View File
@@ -2,6 +2,7 @@
declare(strict_types=1);
namespace LotGD\Core;
use LotGD\Core\Events\EventContext;
interface EventHandler
+9 -12
View File
@@ -3,19 +3,16 @@ declare(strict_types=1);
namespace LotGD\Core;
use Doctrine\ORM\EntityManagerInterface;
use LotGD\Core\Events\EventContext;
use LotGD\Core\Models\EventSubscription;
use LotGD\Core\EventHandler;
use LotGD\Core\Events\EventContextData;
use LotGD\Core\Exceptions\ClassNotFoundException;
use LotGD\Core\Exceptions\SubscriptionNotFoundException;
use LotGD\Core\Exceptions\WrongTypeException;
use LotGD\Core\Events\EventContextData;
use LotGD\Core\Models\EventSubscription;
/**
* Manages a simple publish/subscribe system based on regular expressions
* matching event names and running a fixed
* matching event names and running a fixed.
*/
class EventManager
{
@@ -50,7 +47,7 @@ class EventManager
$subscriptions = $this->getSubscriptions();
foreach ($subscriptions as $s) {
if (preg_match($s->getPattern(), $event)) {
if (\preg_match($s->getPattern(), $event)) {
$class = $s->getClass();
$this->g->getLogger()->addDebug(" Handling with {$class}.");
@@ -102,14 +99,14 @@ class EventManager
}
// Validate the regular expression.
if (@preg_match($pattern, '') === false) {
if (@\preg_match($pattern, '') === false) {
throw new WrongTypeException("Invalid regular expression: {$pattern}");
}
$e = EventSubscription::create([
'pattern' => $pattern,
'class' => $class,
'library' => $library
'library' => $library,
]);
$this->g->getEntityManager()->persist($e);
@@ -126,11 +123,11 @@ class EventManager
*/
public function unsubscribe(string $pattern, string $class, string $library)
{
$e = $this->g->getEntityManager()->getRepository(EventSubscription::class)->find(array(
$e = $this->g->getEntityManager()->getRepository(EventSubscription::class)->find([
'pattern' => $pattern,
'class' => $class,
'library' => $library
));
'library' => $library,
]);
if (!$e) {
throw new SubscriptionNotFoundException("Subscription not found with pattern={$pattern} class={$class} library={$library}.");
}
+4 -6
View File
@@ -1,19 +1,17 @@
<?php
declare(strict_types=1);
namespace LotGD\Core\Events;
use LotGD\Core\Exceptions\ArgumentException;
use LotGD\Core\Models\Character;
/**
* Class CharacterEventData
* @package LotGD\Core\Events
* Class CharacterEventData.
*/
class CharacterEventData extends EventContextData
{
protected static $argumentConfig = [
"character" => ["type" => Character::class, "required" => true],
"value" => ["type" => "mixed", "required" => false]
"value" => ["type" => "mixed", "required" => false],
];
}
}
+4 -6
View File
@@ -3,10 +3,8 @@ declare(strict_types=1);
namespace LotGD\Core\Events;
/**
* Class EventContext
* @package LotGD\Core
* Class EventContext.
* @immutable
*/
class EventContext
@@ -69,7 +67,7 @@ class EventContext
}
/**
* Returns a data field
* Returns a data field.
* @param $field
* @return mixed
*/
@@ -79,7 +77,7 @@ class EventContext
}
/**
* Sets a data field
* Sets a data field.
* @param $field
* @param $value
*/
@@ -106,4 +104,4 @@ class EventContext
{
return $this->data === $originalData ? false : true;
}
}
}
+29 -22
View File
@@ -9,7 +9,6 @@ use LotGD\Core\Exceptions\ArgumentException;
* EventContextData to provide a basic structure for managing contextual data of an event.
*
* This class must be immutable and returns always a new instance of itself for any change.
* @package LotGD\Core\Events
* @immutable
*/
class EventContextData
@@ -41,31 +40,41 @@ class EventContextData
{
$configuration = static::$argumentConfig;
$types = [
"mixed" => function ($x) {return true;},
"int" => function ($x) {return is_int($x);},
"float" => function ($x) {return is_float($x);},
"numeric" => function($x) {return is_numeric($x);},
"string" => function($x) {return is_string($x);},
"mixed" => function ($x) {
return true;
},
"int" => function ($x) {
return \is_int($x);
},
"float" => function ($x) {
return \is_float($x);
},
"numeric" => function ($x) {
return \is_numeric($x);
},
"string" => function ($x) {
return \is_string($x);
},
];
$keys = array_keys($data);
$keys = \array_keys($data);
foreach ($keys as $key) {
if (!isset($configuration[$key])) {
throw new ArgumentException(sprintf("%s does not accept a field called %s", static::class, $key));
throw new ArgumentException(\sprintf("%s does not accept a field called %s", static::class, $key));
}
}
foreach ($configuration as $key => $config) {
if ($config["required"] === true and !isset($data[$key])) {
throw new ArgumentException(sprintf("%s must have a field called %s.", static::class, $key));
throw new ArgumentException(\sprintf("%s must have a field called %s.", static::class, $key));
}
if (isset($types[$config["type"]])) {
if ($types[$config["type"]]($data[$key]) === false) {
throw new ArgumentException(sprintf("The field %s of %s must be of type %s.", $key, static::class, $config["type"]));
throw new ArgumentException(\sprintf("The field %s of %s must be of type %s.", $key, static::class, $config["type"]));
}
} else {
if (!$data[$key] instanceof $config["type"]) {
throw new ArgumentException(sprintf("The field %s of %s must be of type %s", $key, static::class, $config["type"]));
throw new ArgumentException(\sprintf("The field %s of %s must be of type %s", $key, static::class, $config["type"]));
}
}
}
@@ -88,7 +97,7 @@ class EventContextData
*/
public function has(string $field): bool
{
return array_key_exists($field, $this->data);
return \array_key_exists($field, $this->data);
}
/**
@@ -100,13 +109,12 @@ class EventContextData
{
if ($this->has($field)) {
return $this->data[$field];
} else {
$this->throwException($field);
}
$this->throwException($field);
}
/**
* Sets a field to a new value and returns a new data container
* Sets a field to a new value and returns a new data container.
* @param string $field
* @param $value
* @return EventContextData
@@ -118,13 +126,12 @@ class EventContextData
$data[$field] = $value;
return new static($data);
} else {
$this->throwException($field);
}
$this->throwException($field);
}
/**
* Sets multiple fields at once
* Sets multiple fields at once.
* @param array $data array of $field=>$value pairs
* @return EventContextData
*/
@@ -144,12 +151,12 @@ class EventContextData
}
/**
* Returns a list of fields in this context
* Returns a list of fields in this context.
* @return array
*/
private function getListOfFields(): array
{
return array_keys($this->data);
return \array_keys($this->data);
}
/**
@@ -158,8 +165,8 @@ class EventContextData
*/
private function getFormattedListOfFields(): string
{
return substr(
implode(", ", $this->getListOfFields()),
return \substr(
\implode(", ", $this->getListOfFields()),
0,
-2
);
+10 -15
View File
@@ -3,15 +3,10 @@ declare(strict_types=1);
namespace LotGD\Core\Events;
use Doctrine\Common\Util\Debug;
use Doctrine\DBAL\Schema\View;
use LotGD\Core\Exceptions\ArgumentException;
use LotGD\Core\Models\Character;
use LotGD\Core\Models\Scene;
use LotGD\Core\Models\Viewpoint;
/**
* NavigateToScene data container which can be used for navigational events.
*
@@ -21,7 +16,6 @@ use LotGD\Core\Models\Viewpoint;
* scene Scene
* parameters array
* redirect Scene|null
* @package LotGD\Core\Events
*/
class NavigateToSceneData extends EventContextData
{
@@ -33,37 +27,38 @@ class NavigateToSceneData extends EventContextData
protected function __construct(array $data)
{
$mustHaveForm = ["referrer", "viewpoint", "scene", "parameters", "redirect"];
$doesHaveForm = array_keys($data);
sort($mustHaveForm); sort($doesHaveForm);
$doesHaveForm = \array_keys($data);
\sort($mustHaveForm);
\sort($doesHaveForm);
if ($doesHaveForm !== $mustHaveForm) {
throw new ArgumentException("A new NavigateToScene event must have referrer, viewpoint, scene, parameters and redirect.");
}
if ($data["referrer"] instanceof Scene === false and $data["referrer"] !== null) {
throw new ArgumentException(sprintf(
throw new ArgumentException(\sprintf(
"data[referrer] must be an instance of %s, %s given.",
Scene::class,
get_class($data["referrer"])
\get_class($data["referrer"])
));
}
if ($data["scene"] instanceof Scene === false) {
throw new ArgumentException(sprintf(
throw new ArgumentException(\sprintf(
"data[scene] must be an instance of %s, %s given.",
Scene::class,
get_class($data["scene"])
\get_class($data["scene"])
));
}
if ($data["viewpoint"] instanceof Viewpoint === false) {
throw new ArgumentException(sprintf(
throw new ArgumentException(\sprintf(
"data[viewpoint] must be an instance of %s, %s given.",
Viewpoint::class,
get_class($data["viewpoint"])
\get_class($data["viewpoint"])
));
}
parent::__construct($data);
}
}
}
+6 -8
View File
@@ -3,7 +3,6 @@ declare(strict_types=1);
namespace LotGD\Core\Events;
use LotGD\Core\Exceptions\ArgumentException;
use LotGD\Core\Models\Character;
use LotGD\Core\Models\Scene;
@@ -14,7 +13,6 @@ use LotGD\Core\Models\Scene;
* Fields are:
* character Character
* scene Scene|null
* @package LotGD\Core\Events
*/
class NewViewpointData extends EventContextData
{
@@ -25,26 +23,26 @@ class NewViewpointData extends EventContextData
*/
protected function __construct(array $data)
{
if (array_keys($data) !== ["character", "scene"]) {
if (\array_keys($data) !== ["character", "scene"]) {
throw new ArgumentException("A NewViewpoint event must have only character and scene.");
}
if (!$data["character"] instanceof Character) {
throw new ArgumentException(sprintf(
throw new ArgumentException(\sprintf(
"NewViewpoint data[character] must be an instance of %s, %s given.",
Character::class,
get_class($data)
\get_class($data)
));
}
if ($data["scene"] !== null and !$data["scene"] instanceof Scene) {
throw new ArgumentException(sprintf(
throw new ArgumentException(\sprintf(
"NewViewpoint data[scene] must be an instance of %s or null, %s given.",
Scene::class,
get_class($data)
\get_class($data)
));
}
parent::__construct($data);
}
}
}
+3 -5
View File
@@ -3,16 +3,14 @@ declare(strict_types=1);
namespace LotGD\Core\Events;
use LotGD\Core\Exceptions\ArgumentException;
use LotGD\Core\Models\Viewpoint;
/**
* Class ViewpointDecorationEventData
* @package LotGD\Core\Events
* Class ViewpointDecorationEventData.
*/
class ViewpointDecorationEventData extends EventContextData
{
protected static $argumentConfig = [
"viewpoint" => ["type" => Viewpoint::class, "required" => true]
"viewpoint" => ["type" => Viewpoint::class, "required" => true],
];
}
}
@@ -8,5 +8,4 @@ namespace LotGD\Core\Exceptions;
*/
class ActionNotFoundException extends CoreException
{
}
+1 -2
View File
@@ -4,9 +4,8 @@ declare(strict_types=1);
namespace LotGD\Core\Exceptions;
/**
* Exception if a specific, required argument is missing
* Exception if a specific, required argument is missing.
*/
class ArgumentEmptyException extends ArgumentException
{
}
+1 -2
View File
@@ -4,9 +4,8 @@ declare(strict_types=1);
namespace LotGD\Core\Exceptions;
/**
* Exception if a specific, required argument is missing
* Exception if a specific, required argument is missing.
*/
class ArgumentException extends CoreException
{
}
+1 -2
View File
@@ -4,9 +4,8 @@ declare(strict_types=1);
namespace LotGD\Core\Exceptions;
/**
* Exception if a specific, required argument is missing
* Exception if a specific, required argument is missing.
*/
class AttributeMissingException extends CoreException
{
}
+1 -2
View File
@@ -4,9 +4,8 @@ declare(strict_types=1);
namespace LotGD\Core\Exceptions;
/**
* Exception if a specific, required argument is missing
* Exception if a specific, required argument is missing.
*/
class BattleEventException extends BattleException
{
}
+1 -2
View File
@@ -4,9 +4,8 @@ declare(strict_types=1);
namespace LotGD\Core\Exceptions;
/**
* Exception if a specific, required argument is missing
* Exception if a specific, required argument is missing.
*/
class BattleException extends CoreException
{
}
+1 -2
View File
@@ -4,9 +4,8 @@ declare(strict_types=1);
namespace LotGD\Core\Exceptions;
/**
* Exception if a specific, required argument is missing
* Exception if a specific, required argument is missing.
*/
class BattleIsOverException extends BattleException
{
}
+1 -2
View File
@@ -4,9 +4,8 @@ declare(strict_types=1);
namespace LotGD\Core\Exceptions;
/**
* Exception if a specific, required argument is missing
* Exception if a specific, required argument is missing.
*/
class BattleNotOverException extends BattleException
{
}
@@ -4,9 +4,8 @@ declare(strict_types=1);
namespace LotGD\Core\Exceptions;
/**
* Exception if a specific, required argument is missing
* Exception if a specific, required argument is missing.
*/
class BuffListAlreadyActivatedException extends CoreException
{
}
+1 -2
View File
@@ -4,9 +4,8 @@ declare(strict_types=1);
namespace LotGD\Core\Exceptions;
/**
* Exception if a specific, required argument is missing
* Exception if a specific, required argument is missing.
*/
class BuffSlotOccupiedException extends CoreException
{
}
+1 -2
View File
@@ -4,9 +4,8 @@ declare(strict_types=1);
namespace LotGD\Core\Exceptions;
/**
* Exception if a builder is missing an argument
* Exception if a builder is missing an argument.
*/
class BuilderException extends CoreException
{
}
@@ -8,5 +8,4 @@ namespace LotGD\Core\Exceptions;
*/
class CharacterNotFoundException extends CoreException
{
}
+2 -6
View File
@@ -1,15 +1,11 @@
<?php
declare(strict_types=1);
namespace LotGD\Core\Exceptions;
/**
* Class CharacterStatException
* @package LotGD\Core\Exceptions
* Class CharacterStatException.
*/
class CharacterStatException extends CoreException
{
}
}
@@ -1,15 +1,11 @@
<?php
declare(strict_types=1);
namespace LotGD\Core\Exceptions;
/**
* Class CharacterStatExistsException
* @package LotGD\Core\Exceptions
* Class CharacterStatExistsException.
*/
class CharacterStatExistsException extends CharacterStatException
{
}
}
@@ -1,15 +1,11 @@
<?php
declare(strict_types=1);
namespace LotGD\Core\Exceptions;
/**
* Class CharacterStatGroupExistsException
* @package LotGD\Core\Exceptions
* Class CharacterStatGroupExistsException.
*/
class CharacterStatGroupExistsException extends CharacterStatException
{
}
}
@@ -1,15 +1,11 @@
<?php
declare(strict_types=1);
namespace LotGD\Core\Exceptions;
/**
* Class CharacterStatGroupNotFoundException
* @package LotGD\Core\Exceptions
* Class CharacterStatGroupNotFoundException.
*/
class CharacterStatGroupNotFoundException extends CharacterStatException
{
}
}
@@ -1,15 +1,11 @@
<?php
declare(strict_types=1);
namespace LotGD\Core\Exceptions;
/**
* Class CharacterStatNotFoundException
* @package LotGD\Core\Exceptions
* Class CharacterStatNotFoundException.
*/
class CharacterStatNotFoundException extends CharacterStatException
{
}
}
+1 -2
View File
@@ -4,9 +4,8 @@ declare(strict_types=1);
namespace LotGD\Core\Exceptions;
/**
* Exception if a specific, required argument is missing
* Exception if a specific, required argument is missing.
*/
class ClassNotFoundException extends CoreException
{
}
-1
View File
@@ -8,5 +8,4 @@ namespace LotGD\Core\Exceptions;
*/
class CoreException extends \Exception
{
}
@@ -8,5 +8,4 @@ namespace LotGD\Core\Exceptions;
*/
class EntityAlreadyExistsException extends EntityException
{
}
@@ -8,5 +8,4 @@ namespace LotGD\Core\Exceptions;
*/
class EntityDoesNotExistException extends EntityException
{
}
+1 -2
View File
@@ -4,9 +4,8 @@ declare(strict_types=1);
namespace LotGD\Core\Exceptions;
/**
* A basic entity exception
* A basic entity exception.
*/
class EntityException extends CoreException
{
}
@@ -8,5 +8,4 @@ namespace LotGD\Core\Exceptions;
*/
class InvalidConfigurationException extends CoreException
{
}
-1
View File
@@ -8,5 +8,4 @@ namespace LotGD\Core\Exceptions;
*/
class InvalidModelException extends CoreException
{
}
+1 -2
View File
@@ -4,9 +4,8 @@ declare(strict_types=1);
namespace LotGD\Core\Exceptions;
/**
* Exception if a specific, required argument is missing
* Exception if a specific, required argument is missing.
*/
class IsNullException extends CoreException
{
}
+1 -2
View File
@@ -4,9 +4,8 @@ declare(strict_types=1);
namespace LotGD\Core\Exceptions;
/**
* Exception if a specific, required argument is missing
* Exception if a specific, required argument is missing.
*/
class KeyNotFoundException extends CoreException
{
}
@@ -8,5 +8,4 @@ namespace LotGD\Core\Exceptions;
*/
class LibraryDoesNotExistException extends CoreException
{
}
@@ -8,5 +8,4 @@ namespace LotGD\Core\Exceptions;
*/
class ModuleAlreadyExistsException extends CoreException
{
}
@@ -8,5 +8,4 @@ namespace LotGD\Core\Exceptions;
*/
class ModuleDoesNotExistException extends CoreException
{
}
+1 -2
View File
@@ -4,9 +4,8 @@ declare(strict_types=1);
namespace LotGD\Core\Exceptions;
/**
* Exception if a specific, required argument is missing
* Exception if a specific, required argument is missing.
*/
class NotImplementedException extends CoreException
{
}
+1 -2
View File
@@ -4,9 +4,8 @@ declare(strict_types=1);
namespace LotGD\Core\Exceptions;
/**
* Exception if a specific, required argument is missing
* Exception if a specific, required argument is missing.
*/
class ParentAlreadySetException extends CoreException
{
}
@@ -8,5 +8,4 @@ namespace LotGD\Core\Exceptions;
*/
class PermissionAlreadyExistsException extends EntityAlreadyExistsException
{
}
@@ -8,5 +8,4 @@ namespace LotGD\Core\Exceptions;
*/
class PermissionDoesNotExistException extends EntityDoesNotExistException
{
}
@@ -8,5 +8,4 @@ namespace LotGD\Core\Exceptions;
*/
class PermissionIdNotFoundException extends EntityDoesNotExistException
{
}
@@ -8,5 +8,4 @@ namespace LotGD\Core\Exceptions;
*/
class SceneNotFoundException extends CoreException
{
}
@@ -8,5 +8,4 @@ namespace LotGD\Core\Exceptions;
*/
class SubscriptionNotFoundException extends CoreException
{
}
@@ -4,9 +4,8 @@ declare(strict_types=1);
namespace LotGD\Core\Exceptions;
/**
* Gets thrown if a array containts an unexpected array key
* Gets thrown if a array containts an unexpected array key.
*/
class UnexpectedArrayKeyException extends CoreException
{
}
-1
View File
@@ -8,5 +8,4 @@ namespace LotGD\Core\Exceptions;
*/
class WrongTypeException extends CoreException
{
}
+25 -24
View File
@@ -1,21 +1,23 @@
<?php
declare (strict_types=1);
declare(strict_types=1);
namespace LotGD\Core;
use DateTime;
use Doctrine\Common\Util\Debug;
use Doctrine\ORM\EntityManagerInterface;
use LotGD\Core\Events\NavigateToSceneData;
use LotGD\Core\Events\NewViewpointData;
use Monolog\Logger;
use LotGD\Core\Exceptions\ActionNotFoundException;
use LotGD\Core\Models\{
Character, SceneConnectable, Viewpoint, Scene, SceneConnection
};
use LotGD\Core\Exceptions\ {
ActionNotFoundException, CharacterNotFoundException, InvalidConfigurationException, SceneNotFoundException
};
use LotGD\Core\Exceptions\CharacterNotFoundException;
use LotGD\Core\Exceptions\InvalidConfigurationException;
use LotGD\Core\Exceptions\SceneNotFoundException;
use LotGD\Core\Models\Character;
use LotGD\Core\Models\Scene;
use LotGD\Core\Models\SceneConnectable;
use LotGD\Core\Models\SceneConnection;
use LotGD\Core\Models\Viewpoint;
use Monolog\Logger;
/**
* The main game class.
@@ -34,7 +36,6 @@ class Game
private $cwd;
private $timeKeeper;
/**
* Construct a game. You probably want to use Bootstrap to do this.
* @param Configuration $configuration
@@ -188,7 +189,7 @@ class Game
}
/**
* Returns the Message manager
* Returns the Message manager.
* @return MessageManager
*/
public function getMessageManager(): MessageManager
@@ -197,7 +198,7 @@ class Game
}
/**
* Sets the Message Manager
* Sets the Message Manager.
* @param MessageManager $messageManager
*/
public function setMessageManager(MessageManager $messageManager): void
@@ -207,8 +208,8 @@ class Game
/**
* Returns the currently configured user character.
* @return Character
* @throws CharacterNotFoundException
* @return Character
*/
public function getCharacter(): Character
{
@@ -229,8 +230,8 @@ class Game
/**
* Return the viewpoint for the current user.
* @return Viewpoint
* @throws InvalidConfigurationException
* @return Viewpoint
*/
public function getViewpoint(): Viewpoint
{
@@ -241,7 +242,7 @@ class Game
// scene.
$contextData = NewViewpointData::create([
'character' => $this->getCharacter(),
'scene' => null
'scene' => null,
]);
$contextData = $this->getEventManager()->publish('h/lotgd/core/default-scene', $contextData);
@@ -292,7 +293,7 @@ class Game
// Iterates through all connections and adds an action to the connected scene to the action group. If the connection
// belongs to a new connection Group, it creates a new ActionGroup.
$scene->getConnections()->map(function(SceneConnection $connection) use ($scene, &$actionGroups) {
$scene->getConnections()->map(function (SceneConnection $connection) use ($scene, &$actionGroups) {
if ($connection->getOutgoingScene() === $scene) {
// current scene is outgoing, use incoming.
$connectedScene = $connection->getIncomingScene();
@@ -328,14 +329,14 @@ class Game
});
// Logging
$counts = implode(", ", array_map(function($k, $v) {
return $k .count($v);
}, array_keys($actionGroups), array_values($actionGroups)));
$counts = \implode(", ", \array_map(function ($k, $v) {
return $k .\count($v);
}, \array_keys($actionGroups), \array_values($actionGroups)));
$this->getLogger()->addDebug("Total actions: {$counts}");
$actionGroups[ActionGroup::HiddenGroup] = new ActionGroup(ActionGroup::HiddenGroup, '', 100);
$viewpoint->setActionGroups(array_values($actionGroups));
$viewpoint->setActionGroups(\array_values($actionGroups));
// Let and installed listeners (ie modules) make modifications to the
// new viewpoint, including the ability to redirect the user to
@@ -345,7 +346,7 @@ class Game
'viewpoint' => $viewpoint,
'scene' => $scene,
'parameters' => $parameters,
'redirect' => null
'redirect' => null,
]);
$hook = 'h/lotgd/core/navigate-to/' . $scene->getTemplate();
@@ -356,7 +357,7 @@ class Game
$id = $scene->getId();
$this->getLogger()->debug("Redirecting to sceneId={$id}");
}
} while($scene !== null);
} while ($scene !== null);
}
/**
@@ -382,14 +383,14 @@ class Game
$sceneId = $action->getDestinationSceneId();
$scene = $this->getEntityManager()->getRepository(Scene::class)->find([
'id' => $sceneId
'id' => $sceneId,
]);
if ($scene == null) {
throw new SceneNotFoundException("Cannot find sceneId={$sceneId} specified by actionId={$actionId}.");
}
// action parameters overwrite other parameters since the former cannot be changed by the user
$parameters = array_merge($parameters, $actionParameters);
$parameters = \array_merge($parameters, $actionParameters);
$this->navigateToScene($scene, $parameters);
+2 -3
View File
@@ -4,11 +4,10 @@ declare(strict_types=1);
namespace LotGD\Core;
/**
* Interface for classes that are aware of the game
* @package LotGD\Core
* Interface for classes that are aware of the game.
*/
interface GameAwareInterface
{
public function setGame(Game $g);
public function getGame(): Game;
}
}
+9 -11
View File
@@ -3,18 +3,16 @@ declare(strict_types=1);
namespace LotGD\Core;
use Doctrine\ORM\EntityManagerInterface;
use Monolog\Logger;
use LotGD\Core\Exceptions\BuilderException;
use Monolog\Logger;
/**
* The GameBuilder class is used to build a Game object with all dependencies that are needed.
*
* You must provide $cwd, $configuration, $entityManager and a logger instance using the with* methods.
* You can provide additional class *names* for additional dependency injections using the use* methods.
* @package LotGD\Core
*/
class GameBuilder
{
@@ -31,8 +29,8 @@ class GameBuilder
/**
* Creates the game instance with the prepared parameters.
* @return Game
* @throws BuilderException if at least one of cwd, configuration, entityManager or logger as not been set.
* @return Game
*/
public function create(): Game
{
@@ -63,13 +61,13 @@ class GameBuilder
$diceBag = $this->diceBagClass ?? DiceBag::class;
$game->setDiceBag(new $diceBag());
$messageManager=$this->messageManagerClass ?? MessageManager::class;
$messageManager = $this->messageManagerClass ?? MessageManager::class;
$game->setMessageManager(new $messageManager());
return $game;
}
/**
* Adds current working directory argument
* Adds current working directory argument.
* @param string $cwd
* @return self
*/
@@ -80,7 +78,7 @@ class GameBuilder
}
/**
* Configuration
* Configuration.
* @param Configuration $conf
* @return self
*/
@@ -113,13 +111,13 @@ class GameBuilder
}
/**
* Sets the fqcn for the message manager to be used
* Sets the fqcn for the message manager to be used.
* @param string $messageManagerFqcn
* @return self
*/
public function withMessageManager(string $messageManagerFqcn): self
{
$this->messageManagerClass=$messageManagerFqcn;
$this->messageManagerClass = $messageManagerFqcn;
return $this;
}
@@ -166,4 +164,4 @@ class GameBuilder
$this->diceBagClass = $diceBagFqcn;
return $this;
}
}
}
+23 -25
View File
@@ -1,13 +1,11 @@
<?php
declare(strict_types=1);
namespace LotGD\Core;
use Composer\Package\PackageInterface;
use Symfony\Component\Console\Application;
use Symfony\Component\Yaml\Yaml;
use LotGD\Core\ComposerManager;
/**
* Represents the configuration of a LotGD library (like the core, crate or module),
* with its configuration parameters.
@@ -43,7 +41,7 @@ class LibraryConfiguration
if ($basePackage && $basePackage->getName() === $package->getName()) {
// Whatever the base package is in this repo is at $cwd.
$path = $cwd;
} elseif (in_array($package->getType(), ["lotgd-module", "lotgd-crate"])) {
} elseif (\in_array($package->getType(), ["lotgd-module", "lotgd-crate"])) {
// lotgd-modules are installed in the vendor directory.
$installationManager = $composerManager->getComposer()->getInstallationManager();
$path = $installationManager->getInstallPath($package);
@@ -52,15 +50,15 @@ class LibraryConfiguration
$path = $cwd;
}
$confFile = $path . DIRECTORY_SEPARATOR . 'lotgd.yml';
$confFile = $path . \DIRECTORY_SEPARATOR . 'lotgd.yml';
$this->rootNamespace = $this->findRootNamespace($package);
if (file_exists($confFile)) {
$this->rawConfig = Yaml::parse(file_get_contents($confFile));
if (\file_exists($confFile)) {
$this->rawConfig = Yaml::parse(\file_get_contents($confFile));
} else {
$name = $package->getName();
$type = $package->getType();
throw new \Exception("Library {$name} of type {$type} does not have a lotgd.yml in it's root ($confFile).");
throw new \Exception("Library {$name} of type {$type} does not have a lotgd.yml in it's root (${confFile}).");
}
$this->findEntityDirectory();
@@ -87,25 +85,25 @@ class LibraryConfiguration
}
/**
* Searches for a root namespace
* Searches for a root namespace.
*
* This function searches the package's configuration to find it's root namespace.
* For this, it uses the following order:
* - check psr-4 autoload configuration. If used, it takes the first element
* - check psr-0 autoload configuration. If used, it takes the first element
* @param PackageInterface $package
* @return string
* @throws \Exception if no namespace has been found
* @return string
*/
protected function findRootNamespace(PackageInterface $package): string
{
$autoload = $package->getAutoload();
if (isset($autoload["psr-4"]) && count($autoload["psr-4"]) > 0) {
return key($autoload["psr-4"]);
if (isset($autoload["psr-4"]) && \count($autoload["psr-4"]) > 0) {
return \key($autoload["psr-4"]);
}
if (isset($autoload["psr-0"]) && count($autoload["psr-0"]) > 0) {
return key($autoload["psr-0"]);
if (isset($autoload["psr-0"]) && \count($autoload["psr-0"]) > 0) {
return \key($autoload["psr-0"]);
}
$name = $package->getName();
@@ -142,14 +140,14 @@ class LibraryConfiguration
}
/**
* Tries to iterate an array element given by the arguments
* Tries to iterate an array element given by the arguments.
* @param scalar $argument1,... array keys, by increasing depth
*/
public function iterateKey(...$arguments)
{
$result = $this->getSubKeyIfItExists($arguments);
if (is_array($result)) {
if (\is_array($result)) {
foreach ($result as $key => $val) {
yield $key => $val;
}
@@ -157,9 +155,9 @@ class LibraryConfiguration
}
/**
* Returns a subkey of an array if it exists or null
* @param scalar $argument1,... array keys, by increasing depth
* @return type
* Returns a subkey of an array if it exists or null.
* @param mixed ...$arguments
* @return mixed
*/
protected function getConfig(...$arguments)
{
@@ -177,12 +175,12 @@ class LibraryConfiguration
$entityNamespace = $this->getConfig("entityNamespace");
if (is_null($entityNamespace) === false) {
if (\is_null($entityNamespace) === false) {
$entityDirectory = $this->composerManager->translateNamespaceToPath($entityNamespace);
if ($entityDirectory === null) {
throw new \Exception("Could not translate namespace {$entityNamespace} into a directory.");
} else if (is_dir($entityDirectory) === false) {
} elseif (\is_dir($entityDirectory) === false) {
throw new \Exception("Path {$entityDirectory}, translated from namespace {$entityNamespace}, is not a valid directory.");
}
@@ -209,7 +207,7 @@ class LibraryConfiguration
}
/**
* Searches the config file for daenerys commands and, if found, adds the class name to a list
* Searches the config file for daenerys commands and, if found, adds the class name to a list.
*/
protected function findDaenerysCommands()
{
@@ -222,16 +220,16 @@ class LibraryConfiguration
}
/**
* Returns true if this configuration has daenerys commands
* Returns true if this configuration has daenerys commands.
* @return bool
*/
public function hasDaenerysCommands(): bool
{
return count($this->daenerysCommands) > 0 ? true : false;
return \count($this->daenerysCommands) > 0 ? true : false;
}
/**
* Returns a list of daenerys commands
* Returns a list of daenerys commands.
*/
public function getDaenerysCommands(): array
{
+4 -7
View File
@@ -1,12 +1,8 @@
<?php
declare(strict_types=1);
namespace LotGD\Core;
use Composer\Package\PackageInterface;
use Symfony\Component\Console\Application;
use LotGD\Core\ComposerManager;
/**
* Handle the library configurations for the installed core, crate and modules.
*/
@@ -38,7 +34,7 @@ class LibraryConfigurationManager
* format.
* @return LibraryConfiguration|null
*/
public function getConfigurationForLibrary(string $library)
public function getConfigurationForLibrary(string $library): ?LibraryConfiguration
{
$configs = $this->getConfigurations();
@@ -54,7 +50,8 @@ class LibraryConfigurationManager
* Return an array of the library configurations.
* @return LibraryConfiguration[]
*/
public function getConfigurations(): array {
public function getConfigurations(): array
{
return $this->configurations;
}
+8 -9
View File
@@ -10,45 +10,44 @@ use LotGD\Core\Models\SystemCharacter;
/**
* Manages the message system overall
* Class MessageManager
* @package LotGD\Core
* Class MessageManager.
*/
class MessageManager
{
/**
* Sends a message to a MessageThread
* Sends a message to a MessageThread.
* @param \LotGD\Core\Models\Character $from
* @param string $message
* @param \LotGD\Core\Models\MessageThread $thread
* @param bool $systemMessage
* @return \LotGD\Core\Models\Message
* @throws Exceptions\CoreException
* @return \LotGD\Core\Models\Message
*/
public function send(
Character $from,
string $message,
MessageThread $thread,
bool $systemMessage = false
) {
): Message {
$message = new Message($from, $message, $thread, $systemMessage);
$thread->addMessage($message);
return $message;
}
/**
* Sends a system message to a MessageThread
* Sends a system message to a MessageThread.
* @param string $message
* @param \LotGD\Core\Models\MessageThread $thread
* @return \LotGD\Core\Models\Message
* @throws Exceptions\ArgumentException
* @throws Exceptions\CoreException
* @return \LotGD\Core\Models\Message
*/
public function sendSystemMessage(
string $message,
MessageThread $thread
) {
): Message {
$message = new Message(SystemCharacter::getInstance(), $message, $thread, true);
$thread->addMessage($message);
return $message;
}
}
}
+8 -9
View File
@@ -3,16 +3,14 @@ declare(strict_types=1);
namespace LotGD\Core;
use Doctrine\Common\Annotations\AnnotationReader;
use LotGD\Core\Doctrine\Annotations\Extension;
use LotGD\Core\Doctrine\Annotations\ExtensionMethod;
use LotGD\Core\Exceptions\ArgumentException;
use ReflectionClass;
use Doctrine\Common\Annotations\AnnotationReader;
use LotGD\Core\Doctrine\Annotations\Extension;
/**
* Contains method to help the extension of a model.
* @package LotGD\Core
*/
class ModelExtender
{
@@ -32,8 +30,9 @@ class ModelExtender
/**
* @param string[] $classes
*/
public function addMore(array $classes): void {
foreach($classes as $class) {
public function addMore(array $classes): void
{
foreach ($classes as $class) {
$this->add($class);
}
}
@@ -49,7 +48,7 @@ class ModelExtender
$extensionAnnotation = $this->reader->getClassAnnotation($reflectionClass, Extension::class);
if ($extensionAnnotation === null) {
throw new ArgumentException(sprintf("Class %s must have the class Annotation %s", $class, Extension::class));
throw new ArgumentException(\sprintf("Class %s must have the class Annotation %s", $class, Extension::class));
}
$modelClass = $extensionAnnotation->getModelClass();
@@ -63,7 +62,7 @@ class ModelExtender
foreach ($reflectionMethods as $method) {
if ($method->isStatic() === false) {
throw new ArgumentException(sprintf("Method %s must be static.", $method->getName()));
throw new ArgumentException(\sprintf("Method %s must be static.", $method->getName()));
}
/** @var ExtensionMethod $extensionMethodAnnotation */
@@ -92,4 +91,4 @@ class ModelExtender
return self::$classes[$modelClassName][$methodName];
}
}
}
+6 -9
View File
@@ -7,8 +7,6 @@ use Generator;
use LotGD\Core\Exceptions\PermissionAlreadyExistsException;
use LotGD\Core\Exceptions\PermissionDoesNotExistException;
use LotGD\Core\Models\Permission;
use LotGD\Core\Models\PermissionAssociationInterface;
/**
* This abtract class provides functionality for user entities that crates might
@@ -38,7 +36,7 @@ abstract class Actor
*/
protected function loadPermissions()
{
if (class_exists($this->getPermissionAssociationClass()) === false) {
if (\class_exists($this->getPermissionAssociationClass()) === false) {
throw new PermissionAssociationEntityMissingException(
"The method getPermissionAssociationClass does not return a valid class name."
);
@@ -104,13 +102,12 @@ abstract class Actor
if ($this->hasPermissionSet($permission->getId())) {
$permissionId = $permission->getId();
throw new PermissionAlreadyExistsException("The permission with the id {$permissionId} has already been set on this actor.");
} else {
$associationEntity = $this->getPermissionAssociationClass();
$permissionAssoc = new $associationEntity($this, $permission, $state);
$this->permissions->add($permissionAssoc);
$this->permissionIdToAssociation[$permissionAssoc->getId()] = $permissionAssoc;
}
$associationEntity = $this->getPermissionAssociationClass();
$permissionAssoc = new $associationEntity($this, $permission, $state);
$this->permissions->add($permissionAssoc);
$this->permissionIdToAssociation[$permissionAssoc->getId()] = $permissionAssoc;
}
/**
+8 -8
View File
@@ -25,12 +25,13 @@ abstract class BasicEnemy implements FighterInterface
* BasicEnemy constructor. Sets uuid upon creation.
* @throws \Exception
*/
public function __construct() {
public function __construct()
{
$this->id = Uuid::uuid4();
}
/**
* Returns the enemy's id
* Returns the enemy's id.
* @return int
*/
public function getId(): UuidInterface
@@ -39,7 +40,7 @@ abstract class BasicEnemy implements FighterInterface
}
/**
* Returns the enemy's name
* Returns the enemy's name.
* @return string
*/
public function getName(): string
@@ -66,7 +67,7 @@ abstract class BasicEnemy implements FighterInterface
}
/**
* Returns the enemy's current health
* Returns the enemy's current health.
* @return int
*/
public function getHealth(): int
@@ -79,7 +80,7 @@ abstract class BasicEnemy implements FighterInterface
}
/**
* Sets the enemy's current health
* Sets the enemy's current health.
* @param int $health
*/
public function setHealth(int $health)
@@ -105,7 +106,7 @@ abstract class BasicEnemy implements FighterInterface
}
/**
* Heals the enemy
* Heals the enemy.
* @param int $heal
* @param type $overheal True if healing bigger than maxhealth is desired.
*/
@@ -126,8 +127,7 @@ abstract class BasicEnemy implements FighterInterface
{
if ($this->getHealth() > 0) {
return true;
} else {
return false;
}
return false;
}
}
+1 -1
View File
@@ -29,8 +29,8 @@ class BattleEvent
/**
* Returns a string describing the event.
* @param \LotGD\Core\Models\BattleEvents\Game $game
* @return string
* @throws BattleEventException
* @return string
*/
public function decorate(Game $game): string
{
@@ -3,7 +3,6 @@ declare(strict_types=1);
namespace LotGD\Core\Models\BattleEvents;
use LotGD\Core\Exceptions\BattleEventException;
use LotGD\Core\Game;
/**
+8 -12
View File
@@ -7,7 +7,7 @@ use LotGD\Core\Game;
use LotGD\Core\Models\FighterInterface;
/**
* BattleEvent
* BattleEvent.
*/
class DamageEvent extends BattleEvent
{
@@ -52,7 +52,7 @@ class DamageEvent extends BattleEvent
if ($this->damage !== 0) {
// Only damage the victim if there is an actual effect
$victim = $this->damage > 0 ? $this->defender : $this->attacker;
$victim->damage(abs($this->damage));
$victim->damage(\abs($this->damage));
}
}
@@ -69,21 +69,17 @@ class DamageEvent extends BattleEvent
if ($this->damage === 0) {
if ($this->attacker === $game->getCharacter()) {
return "You try to hit {$defendersName} but MISS!";
} else {
return "{$attackersName} tries to hit you but they MISS!";
}
return "{$attackersName} tries to hit you but they MISS!";
} elseif ($this->damage > 0) {
if ($this->attacker === $game->getCharacter()) {
return "You hit {$defendersName} for {$this->damage} points of damage!";
} else {
return "{$attackersName} hits you for {$this->damage} points of damage!";
}
} else {
if ($this->attacker === $game->getCharacter()) {
return "You try to hit {$defendersName} but are RIPOSTED for {$this->damage} points of damage";
} else {
return "{$attackersName} tries to hit you but you RIPOSTE for {$this->damage} points of damage";
}
return "{$attackersName} hits you for {$this->damage} points of damage!";
}
if ($this->attacker === $game->getCharacter()) {
return "You try to hit {$defendersName} but are RIPOSTED for {$this->damage} points of damage";
}
return "{$attackersName} tries to hit you but you RIPOSTE for {$this->damage} points of damage";
}
}
@@ -66,10 +66,10 @@ class DamageLifetapEvent extends BattleEvent
{
parent::decorate($game);
return str_replace(
return \str_replace(
[
"{target}",
"{damage}"
"{damage}",
],
[
$this->target->getDisplayName(),
@@ -35,7 +35,7 @@ class DamageReflectionEvent extends BattleEvent
}
/**
* Returns the damage
* Returns the damage.
* @return int
*/
public function getDamage(): int
@@ -66,10 +66,10 @@ class DamageReflectionEvent extends BattleEvent
{
parent::decorate($game);
return str_replace(
return \str_replace(
[
"{target}",
"{damage}"
"{damage}",
],
[
$this->target->getDisplayName(),
@@ -3,7 +3,6 @@ declare(strict_types=1);
namespace LotGD\Core\Models\BattleEvents;
use LotGD\Core\Exceptions\BattleEventException;
use LotGD\Core\Game;
use LotGD\Core\Models\FighterInterface;
@@ -42,7 +41,7 @@ class MinionDamageEvent extends BattleEvent
{
parent::decorate($game);
return str_replace(
return \str_replace(
[
"{target}",
"{amount}",
@@ -3,7 +3,6 @@ declare(strict_types=1);
namespace LotGD\Core\Models\BattleEvents;
use LotGD\Core\Exceptions\BattleEventException;
use LotGD\Core\Game;
use LotGD\Core\Models\FighterInterface;
@@ -48,16 +47,16 @@ class RegenerationBuffEvent extends BattleEvent
parent::decorate($game);
if ($this->regeneration === 0) {
return str_replace(
return \str_replace(
"{target}",
$target->getDisplayName(),
$this->noEffectMessage
);
} else {
return str_replace(
}
return \str_replace(
[
"{target}",
"{amount}"
"{amount}",
],
[
$target->getDisplayName(),
@@ -65,7 +64,6 @@ class RegenerationBuffEvent extends BattleEvent
],
$this->effectMessage
);
}
}
/**
@@ -89,8 +87,8 @@ class RegenerationBuffEvent extends BattleEvent
// Damaging
if ($healthLeft === 0) {
$this->regeneration = 0;
} elseif ($healthLeft < -1*$this->regeneration) {
$this->regeneration = - $healthLeft;
} elseif ($healthLeft < -1 * $this->regeneration) {
$this->regeneration = -$healthLeft;
}
}
+74 -75
View File
@@ -35,43 +35,43 @@ class Buff
/** @Column(type="string") */
private $slot;
/**
* Name of the buff
* Name of the buff.
* @var string
* @Column(type="string")
*/
private $name;
/**
* The message given upon activation of the buff
* The message given upon activation of the buff.
* @var string
* @Column(type="text")
*/
private $startMessage = "";
/**
* The message given every round
* The message given every round.
* @var string
* @Column(type="text")
*/
private $roundMessage = "";
/**
* The message given if the buff ends
* The message given if the buff ends.
* @var string
* @Column(type="text")
*/
private $endMessage = "";
/**
* The message given if the effect has success
* The message given if the effect has success.
* @var string
* @Column(type="text")
*/
private $effectSucceedsMessage = "";
/**
* The message given if the effect fails
* The message given if the effect fails.
* @var string
* @Column(type="text")
*/
private $effectFailsMessage = "";
/**
* The message given if the effect has no effect
* The message given if the effect has no effect.
* @var string
* @Column(type="text")
*/
@@ -83,13 +83,13 @@ class Buff
*/
private $newDayMessage = "";
/**
* A value determining when the buffs activates
* A value determining when the buffs activates.
* @var int
* @Column(type="integer")
*/
private $activateAt;
/**
* True if the buff survives a new day
* True if the buff survives a new day.
* @var bool
* @Column(type="boolean")
*/
@@ -109,67 +109,67 @@ class Buff
*/
private $rounds = 1;
/**
* Number of healthpoints the badguy regenerates
* Number of healthpoints the badguy regenerates.
* @var int
* @Column(type="integer")
*/
private $badguyRegeneration = 0;
/**
* Number of healthpoints the goodguy regenerates
* Number of healthpoints the goodguy regenerates.
* @var int
* @Column(type="integer")
*/
private $goodguyRegeneration = 0;
/**
* Fraction of damage applied to the badguy that gets converted to health ("absorb") for the goodguy
* Fraction of damage applied to the badguy that gets converted to health ("absorb") for the goodguy.
* @var float
* @Column(type="float")
*/
private $badguyLifetap = 0;
/**
* Fraction of damage applied to the goodguy that gets converted to health for the badguy
* Fraction of damage applied to the goodguy that gets converted to health for the badguy.
* @var float
* @Column(type="float")
*/
private $goodguyLifetap = 0;
/**
* Fraction of damage that is reflected to the goodguy if damage is applied to the badguy
* Fraction of damage that is reflected to the goodguy if damage is applied to the badguy.
* @var float
* @Column(type="float")
*/
private $badguyDamageReflection = 0;
/**
* Fraction of damage that is reflected to the badguy if damage is applied to the goodguy
* Fraction of damage that is reflected to the badguy if damage is applied to the goodguy.
* @var float
* @Column(type="float")
*/
private $goodguyDamageReflection = 0;
/**
* Number of minions
* Number of minions.
* @var int
* @Column(type="integer")
*/
private $numberOfMinions = 0;
/**
* Minium damage done to the badguy by the minions (if $numberOfMinions > 0)
* Minium damage done to the badguy by the minions (if $numberOfMinions > 0).
* @var int
* @Column(type="integer")
*/
private $minionMinBadguyDamage = 0;
/**
* Maximum damage done to the badguy by the minions (if $numberOfMinions > 0)
* Maximum damage done to the badguy by the minions (if $numberOfMinions > 0).
* @var int
* @Column(type="integer")
*/
private $minionMaxBadguyDamage = 0;
/**
* Minium damage done to the goodguy by the minions (if $numberOfMinions > 0)
/**
* Minium damage done to the goodguy by the minions (if $numberOfMinions > 0).
* @var int
* @Column(type="integer")
*/
private $minionMinGoodguyDamage = 0;
/**
* Maximum damage done to the goodguy by the minions (if $numberOfMinions > 0)
* Maximum damage done to the goodguy by the minions (if $numberOfMinions > 0).
* @var int
* @Column(type="integer")
*/
@@ -181,56 +181,56 @@ class Buff
*/
private $badguyDamageModifier = 1;
/**
* Modifies the badguy's attack value
* Modifies the badguy's attack value.
* @var float
* @Column(type="float")
*/
private $badguyAttackModifier = 1;
/**
* Modified the badguy's defense value
* Modified the badguy's defense value.
* @var float
* @Column(type="float")
*/
private $badguyDefenseModifier = 1;
/**
* True if the badguy stays invulnurable during the buffs duration
* True if the badguy stays invulnurable during the buffs duration.
* @var bool
* @Column(type="boolean")
*/
private $badguyInvulnurable = false;
/**
* Modifies the damage applied to the goodguy
* Modifies the damage applied to the goodguy.
* @var float
* @Column(type="float")
*/
private $goodguyDamageModifier = 1;
/**
* Modifies the goodguy's attack value
* Modifies the goodguy's attack value.
* @var float
* @Column(type="float")
*/
private $goodguyAttackModifier = 1;
/**
* Modifies the goodguy's defense value
* Modifies the goodguy's defense value.
* @var float
* @Column(type="float")
*/
private $goodguyDefenseModifier = 1;
/**
* True if the goodguy stays invulnurable during the buffs duration
* True if the goodguy stays invulnurable during the buffs duration.
* @var bool
* @Column(type="boolean")
*/
private $goodguyInvulnurable = false;
/**
* True if the buff has already been started
* True if the buff has already been started.
* @var bool
* @Column(type="boolean")
*/
private $hasBeenStarted = false;
/**
* Allowed buff values and their type
* Allowed buff values and their type.
* @var array
*/
private static $buffArrayTemplate = [
@@ -278,7 +278,7 @@ class Buff
];
/**
* Creates a new buff entity using an array
* Creates a new buff entity using an array.
* @param array $buffArray
* @throws ArgumentException
*/
@@ -294,21 +294,21 @@ class Buff
switch (self::$buffArrayTemplate[$attribute]) {
case "string":
if (is_string($value) === false) {
if (\is_string($value) === false) {
throw new ArgumentException("{$attribute} needs to be a string.");
}
break;
case "int":
if (is_int($value) === false) {
if (\is_int($value) === false) {
throw new ArgumentException("{$attribute} needs to be a int.");
}
break;
case "float":
if (is_float($value) === false) {
if (\is_float($value) === false) {
// Convert to float if it is an integer.
if (is_int($value) === false) {
if (\is_int($value) === false) {
throw new ArgumentException("{$attribute} needs to be a float.");
}
@@ -317,7 +317,7 @@ class Buff
break;
case "boolean":
if (is_bool($value) === false) {
if (\is_bool($value) === false) {
throw new ArgumentException("{$attribute} needs to be boolean.");
}
break;
@@ -327,7 +327,7 @@ class Buff
}
foreach ($this->required as $required) {
if (is_null($this->$required)) {
if (\is_null($this->{$required})) {
throw new ArgumentException("{$required} needs to be inside of the buffArray!");
}
}
@@ -338,19 +338,19 @@ class Buff
* @param \LotGD\Core\Models\Buff $buff
* @return \LotGD\Core\Models\Buff
*/
public static function constructFromTemplate(Buff $buff): Buff
public static function constructFromTemplate(self $buff): self
{
$buffArray = [];
foreach (self::$buffArrayTemplate as $attribute => $type) {
$buffArray[$attribute] = $buff->$attribute;
$buffArray[$attribute] = $buff->{$attribute};
}
return new Buff($buffArray);
return new self($buffArray);
}
/**
* Returns the id of the buff
* Returns the id of the buff.
* @return int
*/
public function getId(): UuidInterface
@@ -359,7 +359,7 @@ class Buff
}
/**
* Returns the Character this buff has been applied to
* Returns the Character this buff has been applied to.
* @return \LotGD\Core\Models\Character
*/
public function getCharacter(): Character
@@ -368,7 +368,7 @@ class Buff
}
/**
* Returns the slot this buff occupies
* Returns the slot this buff occupies.
* @return string
*/
public function getSlot(): string
@@ -377,7 +377,7 @@ class Buff
}
/**
* Returns the buff's name
* Returns the buff's name.
* @return string
*/
public function getName(): string
@@ -386,7 +386,7 @@ class Buff
}
/**
* Returns the message displayed upon buff activation
* Returns the message displayed upon buff activation.
* @return string
*/
public function getStartMessage(): string
@@ -395,7 +395,7 @@ class Buff
}
/**
* Returns the message displayed every round
* Returns the message displayed every round.
* @return string
*/
public function getRoundMessage(): string
@@ -413,7 +413,7 @@ class Buff
}
/**
* Returns the message displayed when the buff's effect succeeds
* Returns the message displayed when the buff's effect succeeds.
* @return string
*/
public function getEffectSucceedsMessage(): string
@@ -422,7 +422,7 @@ class Buff
}
/**
* Returns the message displayed when the buff's effect fails
* Returns the message displayed when the buff's effect fails.
* @return string
*/
public function getEffectFailsMessage(): string
@@ -431,7 +431,7 @@ class Buff
}
/**
* Returns the message displayed when the buff has no effect at all
* Returns the message displayed when the buff has no effect at all.
* @return string
*/
public function getNoEffectMessage(): string
@@ -458,7 +458,7 @@ class Buff
}
/**
* Checks if this buff gets activated
* Checks if this buff gets activated.
* @param int $flag
* @return bool
*/
@@ -466,9 +466,8 @@ class Buff
{
if ($flag === self::ACTIVATE_NONE) {
return $this->activateAt == self::ACTIVATE_NONE ? true : false;
} else {
return ($this->activateAt & $flag) == true;
}
return ($this->activateAt & $flag) == true;
}
/**
@@ -490,7 +489,7 @@ class Buff
}
/**
* Returns the number of rounds left
* Returns the number of rounds left.
* @return int
*/
public function getRounds(): int
@@ -499,7 +498,7 @@ class Buff
}
/**
* Sets the number of rounds left
* Sets the number of rounds left.
* @param int $rounds
*/
public function setRounds(int $rounds)
@@ -508,7 +507,7 @@ class Buff
}
/**
* Decreases the number of rounds left
* Decreases the number of rounds left.
* @param int $roundsToDecrease
*/
public function decreaseRounds(int $roundsToDecrease = 1)
@@ -521,7 +520,7 @@ class Buff
}
/**
* Returns the amount of health the badguy gets healed
* Returns the amount of health the badguy gets healed.
* @return int
*/
public function getBadguyRegeneration(): int
@@ -530,7 +529,7 @@ class Buff
}
/**
* Returns the number of health the goodguy gets healed
* Returns the number of health the goodguy gets healed.
* @return int
*/
public function getGoodguyRegeneration(): int
@@ -539,7 +538,7 @@ class Buff
}
/**
* Returns the fraction of life that gets absorbed from the damage applied to the badguy
* Returns the fraction of life that gets absorbed from the damage applied to the badguy.
* @return float
*/
public function getBadguyLifetap(): float
@@ -548,7 +547,7 @@ class Buff
}
/**
* Returns the fraction of life that gets absorbed from the damage applied to the goodguy
* Returns the fraction of life that gets absorbed from the damage applied to the goodguy.
* @return float
*/
public function getGoodguyLifetap(): float
@@ -557,7 +556,7 @@ class Buff
}
/**
* Returns the fraction of the damage applied to the badguy that gets reflected to the goodguy
* Returns the fraction of the damage applied to the badguy that gets reflected to the goodguy.
* @return float
*/
public function getBadguyDamageReflection(): float
@@ -566,7 +565,7 @@ class Buff
}
/**
* Returns the fraction of the damage applied to the goodguy that gets reflected to the badguy
* Returns the fraction of the damage applied to the goodguy that gets reflected to the badguy.
* @return float
*/
public function getGoodguyDamageReflection(): float
@@ -575,7 +574,7 @@ class Buff
}
/**
* Returns the number of minions
* Returns the number of minions.
* @return int
*/
public function getNumberOfMinions(): int
@@ -584,7 +583,7 @@ class Buff
}
/**
* Returns the minium damage a minion afflicts to the badguy
* Returns the minium damage a minion afflicts to the badguy.
* @return int
*/
public function getMinionMinBadguyDamage(): int
@@ -593,7 +592,7 @@ class Buff
}
/**
* Returns the maximum damage a minion afflicts to the goodguy
* Returns the maximum damage a minion afflicts to the goodguy.
* @return int
*/
public function getMinionMaxGoodguyDamage(): int
@@ -602,7 +601,7 @@ class Buff
}
/**
* Returns the minium damage a minion afflicts to the goodguy
* Returns the minium damage a minion afflicts to the goodguy.
* @return int
*/
public function getMinionMinGoodguyDamage(): int
@@ -611,7 +610,7 @@ class Buff
}
/**
* Returns the maximum damage a minion afflicts to the badguy
* Returns the maximum damage a minion afflicts to the badguy.
* @return int
*/
public function getMinionMaxBadguyDamage(): int
@@ -620,7 +619,7 @@ class Buff
}
/**
* Returns a factor which modifies the damage applied TO the badguy
* Returns a factor which modifies the damage applied TO the badguy.
* @return float
*/
public function getBadguyDamageModifier(): float
@@ -629,7 +628,7 @@ class Buff
}
/**
* Returns a factor which modifies the badguy's attack value
* Returns a factor which modifies the badguy's attack value.
* @return float
*/
public function getBadguyAttackModifier(): float
@@ -638,7 +637,7 @@ class Buff
}
/**
* Returns a factor which modified the badguy's defense value
* Returns a factor which modified the badguy's defense value.
* @return float
*/
public function getBadguyDefenseModifier(): float
@@ -647,7 +646,7 @@ class Buff
}
/**
* Returns true if the badguy is invulnurable
* Returns true if the badguy is invulnurable.
* @return bool
*/
public function badguyIsInvulnurable(): bool
@@ -656,7 +655,7 @@ class Buff
}
/**
* Returns a factor which modifies the damage applied TO the goodguy
* Returns a factor which modifies the damage applied TO the goodguy.
* @return float
*/
public function getGoodguyDamageModifier(): float
@@ -665,7 +664,7 @@ class Buff
}
/**
* Returns a factor which modifies the goodguy's attack value
* Returns a factor which modifies the goodguy's attack value.
* @return float
*/
public function getGoodguyAttackModifier(): float
@@ -674,7 +673,7 @@ class Buff
}
/**
* Returns a factor which modified the goodguy's defense value
* Returns a factor which modified the goodguy's defense value.
* @return float
*/
public function getGoodguyDefenseModifier(): float
@@ -683,7 +682,7 @@ class Buff
}
/**
* Returns true if the goodguy is invulnurable
* Returns true if the goodguy is invulnurable.
* @return bool
*/
public function goodguyIsInvulnurable(): bool
@@ -692,7 +691,7 @@ class Buff
}
/**
* Returns true if the buff has already been started
* Returns true if the buff has already been started.
* @return bool
*/
public function hasBeenStarted(): bool
+39 -39
View File
@@ -3,10 +3,8 @@ declare(strict_types=1);
namespace LotGD\Core\Models;
use Doctrine\Common\Collections\{
ArrayCollection,
Collection
};
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping\Column;
use Doctrine\ORM\Mapping\Entity;
use Doctrine\ORM\Mapping\Id;
@@ -17,18 +15,20 @@ use Doctrine\ORM\Mapping\OneToMany;
use Doctrine\ORM\Mapping\OneToOne;
use Doctrine\ORM\Mapping\Table;
use LotGD\Core\{
BuffList, Events\CharacterEventData, Game, GameAwareInterface
};
use LotGD\Core\BuffList;
use LotGD\Core\Events\CharacterEventData;
use LotGD\Core\Exceptions\BuffSlotOccupiedException;
use LotGD\Core\Tools\Model\{
Creator, ExtendableModel, GameAware, PropertyManager, SoftDeletable
};
use LotGD\Core\GameAwareInterface;
use LotGD\Core\Tools\Model\Creator;
use LotGD\Core\Tools\Model\ExtendableModel;
use LotGD\Core\Tools\Model\GameAware;
use LotGD\Core\Tools\Model\PropertyManager;
use LotGD\Core\Tools\Model\SoftDeletable;
use Ramsey\Uuid\Uuid;
use Ramsey\Uuid\UuidInterface;
/**
* Model for a character
* Model for a character.
*
* @Entity(repositoryClass="LotGD\Core\Models\Repositories\CharacterRepository")
* @Table(name="characters")
@@ -47,11 +47,11 @@ class Character implements CharacterInterface, CreateableInterface, GameAwareInt
private $name = "";
/** @Column(type="text"); */
private $displayName = "";
/** @Column(type="integer", options={"default":10}) */
/** @Column(type="integer", options={"default"= 10}) */
private $maxHealth = 10;
/** @Column(type="integer", options={"default":10}) */
/** @Column(type="integer", options={"default"= 10}) */
private $health = 10;
/** @Column(type="integer", options={"default":1})/ */
/** @Column(type="integer", options={"default"= 1})/ */
private $level = 1;
/** @OneToMany(targetEntity="CharacterProperty", mappedBy="owner", cascade={"persist", "remove"}) */
private $properties;
@@ -60,13 +60,13 @@ class Character implements CharacterInterface, CreateableInterface, GameAwareInt
/**
* @ManyToMany(targetEntity="MessageThread", inversedBy="participants", cascade={"persist"})
* @JoinTable(
* name="message_threads_x_characters",
* joinColumns={
* @JoinColumn(name="character_id", referencedColumnName="id")
* },
* inverseJoinColumns={
* @JoinColumn(name="messagethread_id", referencedColumnName="id")
* }
* name="message_threads_x_characters",
* joinColumns={
* @JoinColumn(name="character_id", referencedColumnName="id")
* },
* inverseJoinColumns={
* @JoinColumn(name="messagethread_id", referencedColumnName="id")
* }
* )
*/
private $messageThreads;
@@ -85,7 +85,7 @@ class Character implements CharacterInterface, CreateableInterface, GameAwareInt
private $propertyClass = CharacterProperty::class;
/**
* Creates a character at full health
* Creates a character at full health.
*/
public static function createAtFullHealth(array $arguments): self
{
@@ -107,7 +107,7 @@ class Character implements CharacterInterface, CreateableInterface, GameAwareInt
}
/**
* Returns the entity's id
* Returns the entity's id.
* @return int The id
*/
public function getId(): UuidInterface
@@ -116,7 +116,7 @@ class Character implements CharacterInterface, CreateableInterface, GameAwareInt
}
/**
* Sets the character's name and generates the display name
* Sets the character's name and generates the display name.
* @param string $name The name to set
*/
public function setName(string $name)
@@ -126,7 +126,7 @@ class Character implements CharacterInterface, CreateableInterface, GameAwareInt
}
/**
* Returns the character's name
* Returns the character's name.
* @return string The name
*/
public function getName(): string
@@ -143,7 +143,7 @@ class Character implements CharacterInterface, CreateableInterface, GameAwareInt
}
/**
* Returns displayName, a combination of title, name and suffix, mixed with colour codes
* Returns displayName, a combination of title, name and suffix, mixed with colour codes.
* @return string The displayName
*/
public function getDisplayName(): string
@@ -162,7 +162,7 @@ class Character implements CharacterInterface, CreateableInterface, GameAwareInt
}
/**
* Returns the maximum health
* Returns the maximum health.
* @return int
*/
public function getMaxHealth(): int
@@ -171,7 +171,7 @@ class Character implements CharacterInterface, CreateableInterface, GameAwareInt
}
/**
* Sets current health
* Sets current health.
* @param int $health
*/
public function setHealth(int $health)
@@ -180,7 +180,7 @@ class Character implements CharacterInterface, CreateableInterface, GameAwareInt
}
/**
* Returns current health
* Returns current health.
* @return int
*/
public function getHealth(): int
@@ -202,7 +202,7 @@ class Character implements CharacterInterface, CreateableInterface, GameAwareInt
}
/**
* Heals the enemy
* Heals the enemy.
* @param int $heal
* @param bool $overheal True if healing bigger than maxHealth is desired.
*/
@@ -225,7 +225,7 @@ class Character implements CharacterInterface, CreateableInterface, GameAwareInt
}
/**
* Returns the character's level
* Returns the character's level.
* @return int
*/
public function getLevel(): int
@@ -234,7 +234,7 @@ class Character implements CharacterInterface, CreateableInterface, GameAwareInt
}
/**
* Returns the character's virtual attribute "attack"
* Returns the character's virtual attribute "attack".
* @param bool $ignoreBuffs
* @return int
*/
@@ -246,7 +246,7 @@ class Character implements CharacterInterface, CreateableInterface, GameAwareInt
"h/lotgd/core/getCharacterAttack",
CharacterEventData::create([
"character" => $this,
"value" => $baseAttack
"value" => $baseAttack,
])
);
@@ -256,7 +256,7 @@ class Character implements CharacterInterface, CreateableInterface, GameAwareInt
}
/**
* Returns the character's virtual attribute "defense"
* Returns the character's virtual attribute "defense".
* @param bool $ignoreBuffs
* @return int
*/
@@ -268,7 +268,7 @@ class Character implements CharacterInterface, CreateableInterface, GameAwareInt
"h/lotgd/core/getCharacterDefense",
CharacterEventData::create([
"character" => $this,
"value" => $baseDefense
"value" => $baseDefense,
])
);
@@ -278,7 +278,7 @@ class Character implements CharacterInterface, CreateableInterface, GameAwareInt
}
/**
* Sets the character's level
* Sets the character's level.
* @param int $level
*/
public function setLevel(int $level)
@@ -290,7 +290,7 @@ class Character implements CharacterInterface, CreateableInterface, GameAwareInt
* Returns the current character viewpoint or null if one is not set.
* @return \LotGD\Core\Models\Viewpoint|null
*/
public function getViewpoint()
public function getViewpoint(): ?Viewpoint
{
return $this->viewpoint;
}
@@ -304,7 +304,7 @@ class Character implements CharacterInterface, CreateableInterface, GameAwareInt
}
/**
* Returns a list of buffs
* Returns a list of buffs.
*/
public function getBuffs(): BuffList
{
@@ -313,7 +313,7 @@ class Character implements CharacterInterface, CreateableInterface, GameAwareInt
}
/**
* Adds a buff to the buffList
* Adds a buff to the buffList.
*/
public function addBuff(Buff $buff, bool $override = false)
{
+3 -3
View File
@@ -9,7 +9,7 @@ use Doctrine\ORM\Mapping\Table;
use LotGD\Core\Tools\Model\Properties;
/**
* Properties for Characters
* Properties for Characters.
* @Entity
* @Table(name="character_properties")
*/
@@ -21,7 +21,7 @@ class CharacterProperty
private $owner;
/**
* Returns the owner
* Returns the owner.
* @return \LotGD\Core\Models\Character
*/
public function getOwner(): Character
@@ -30,7 +30,7 @@ class CharacterProperty
}
/**
* Sets the owner
* Sets the owner.
* @param \LotGD\Core\Models\Character $owner
*/
public function setOwner(Character $owner)
+5 -8
View File
@@ -1,17 +1,14 @@
<?php
declare(strict_types=1);
namespace LotGD\Core\Models;
use LotGD\Core\Exceptions\CharacterStatExistsException;
use LotGD\Core\Exceptions\CharacterStatNotFoundException;
use LotGD\Core\Models\CharacterStats\CharacterStatInterface;
/**
* Class CharacterStatGroup
* @package LotGD\Core\Models
* Class CharacterStatGroup.
*/
class CharacterStatGroup
{
@@ -73,8 +70,8 @@ class CharacterStatGroup
/**
* @param string $id
* @return CharacterStatInterface
* @throws CharacterStatNotFoundException
* @return CharacterStatInterface
*/
public function getCharacterStat(string $id): CharacterStatInterface
{
@@ -99,13 +96,13 @@ class CharacterStatGroup
}
/**
* @return \Generator|CharacterStatInterface[]
* @return CharacterStatInterface[]|\Generator
*/
public function iterate(): \Generator
{
// First, sort stat set by weight if not sorted
if (!$this->sorted) {
uasort($this->stats, function (CharacterStatInterface $a, CharacterStatInterface $b) {
\uasort($this->stats, function (CharacterStatInterface $a, CharacterStatInterface $b) {
return $a->getWeight() <=> $b->getWeight();
});
$this->sorted = true;
@@ -116,4 +113,4 @@ class CharacterStatGroup
yield $stat;
}
}
}
}
+5 -8
View File
@@ -1,18 +1,15 @@
<?php
declare(strict_types=1);
namespace LotGD\Core\Models;
use LotGD\Core\Events\EventContextData;
use LotGD\Core\Exceptions\CharacterStatGroupExistsException;
use LotGD\Core\Exceptions\CharacterStatGroupNotFoundException;
use LotGD\Core\Game;
/**
* Class CharacterStats
* @package LotGD\Core\Models
* Class CharacterStats.
*/
class CharacterStats
{
@@ -39,13 +36,13 @@ class CharacterStats
}
/**
* @return \Generator|CharacterStatGroup[]
* @return CharacterStatGroup[]|\Generator
*/
public function iterate(): \Generator
{
// First, sort stat set by weight if not sorted yet
if (!$this->sorted) {
uasort($this->stat_groups, function (CharacterStatGroup $a, CharacterStatGroup $b) {
\uasort($this->stat_groups, function (CharacterStatGroup $a, CharacterStatGroup $b) {
return $a->getWeight() <=> $b->getWeight();
});
$this->sorted = true;
@@ -73,8 +70,8 @@ class CharacterStats
/**
* @param string $id
* @return CharacterStatGroup
* @throws CharacterStatGroupNotFoundException
* @return CharacterStatGroup
*/
public function getCharacterStatGroup(string $id): CharacterStatGroup
{
@@ -97,4 +94,4 @@ class CharacterStats
return false;
}
}
}
@@ -1,13 +1,10 @@
<?php
declare(strict_types=1);
namespace LotGD\Core\Models\CharacterStats;
/**
* Class BaseCharacterStat
* @package LotGD\Core\Models\CharacterStats
* Class BaseCharacterStat.
*/
class BaseCharacterStat implements CharacterStatInterface
{
@@ -63,7 +60,7 @@ class BaseCharacterStat implements CharacterStatInterface
/** @inheritdoc */
public function getValueAsString(): string
{
return sprintf("%s", $this->getValue());
return \sprintf("%s", $this->getValue());
}
/** @inheritdoc */
@@ -77,4 +74,4 @@ class BaseCharacterStat implements CharacterStatInterface
{
return $this->weight;
}
}
}
@@ -1,10 +1,8 @@
<?php
declare(strict_types=1);
namespace LotGD\Core\Models\CharacterStats;
interface CharacterStatInterface
{
/**
@@ -57,4 +55,4 @@ interface CharacterStatInterface
* @return mixed
*/
public function setWeight(int $weight);
}
}
+3 -5
View File
@@ -1,15 +1,13 @@
<?php
declare(strict_types = 1);
declare(strict_types=1);
namespace LotGD\Core\Models;
use Doctrine\ORM\EntityManagerInterface;
/**
* Interface for createable models
* Interface for createable models.
*/
interface CreateableInterface extends SaveableInterface
{
public static function create(array $arguments): CreateableInterface;
public static function create(array $arguments): self;
}
-1
View File
@@ -3,7 +3,6 @@ declare(strict_types=1);
namespace LotGD\Core\Models;
use Doctrine\ORM\EntityManagerInterface;
use Doctrine\ORM\Mapping\Entity;
use Doctrine\ORM\Mapping\Table;
+1 -2
View File
@@ -3,8 +3,7 @@ declare(strict_types=1);
namespace LotGD\Core\Models;
interface ExtendableModelInterface
{
public function __call($method, $arguments);
}
}
+1 -4
View File
@@ -3,10 +3,7 @@ declare(strict_types=1);
namespace LotGD\Core\Models;
use LotGD\Core\{
BuffList,
Game
};
use LotGD\Core\BuffList;
/**
* Interface for models that should be able to participate in fights.
+3 -6
View File
@@ -5,12 +5,11 @@ namespace LotGD\Core\Models;
use Doctrine\ORM\EntityManagerInterface;
use LotGD\Core\Models\GameConfigurationElement;
use LotGD\Core\Tools\OneToManyCollection;
use LotGD\Core\Tools\Model\PropertyManager;
use LotGD\Core\Tools\OneToManyCollection;
/**
* Provides an interface to access properties
* Provides an interface to access properties.
*/
class GameConfiguration
{
@@ -19,8 +18,6 @@ class GameConfiguration
/** @var ArrayCollection */
private $properties;
/**
* Constructor.
* @param EntityManagerInterface $entityManager
@@ -42,7 +39,7 @@ class GameConfiguration
}
/**
* Sets and overwrites a configuration value saved by the name
* Sets and overwrites a configuration value saved by the name.
* @param string $configurationName
* @param mixed $configurationValue
*/
+2 -2
View File
@@ -3,12 +3,12 @@ declare(strict_types=1);
namespace LotGD\Core\Models;
use LotGD\Core\Tools\Model\Properties;
use Doctrine\ORM\Mapping\Entity;
use Doctrine\ORM\Mapping\Table;
use LotGD\Core\Tools\Model\Properties;
/**
* Properties for Characters
* Properties for Characters.
* @Entity
* @Table(name="game_configuration")
*/
+12 -19
View File
@@ -5,18 +5,14 @@ namespace LotGD\Core\Models;
use DateTime;
use Doctrine\ORM\EntityManagerInterface;
use Doctrine\ORM\Mapping\Entity;
use Doctrine\ORM\Mapping\Table;
use LotGD\Core\Exceptions\InvalidModelException;
use LotGD\Core\Exceptions\ArgumentException;
use LotGD\Core\Exceptions\ParentAlreadySetException;
use LotGD\Core\Tools\Model\Deletor;
use LotGD\Core\Tools\Model\Saveable;
/**
* Model for messages
* Model for messages.
* @Entity
* @Table(name="messages")
*/
@@ -38,7 +34,6 @@ class Message
/** @Column(type="boolean", nullable=false) */
private $systemMessage = false;
/**
* Constructs the message.
* Use the Message Manager methods send() and sendSystemMessage() instead.
@@ -58,7 +53,7 @@ class Message
} elseif ($systemMessage === false) {
// This should not happen since the constructor is not a public method
throw new ArgumentException(
sprintf(
\sprintf(
'If $from is not an instance of %s, $systemMessage must be true',
Character::class
)
@@ -72,7 +67,7 @@ class Message
}
/**
* Returns the id
* Returns the id.
* @return int
*/
public function getId(): int
@@ -81,16 +76,15 @@ class Message
}
/**
* Returns the true character of the message
* Returns the true character of the message.
* @return \LotGD\Core\Models\CharacterInterface
*/
public function getAuthor(): CharacterInterface
{
if (is_null($this->author)) {
if (\is_null($this->author)) {
return SystemCharacter::getInstance();
} else {
return $this->author;
}
return $this->author;
}
/**
@@ -104,13 +98,12 @@ class Message
{
if ($this->isSystemMessage()) {
return SystemCharacter::getInstance();
} else {
return $this->getAuthor();
}
return $this->getAuthor();
}
/**
* Returns the message
* Returns the message.
* @return string
*/
public function getMessage(): string
@@ -119,7 +112,7 @@ class Message
}
/**
* Returns the thread this message belongs to
* Returns the thread this message belongs to.
* @return \LotGD\Core\Models\MessageThread
*/
public function getThread(): MessageThread
@@ -137,7 +130,7 @@ class Message
*/
public function setThread(MessageThread $thread)
{
if (is_null($this->thread) === false) {
if (\is_null($this->thread) === false) {
throw new ParentAlreadySetException("A message's thread cannot be changed.");
}
@@ -145,7 +138,7 @@ class Message
}
/**
* Returns the datetime this message was created at
* Returns the datetime this message was created at.
* @return DateTime
*/
public function getCreatedAt(): DateTime
@@ -154,7 +147,7 @@ class Message
}
/**
* Returns true if the message is a system message
* Returns true if the message is a system message.
* @return bool
*/
public function isSystemMessage(): bool
+7 -8
View File
@@ -13,7 +13,7 @@ use LotGD\Core\Exceptions\CoreException;
use LotGD\Core\Tools\Model\Saveable;
/**
* A Thread of messages
* A Thread of messages.
*
* @Entity(repositoryClass="LotGD\Core\Models\Repositories\MessageThreadRepository")
* @Table(name="message_threads")
@@ -26,7 +26,7 @@ class MessageThread implements SaveableInterface
private $id;
/** @Column(type="string", length=255, unique=true) */
private $threadKey;
/** @Column(type="boolean", options={"default"=false}) */
/** @Column(type="boolean", options={"default"= false}) */
private $readonly = false;
/** @ManyToMany(targetEntity="Character", cascade={"persist"}, mappedBy="messageThreads") */
private $participants;
@@ -53,7 +53,7 @@ class MessageThread implements SaveableInterface
}
/**
* Returns the primary id of this message
* Returns the primary id of this message.
* @return int
*/
public function getId(): int
@@ -62,7 +62,7 @@ class MessageThread implements SaveableInterface
}
/**
* Returns a list of messages inside this thread
* Returns a list of messages inside this thread.
* @return Collection
*/
public function getMessages(): Collection
@@ -79,13 +79,12 @@ class MessageThread implements SaveableInterface
{
if ($this->isReadonly() && $message->getApparantAuthor() instanceof SystemCharacter === false) {
throw new CoreException("Cannot write a normal message to a readonly thread");
} else {
$this->messages->add($message);
}
$this->messages->add($message);
}
/**
* Get a collection of participants in this thread
* Get a collection of participants in this thread.
* @return Collection
*/
public function getParticipants(): Collection
@@ -94,7 +93,7 @@ class MessageThread implements SaveableInterface
}
/**
* Returns true if the thread is "readonly"
* Returns true if the thread is "readonly".
* @return bool
*/
public function isReadonly(): bool
+4 -4
View File
@@ -1,5 +1,5 @@
<?php
declare(strict_types = 1);
declare(strict_types=1);
namespace LotGD\Core\Models;
@@ -16,7 +16,7 @@ class MissingCharacter implements CharacterInterface
private $displayname;
/**
* Sets the name of the missing character, defautls to "Nobody"
* Sets the name of the missing character, defautls to "Nobody".
* @param string $displayname
*/
public function __construct(string $displayname = "Nobody")
@@ -25,7 +25,7 @@ class MissingCharacter implements CharacterInterface
}
/**
* Returns the name
* Returns the name.
* @return string
*/
public function getDisplayName(): string
@@ -34,7 +34,7 @@ class MissingCharacter implements CharacterInterface
}
/**
* Returns the name
* Returns the name.
* @return string
*/
public function getName(): string

Some files were not shown because too many files have changed in this diff Show More