-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathstoryteller.php
42 lines (34 loc) · 1.24 KB
/
storyteller.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
<?php
require_once 'logic/config.php';
require_once 'logic/functions.php';
require_once 'logic/slack.php';
// Check the incoming data for the secret slack token
if ($_POST['token'] != $config->slack_token) {
header('HTTP/1.0 403 Forbidden');
die('Access Denied. Token does not match');
}
// Gamebook Object
require_once 'logic/rulesets/'.getbook().'.php';
$bookclass = 'Book_'.getbook();
$gamebook = new $bookclass($player);
// Split the command list by semi-colons. Allows multiple commands to be queued
// Note, some commands will queue other commands
// Note $commandlist is referenced as a global variable
$commandlist = explode(";", html_entity_decode($_POST['text']));
// Trim and Filter Trigger word from commands
// From this point onwards all commands are expected to NOT have the trigger word
foreach ($commandlist as $key => $command) {
$command = trim($command);
if (stripos($command, $_POST['trigger_word']) === 0) {
$commandlist[$key] = substr($command, strlen($_POST['trigger_word']));
}
}
foreach ($commandlist as $command) {
$gamebook->addCommand($command, true, true);
}
$gamebook->processCommandList();
$gamebook->savePlayer();
// Deal with messages left in the queue
if ($message_queue) {
sendmsg("");
}