Page Menu
Home
Code
Search
Configure Global Search
Log In
Files
F212483
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
9 KB
Subscribers
None
View Options
diff --git a/Engines/Perso/Events/TryAutoSelect.php b/Engines/Perso/Events/TryAutoSelect.php
index de84ab8..653355a 100644
--- a/Engines/Perso/Events/TryAutoSelect.php
+++ b/Engines/Perso/Events/TryAutoSelect.php
@@ -1,49 +1,49 @@
<?php
namespace Zed\Engines\Perso\Events;
use Perso;
class TryAutoSelect extends BaseEvent {
/**
* @var Perso[]
*/
private array $persos;
public function isTriggered (): bool {
return !$this->selector->hasPerso;
}
public function handle () : void {
$this->persos = Perso::get_persos($this->selector->user->id);
$count = count($this->persos);
if ($count === 0) {
$this->askUserToCreatePerso();
} elseif ($count === 1) {
$this->autoselect();
} else {
$this->askUserToSelectPerso();
}
}
- private function askUserToCreatePerso () : void {
+ private function askUserToCreatePerso () : never {
$this->selector->smarty
->display("perso_create.tpl");
exit;
}
private function autoselect () : void {
$this->selector->selectAndSetPerso($this->persos[0]);
}
- private function askUserToSelectPerso () : void {
+ private function askUserToSelectPerso () : never {
$this->selector->smarty
->assign("PERSOS", $this->persos)
->display("perso_select.tpl");
$_SESSION['UserWithSeveralPersos'] = true;
exit;
}
}
diff --git a/Engines/Perso/PersoSelector.php b/Engines/Perso/PersoSelector.php
index 5651fc7..36de588 100644
--- a/Engines/Perso/PersoSelector.php
+++ b/Engines/Perso/PersoSelector.php
@@ -1,121 +1,122 @@
<?php
namespace Zed\Engines\Perso;
use Smarty;
+use Zed\Engines\Perso\Events\BaseEvent;
use Zed\Engines\Perso\Events\Create;
use Zed\Engines\Perso\Events\Logout;
use Zed\Engines\Perso\Events\ReadFromSession;
use Zed\Engines\Perso\Events\Select;
use Zed\Engines\Perso\Events\TryAutoSelect;
use Perso;
use User;
use LogicException;
class PersoSelector {
///
/// Properties
///
public User $user;
public Smarty $smarty;
public Perso $perso;
public bool $hasPerso = false;
///
/// Constructors
//
/**
* @param User $user The currently logged user
*/
public function __construct (User $user, Smarty $smarty) {
$this->smarty = $smarty;
$this->user = $user;
}
///
/// Events processing
///
/**
* Select a perso using several strategies in a sequential order.
*
* Order matters: for example, to be able to log a perso out,
* we first need to select it from the session.
*
- * @return \Zed\Engines\Perso\Events\BaseEvent[]
+ * @return BaseEvent[]
*/
private function getDefaultEvents () : array {
return [
// Strategy 1. Look in session if the perso is already selected.
new ReadFromSession($this),
// Strategy 2. Process forms and actions from URL.
new Create($this),
new Logout($this),
new Select($this),
// Strategy 3. Try to autoselect a perso or ask user for one.
new TryAutoSelect($this),
];
}
private function handleEvents () : void {
$events = $this->getDefaultEvents();
foreach ($events as $event) {
$event->run();
}
}
/**
* Run all the workflow to get a perso.
*/
public static function load (User $user, Smarty $smarty) : Perso {
$selector = new self($user, $smarty);
$selector->handleEvents();
if (!$selector->hasPerso) {
throw new LogicException(<<<'EOD'
The selector has processed the different events and scenarii
to pick a perso. The expectation after all events have been
handled is we've selected a perso or have printed any view
to create or select one.
As such, this code should be unreachable. Debug the different
'isTriggered' and 'handle' methods of the events to ensure the
last event exit or return a perso.
EOD);
}
$smarty->assign('CurrentPerso', $selector->perso);
return $selector->perso;
}
///
/// Properties
///
/**
* Select a perso, as a fresh login.
*
* If the perso is already logged in,
* we can call PersoSelector::setPerso instead.
*/
public function selectAndSetPerso (Perso $perso) : void {
$perso->on_select();
$this->setPerso($perso);
}
public function setPerso (Perso $perso) : void {
$this->perso = $perso;
$this->hasPerso = true;
}
}
diff --git a/README b/README
index c48ad3e..f44befc 100644
--- a/README
+++ b/README
@@ -1,154 +1,154 @@
ZzzzzzZ zz
Z z z The spatial gallery / social network / lounge
z z (c) 2010, Dereckson, some rights reserved.
z zzzzz zzzzz
z z z z z 0.1 alpha technical preview
z zzzzzzz z z
z z z z Last update hypership time: 5.096
z Z z z z z
ZzzzzzZ zzzzz zzzzzz
=========
INSTALL
=========
- * Zed is a PHP 7 application.
+ * Zed is a PHP 8.1+ application.
* You can import dev/schema-mysql.sql as original SQL schema
* The configuration file is includes/config.php
* Files are cached in 3 directories of the cache folder, sets appropriate
write permissions to:
compiled openid sessions
* Zed needs but doesn't include in its code the Janrain OpenID PHP libraries:
http://www.janrain.com/openid-enabled - http://github.com/openid/php-openid
Put the Auth folder somewhere in your include_dir path.
bcmath and GMP php extensions are recommended (required?) for OpenID.
Our dev environment outputs a white page without error if GMP isn't here.
=========
UPGRADE
=========
* For our main prod install, we use a script exporting last repo revision with
hg archive and applying a patch to config.php.
===========
LOCATIONS
===========
* Global location is a 9 letters code
<B,S> <body or spaceship id> <place where you are in this body/spaceship>
zerofilled 5 digits zerofilled 3 digits
You can also find 6 digits expressions e.g. B00001 is the hypership
* Local location varies of the place.
- On hypership core (B00001002): Sector C<0-8> Level <z> Zone <x-y>
- 0 is the gravity center
- 1-8 the 8 cubes surrounding it: 1-4 below, 5-8 above
- On the ship tower (B00001001): Sector T<z> Couloir <1-6>
- z is the level
- couloir depends of your x, y position (polar coordinates could help)
=================
HYPERSHIP TIME?
=================
* The amount of days since hypership launch, July 3rd 2010 00:00 UTC
* So the decimal part is like internet time, but in GMT and not CET/CEST
===============
SIDE PROJECTS
===============
* A pazaak game, to have something to play
* Will be an Arzakon client
=================
I WANT TO HELP!
=================
* You can create new SmartLine commands
* You can translate it in a new language
Start point: http://zed.dereckson.be/lang/en/core.conf
* You can code a bit of adventure, places description, stuff to do
as long you don't transform it in ogame clone (we're building a community
who want or don't want to play, but not a mechanic game)
and as long no money is involved (if you ask why, read Iain M. Banks novels)
in the hypership (in far asteroids, orbitals, planets you do what you want)
============
KNOWN BUGS
============
* Javascript get_hypership_time will returns 5.94 instead 5.094
Some %03d to add in /js/misc.js
* The floater rendering adds a black line under Opera
dojox.layout.floatingPane bug, need to check with last dojo version
* API /location query will break indent on location->body->location
beautify XML code to improve
* do.php allows any local location move, discarding FrL status
* The upload artwork dojo form can't be closed under Opera
=======================
API - General methods
=======================
* /api.php/time
Returns hypership time
Public access
* /api.php/perso/<perso_id>
Returns perso object
Created only to test extensively recursivity of api xml output
It's disabled since 10.811 on zed.dereckson.be, if you need an alternative,
open a bug report with the fields you need. Ship API should be able to manage
inventory if user is on. Ship API must also be able to get/set custom flags.
Requires a key
* /api.php/location/<location code or name>
Returns location object
Tip: to get the full name, use string eg /api.php/location/Zeta?format=string
Requires a key
* GET/POST API parameters
- key
API key, ask it at zed at dereckson be, object [DEV] api key request
- format
- preview print_r representation, so you've an idea of the object
- json json_encode() output
- php serialize() output
- xml XML document
- string output "as is" (or if it's an object, calls __toString())
============
API - Ship
=============
* /api.php/ship/authenticate/<perso nickname>
=================
ACKNOWLEDGEMENT
=================
Elfix, to have let me figure a regexp correction, instead to throw away regexp
validation for places local location.
File Metadata
Details
Attached
Mime Type
text/x-diff
Expires
Mon, Nov 25, 06:11 (10 h, 39 m ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
21199
Default Alt Text
(9 KB)
Attached To
rZED Zed
Event Timeline
Log In to Comment