lotgd / core

Core functionality for Legend of the Green Dragon, a text-based RPG game.
GNU Affero General Public License v3.0
152 stars 15 forks source link

Feature/scene connections #83

Closed Vassyli closed 7 years ago

Vassyli commented 7 years ago

The parent<=>child relationship of scenes was removed. Instead, this commit introduces the concept of a connection.

A connection is used to connect two scenes. Depending on which entity the connect-method is called, one is defined as the "outgoing" scene, the other as the ingoing scene:

$a->connect($b);

In this case, $a will be the outgoing part of the connection, $b the incoming.

Furthermore, in order to support action groups, this commit introduces SceneConnectionGroups which can be created in scenes and checked wether they exist or not. Using these, it is possible to specifiy to which part of the scenes are connected to each other.

$a->getConnectionGroup("scene-A/marketsquare")->connect($b);

In this case, $a will have the action to access $b under the ActionGroup of scene-A/marketsquare. On the other hand, $b, which doesn't have a connection group specified, will have the connection back to $a in the default group.

Connect also accepts the return value of getConnectionGroup as the argument, thus allowing the connection to a certain part of $b as well:

$a->connect($b->getConnectionGroup("scene-B/back"));

The tests for scenes were updates in order to reflect this change. Additional tests were added to check if directionality is supported (Currently, only Bidirectional (default) and Unidirectional are supported).