Removes master

This commit is contained in:
Vassyli
2018-01-05 10:30:21 +01:00
parent 5ac7098f35
commit 81d773720a
2 changed files with 118 additions and 138 deletions
-20
View File
@@ -1,20 +0,0 @@
<?php
declare(strict_types=1);
namespace LotGD\Core\Models;
use Doctrine\ORM\Mapping\Entity;
use Doctrine\ORM\Mapping\Table;
use LotGD\Core\Tools\Model\AutoScaleFighter;
/**
* The Monster entity
*
* @Entity
* @Table(name="masters")
*/
class Master extends BasicEnemy
{
use AutoScaleFighter;
}
+118 -118
View File
@@ -11,80 +11,80 @@ use LotGD\Core\TimeKeeper;
* @backupStaticAttributes disabled
*/
class TimeKeeperTests extends \PHPUnit_Framework_TestCase {
private $gameEpoch;
private $gameOffsetSeconds;
private $gameDaysPerDay;
private $gameEpoch;
private $gameOffsetSeconds;
private $gameDaysPerDay;
public function setUp() {
$this->gameEpoch = new \DateTime('2015-07-27 00:00:00 PDT');;
$this->gameOffsetSeconds = 0;
$this->gameDaysPerDay = 2;
}
public function setUp() {
$this->gameEpoch = new \DateTime('2015-07-27 00:00:00 PDT');;
$this->gameOffsetSeconds = 0;
$this->gameDaysPerDay = 2;
}
public function testConvertToBasicConversion() {
$this->gameDaysPerDay = 1;
$keeper = new TimeKeeper($this->gameEpoch, new DateTime(), $this->gameOffsetSeconds, $this->gameDaysPerDay);
public function testConvertToBasicConversion() {
$this->gameDaysPerDay = 1;
$keeper = new TimeKeeper($this->gameEpoch, new DateTime(), $this->gameOffsetSeconds, $this->gameDaysPerDay);
$date = new \DateTime('2015-07-27 23:59:59 PDT');
$converted = $keeper->convertToGameTime($date);
$this->assertEquals('0000-01-01 23:59:59', $converted->format('Y-m-d H:i:s'));
$date = new \DateTime('2015-07-27 23:59:59 PDT');
$converted = $keeper->convertToGameTime($date);
$this->assertEquals('0000-01-01 23:59:59', $converted->format('Y-m-d H:i:s'));
$date = new \DateTime('2015-07-27 12:00:00 PDT');
$converted = $keeper->convertToGameTime($date);
$this->assertEquals('0000-01-01 12:00:00', $converted->format('Y-m-d H:i:s'));
}
$date = new \DateTime('2015-07-27 12:00:00 PDT');
$converted = $keeper->convertToGameTime($date);
$this->assertEquals('0000-01-01 12:00:00', $converted->format('Y-m-d H:i:s'));
}
public function testConvertToRespectsGameDaysPerDayUpperBound() {
$date = new \DateTime('2015-07-27 05:59:59 PDT');
public function testConvertToRespectsGameDaysPerDayUpperBound() {
$date = new \DateTime('2015-07-27 05:59:59 PDT');
$this->gameDaysPerDay = 4;
$keeper = new TimeKeeper($this->gameEpoch, new DateTime(), $this->gameOffsetSeconds, $this->gameDaysPerDay);
$this->gameDaysPerDay = 4;
$keeper = new TimeKeeper($this->gameEpoch, new DateTime(), $this->gameOffsetSeconds, $this->gameDaysPerDay);
$converted = $keeper->convertToGameTime($date);
$this->assertEquals('0000-01-01', $converted->format('Y-m-d'));
}
$converted = $keeper->convertToGameTime($date);
$this->assertEquals('0000-01-01', $converted->format('Y-m-d'));
}
public function testConvertToRespectsGameDaysPerDayNextDay() {
$date = new \DateTime('2015-07-27 06:00:00 PDT');
public function testConvertToRespectsGameDaysPerDayNextDay() {
$date = new \DateTime('2015-07-27 06:00:00 PDT');
$this->gameDaysPerDay = 4;
$keeper = new TimeKeeper($this->gameEpoch, new DateTime(), $this->gameOffsetSeconds, $this->gameDaysPerDay);
$this->gameDaysPerDay = 4;
$keeper = new TimeKeeper($this->gameEpoch, new DateTime(), $this->gameOffsetSeconds, $this->gameDaysPerDay);
$converted = $keeper->convertToGameTime($date);
$this->assertEquals('0000-01-02', $converted->format('Y-m-d'));
}
$converted = $keeper->convertToGameTime($date);
$this->assertEquals('0000-01-02', $converted->format('Y-m-d'));
}
public function testConvertToRespectsGameDaysPerDayNextDayUpperBound() {
$date = new \DateTime('2015-07-27 11:59:59 PDT');
public function testConvertToRespectsGameDaysPerDayNextDayUpperBound() {
$date = new \DateTime('2015-07-27 11:59:59 PDT');
$this->gameDaysPerDay = 4;
$keeper = new TimeKeeper($this->gameEpoch, new DateTime(), $this->gameOffsetSeconds, $this->gameDaysPerDay);
$this->gameDaysPerDay = 4;
$keeper = new TimeKeeper($this->gameEpoch, new DateTime(), $this->gameOffsetSeconds, $this->gameDaysPerDay);
$converted = $keeper->convertToGameTime($date);
$this->assertEquals('0000-01-02', $converted->format('Y-m-d'));
}
$converted = $keeper->convertToGameTime($date);
$this->assertEquals('0000-01-02', $converted->format('Y-m-d'));
}
public function testIfIsNewDayReturnsTrueWithNullAsLastInteractionTime() {
$keeper = new TimeKeeper($this->gameEpoch, new DateTime(), $this->gameOffsetSeconds, 4);
public function testIfIsNewDayReturnsTrueWithNullAsLastInteractionTime() {
$keeper = new TimeKeeper($this->gameEpoch, new DateTime(), $this->gameOffsetSeconds, 4);
$this->assertTrue($keeper->isNewDay(null));
}
$this->assertTrue($keeper->isNewDay(null));
}
public function testIfIsNewDayReturnsFalseIfLastInteractionTimeWasJustRecently()
{
// game days per day: 4, each day 6h.
$keeper = new TimeKeeper($this->gameEpoch, new DateTime("2017-01-02 11:59:59"), 3600*5, 4);
public function testIfIsNewDayReturnsFalseIfLastInteractionTimeWasJustRecently()
{
// game days per day: 4, each day 6h.
$keeper = new TimeKeeper($this->gameEpoch, new DateTime("2017-01-02 11:59:59"), 3600*5, 4);
$time1 = new \DateTime("2017-01-02 06:00:00");
$time2 = new \DateTime("2017-01-02 11:59:59");
$time3 = new \DateTime("2017-01-02 09:00:00");
$time4 = new \DateTime("2017-01-02 09:59:30");
$time1 = new \DateTime("2017-01-02 06:00:00");
$time2 = new \DateTime("2017-01-02 11:59:59");
$time3 = new \DateTime("2017-01-02 09:00:00");
$time4 = new \DateTime("2017-01-02 09:59:30");
$this->assertFalse($keeper->isNewDay($time1));
$this->assertFalse($keeper->isNewDay($time2));
$this->assertFalse($keeper->isNewDay($time3));
$this->assertFalse($keeper->isNewDay($time4));
}
$this->assertFalse($keeper->isNewDay($time1));
$this->assertFalse($keeper->isNewDay($time2));
$this->assertFalse($keeper->isNewDay($time3));
$this->assertFalse($keeper->isNewDay($time4));
}
public function testIfIsNewDayReturnsFalseIfLastInteractionTimeWasOnLastGameDay()
{
@@ -103,87 +103,87 @@ class TimeKeeperTests extends \PHPUnit_Framework_TestCase {
$this->assertTrue($keeper->isNewDay($time4));
}
public function testConvertToRespectsGameOffset() {
$date = new \DateTime('2015-07-27 01:01:15 PDT');
public function testConvertToRespectsGameOffset() {
$date = new \DateTime('2015-07-27 01:01:15 PDT');
$this->gameOffsetSeconds = 60*60;
$this->gameDaysPerDay = 1;
$keeper = new TimeKeeper($this->gameEpoch, new DateTime(), $this->gameOffsetSeconds, $this->gameDaysPerDay);
$this->gameOffsetSeconds = 60*60;
$this->gameDaysPerDay = 1;
$keeper = new TimeKeeper($this->gameEpoch, new DateTime(), $this->gameOffsetSeconds, $this->gameDaysPerDay);
$converted = $keeper->convertToGameTime($date);
$this->assertEquals('0000-01-01 00:01:15', $converted->format('Y-m-d H:i:s'));
}
$converted = $keeper->convertToGameTime($date);
$this->assertEquals('0000-01-01 00:01:15', $converted->format('Y-m-d H:i:s'));
}
public function testConvertToRespectsGameOffsetUpperBound() {
$date = new \DateTime('2015-07-28 00:59:59 PDT');
public function testConvertToRespectsGameOffsetUpperBound() {
$date = new \DateTime('2015-07-28 00:59:59 PDT');
$this->gameOffsetSeconds = 60*60;
$this->gameDaysPerDay = 1;
$keeper = new TimeKeeper($this->gameEpoch, new DateTime(), $this->gameOffsetSeconds, $this->gameDaysPerDay);
$this->gameOffsetSeconds = 60*60;
$this->gameDaysPerDay = 1;
$keeper = new TimeKeeper($this->gameEpoch, new DateTime(), $this->gameOffsetSeconds, $this->gameDaysPerDay);
$converted = $keeper->convertToGameTime($date);
$this->assertEquals('0000-01-01 23:59:59', $converted->format('Y-m-d H:i:s'));
}
$converted = $keeper->convertToGameTime($date);
$this->assertEquals('0000-01-01 23:59:59', $converted->format('Y-m-d H:i:s'));
}
public function testConvertToRespectsGameOffsetNextDay() {
$date = new \DateTime('2015-07-28 01:00:00 PDT');
public function testConvertToRespectsGameOffsetNextDay() {
$date = new \DateTime('2015-07-28 01:00:00 PDT');
$this->gameOffsetSeconds = 60*60;
$this->gameDaysPerDay = 1;
$keeper = new TimeKeeper($this->gameEpoch, new DateTime(), $this->gameOffsetSeconds, $this->gameDaysPerDay);
$this->gameOffsetSeconds = 60*60;
$this->gameDaysPerDay = 1;
$keeper = new TimeKeeper($this->gameEpoch, new DateTime(), $this->gameOffsetSeconds, $this->gameDaysPerDay);
$converted = $keeper->convertToGameTime($date);
$this->assertEquals('0000-01-02', $converted->format('Y-m-d'));
}
$converted = $keeper->convertToGameTime($date);
$this->assertEquals('0000-01-02', $converted->format('Y-m-d'));
}
public function testConvertToRespectsGameOffsetNextDayUpperBound() {
$date = new \DateTime('2015-07-29 00:59:59 PDT');
public function testConvertToRespectsGameOffsetNextDayUpperBound() {
$date = new \DateTime('2015-07-29 00:59:59 PDT');
$this->gameOffsetSeconds = 60*60;
$this->gameDaysPerDay = 1;
$keeper = new TimeKeeper($this->gameEpoch, new DateTime(), $this->gameOffsetSeconds, $this->gameDaysPerDay);
$this->gameOffsetSeconds = 60*60;
$this->gameDaysPerDay = 1;
$keeper = new TimeKeeper($this->gameEpoch, new DateTime(), $this->gameOffsetSeconds, $this->gameDaysPerDay);
$converted = $keeper->convertToGameTime($date);
$this->assertEquals('0000-01-02', $converted->format('Y-m-d'));
}
$converted = $keeper->convertToGameTime($date);
$this->assertEquals('0000-01-02', $converted->format('Y-m-d'));
}
public function testConvertFromBasicConversion() {
$date = new \DateTime('0000-01-02 00:00:00 UTC');
public function testConvertFromBasicConversion() {
$date = new \DateTime('0000-01-02 00:00:00 UTC');
$this->gameDaysPerDay = 1;
$keeper = new TimeKeeper($this->gameEpoch, new DateTime(), $this->gameOffsetSeconds, $this->gameDaysPerDay);
$this->gameDaysPerDay = 1;
$keeper = new TimeKeeper($this->gameEpoch, new DateTime(), $this->gameOffsetSeconds, $this->gameDaysPerDay);
$converted = $keeper->convertFromGameTime($date);
$this->assertEquals("2015-07-28", $converted->format('Y-m-d'));
}
$converted = $keeper->convertFromGameTime($date);
$this->assertEquals("2015-07-28", $converted->format('Y-m-d'));
}
public function testConvertFromRespectsGameOffsetNextDay() {
$epoch = new \DateTime('2015-07-27 00:00:00 PDT');
$date = new \DateTime('0000-01-02 23:59:59 UTC');
public function testConvertFromRespectsGameOffsetNextDay() {
$epoch = new \DateTime('2015-07-27 00:00:00 PDT');
$date = new \DateTime('0000-01-02 23:59:59 UTC');
$this->gameEpoch = $epoch;
$this->gameOffsetSeconds = 60*60;
$this->gameDaysPerDay = 1;
$keeper = new TimeKeeper($this->gameEpoch, new DateTime(), $this->gameOffsetSeconds, $this->gameDaysPerDay);
$this->gameEpoch = $epoch;
$this->gameOffsetSeconds = 60*60;
$this->gameDaysPerDay = 1;
$keeper = new TimeKeeper($this->gameEpoch, new DateTime(), $this->gameOffsetSeconds, $this->gameDaysPerDay);
$converted = $keeper->convertFromGameTime($date);
$this->assertEquals("2015-07-29 00:59:59", $converted->format('Y-m-d H:i:s'));
}
$converted = $keeper->convertFromGameTime($date);
$this->assertEquals("2015-07-29 00:59:59", $converted->format('Y-m-d H:i:s'));
}
public function testConvertFromRespectsGameDaysPerDayNextDay() {
$epoch = new \DateTime('2015-07-27 00:00:00 PDT');
$date = new \DateTime('0000-01-02 23:59:59 UTC');
public function testConvertFromRespectsGameDaysPerDayNextDay() {
$epoch = new \DateTime('2015-07-27 00:00:00 PDT');
$date = new \DateTime('0000-01-02 23:59:59 UTC');
$this->gameEpoch = $epoch;
$this->gameDaysPerDay = 4;
$keeper = new TimeKeeper($this->gameEpoch, new DateTime(), $this->gameOffsetSeconds, $this->gameDaysPerDay);
$this->gameEpoch = $epoch;
$this->gameDaysPerDay = 4;
$keeper = new TimeKeeper($this->gameEpoch, new DateTime(), $this->gameOffsetSeconds, $this->gameDaysPerDay);
$converted = $keeper->convertFromGameTime($date);
$this->assertEquals("2015-07-27 11:59:59", $converted->format('Y-m-d H:i:s'));
}
$converted = $keeper->convertFromGameTime($date);
$this->assertEquals("2015-07-27 11:59:59", $converted->format('Y-m-d H:i:s'));
}
public function testGameTimeSanity() {
$keeper = new TimeKeeper($this->gameEpoch, new DateTime(), $this->gameOffsetSeconds, $this->gameDaysPerDay);
$this->assertNotNull($keeper->getGameTime());
}
public function testGameTimeSanity() {
$keeper = new TimeKeeper($this->gameEpoch, new DateTime(), $this->gameOffsetSeconds, $this->gameDaysPerDay);
$this->assertNotNull($keeper->getGameTime());
}
}