12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152 |
- /// <reference path="./Classes/Rulebook.ts" />
- /// <reference path="./Classes/Rule.ts" />
- /// <reference path="MachineBegins.ts" />
- module PlayBegins {
- export var rulebook = new Rulebook<void>("Play Begins");
- export var LOAD_FAILED = false;
- export let startingRoom;
- export function execute () {
- rulebook.execute({});
- }
- export function setStartingRoom (room : Room) {
- if (startingRoom != undefined) {
- console.warn("[InitialRoom] Multiple requests for starting room, please check.", startingRoom, room);
- }
- startingRoom = room;
- }
- export let PutPlayerIntoFirstRoom = rulebook.createAndAddRule({
- name : "Place player into initial room",
- firstPriority : Rule.PRIORITY_HIGHEST,
- priority : Rule.PRIORITY_MEDIUM,
- code : () => {
- if (WorldState.player.getRoom() != undefined) {
- console.debug(Rulebook.getIndentation() + "[InitialRoom] Player already in a room.", WorldState.player.getRoom());
- } else {
- startingRoom.place(WorldState.player);
- }
- }
- });
- export var RunEmptyTurnSequenceRule = new Rule ({
- name : "Run Empty Turn Sequence Rule",
- firstPriority : Rule.PRIORITY_LOWEST,
- priority : Rule.PRIORITY_LOWEST,
- code : (rulebook2 : RulebookRunner<void>) => {
- TurnSequence.execute();
- }
- });
- rulebook.addRule(RunEmptyTurnSequenceRule);
- }
- module MachineBegins {
- export let RunPlayBegins = MachineBegins.rulebook.createAndAddRule({
- firstPriority : Rule.PRIORITY_LOW,
- name : "Run Play Begins",
- code : () => {
- PlayBegins.execute();
- }
- });
- }
|