Zed. The source code to build a world.

Travel
in package

Travel helper class

The Travel class reads content/travel.xml to get travel special rules

It's so able to provide methods determining if a move is or not valid.

This class implements a singleton pattern.

Table of Contents

Properties

$globalTravelTo  : array<string|int, mixed>
Array of TravelPlace, each one a custom travel rule

Methods

__construct()  : mixed
Constructor
can_travel()  : bool
Determines if a perso can travel from $from to $to
load()  : Travel
Gets and initializes if needed the Travel instance
load_xml()  : mixed
Loads a travel configuration XML file
try_parse_rewrite_rule()  : bool
Tries to parse the specified expression, according the rewrite rules (for example defined by the <RewriteRule> xml tags)

Properties

$globalTravelTo

Array of TravelPlace, each one a custom travel rule

public array<string|int, mixed> $globalTravelTo

This array is indexed by TravelPlace code.

Methods

__construct()

Constructor

public __construct() : mixed

can_travel()

Determines if a perso can travel from $from to $to

public can_travel(mixed $from, mixed &$to) : bool

If an alias have been used for $to local location, set correct location.

Parameters
$from : mixed
$to : mixed
Tags
todo

From B00001002, goto C1 doesn't work. Alias seems ignored.

Return values
bool

true if the travel move is valid ; otherwise, false.

load()

Gets and initializes if needed the Travel instance

public static load() : Travel
Return values
Travel

the Travel instance

load_xml()

Loads a travel configuration XML file

public load_xml(mixed $file) : mixed
Parameters
$file : mixed

try_parse_rewrite_rule()

Tries to parse the specified expression, according the rewrite rules (for example defined by the <RewriteRule> xml tags)

public try_parse_rewrite_rule(string $expression, mixed $from, mixed &$to) : bool
Parameters
$expression : string

the expression to parse

$from : mixed
$to : mixed
Return values
bool

true if the expression have been parsed ; otherwise, false.


        
On this page

Search results