-
-
Save sasin91/27388e3ee7f2e0686fdd203803c4fe93 to your computer and use it in GitHub Desktop.
Bored.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Person | |
* @requires: PHP 7.1+ | |
* @TODO: Description | |
* @TODO: Add further Contracts Err, Interfaces. | |
* @TODO: Implement definition of Lust and morph with Emotion where applicable | |
* @TODO: Implement relationships | |
*/ | |
class Person extends Entity implements FamilyMember, | |
Reproducable, | |
EmotionallyEnabled, | |
ShouldQue, | |
Sociable, | |
HumanMind, | |
HumanBehavior | |
{ | |
use SociallyAcceptableBehavior, | |
Consciousness; | |
public $facade, $gender, $type; | |
protected $attributes, $persona, $character; | |
private $details; | |
public function __construct($state) | |
{ | |
$this->configureWith($state); | |
} | |
protected function configureWith($state) | |
{ | |
// @TODO: Implement configuration of personal state | |
} | |
public function __wakeup() | |
{ | |
$state = unserialize(DB::getLastSavedState()); | |
$me = new static($state); | |
// @TODO: Refactor into MorningRoutine | |
$me->checkSchedule(); | |
$me->consumeBreakfast(); | |
$me->checkAppointments(); | |
$me->updateSchedule(); | |
$schedule = $me->getSchedule(); | |
if(!$schedule->has('gymTime')) | |
{ | |
$schema = $schedule->get('workoutSchema'); | |
if($workout = $schema->for((new Time())->today())->has('workout')) | |
{ | |
$schedule->put('gymTime', $workout); | |
} | |
} | |
if($schedule->has('appointments')) | |
{ | |
foreach ($schedule->get('appointments') as $appointment) { | |
queue()->for($me)->push($appointment); | |
} | |
} | |
// @TODO: Implement events and more. | |
// @consider: Using a switch. | |
if($me->hasJob() && $me->isExpectedAtWorkToday()) | |
{ | |
// Pun intended. | |
$me->goTo(Work::class); | |
} else { | |
$me->checkPersonalProjects(); | |
if($me->wantsToImproveProject()) | |
{ | |
$me->improveProject(); | |
} else { | |
$me->playGames(); | |
} | |
} | |
} | |
public function __sleep(Time $period) | |
{ | |
$me = New \ReflectionClass($this); | |
// TODO: Implement methods below... | |
// TODO: Refactor into SleepRoutine | |
$me->introspect('*'); | |
$me->validateSchedule('today'); | |
$me->considerTommorow(); | |
$me->checkAlarm(); | |
$expectedTimeAsleep = $me->evaluteActualSleepPeriod($period); | |
$state = serialize($me); | |
DB::store($state); | |
try { | |
sleep($expectedTimeAsleep); | |
} catch (Dream $dream) { | |
if($dream->isLucid()) | |
{ | |
$dream->inject($me)->observe(); | |
} | |
if($dream->isNightmare()) | |
{ | |
$dream->cancel(); | |
$dream->newOrWakeup(); | |
} | |
} catch(Interuption $annoyance) { | |
$annoyance->handle(); | |
$me->resumeSleep(); | |
} | |
} | |
protected function routine(Routine $routine, Time $period) | |
{ | |
while ($period->isNotExpired()) { | |
$routine->for($this)->execute(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment