123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112 |
- /// <reference path="../Forest.ts" />
- /// <reference path="ForestBed.ts" />
- /// <reference path="OrcVillage.ts" />
- /// <reference path="WitchHut.ts" />
- /// <reference path="MazeEntrance.ts" />
- /// <reference path="TheObelisk.ts" />
- /// <reference path="CentaurVillage.ts" />
- /// <reference path="OminousCave.ts" />
- PlayBegins.rulebook.addRule(new Rule({
- name : "Randomize Forest Region",
- firstPriority : Rule.PRIORITY_HIGHEST,
- code : async runner => {
- await Forest.region.randomize();
- }
- }));
- RegionRandom.rulebookRandomizeRegion.addRule(new Rule({
- name : "Add the first rooms to guarantee position.",
- firstPriority : Rule.PRIORITY_HIGHEST,
- code : async runner => {
- // Add the clearing in the woods
- let cells = [
- Forest.ForestBed,
- Forest.OrcVillageSouthGates,
- Forest.CentaurVillageSoutheastGates,
- Forest.Pond,
- Forest.WitchHut,
- Forest.MazeEntrance,
- Forest.OminousCave,
- Forest.TheObelisk,
- ];
- for (let i = 0; i < cells.length; i++) {
- let options : RandomizingRoomOptions = {
- map : Forest.region.map,
- room : cells[i],
- region : Forest.region
- };
- await RegionRandom.rulebookBeforePlaceRoom.execute({noun : options});
- await RegionRandom.rulebookPlaceRoom.execute({noun : options});
- await RegionRandom.rulebookAfterPlaceRoom.execute({noun : options});
- }
- let minimumAmountOfRooms = cells.length * 7;
- let placed = Forest.region.getRooms().length; // At this stage, every room is placed
- for (let i = (minimumAmountOfRooms - placed); i > 0; i--) {
- Forest.region.place(new Forest.region.fodderRoomClass());
- }
- },
- conditions : runner => {
- return runner.noun == Forest.region;
- }
- }));
- RegionRandom.rulebookRandomizeRegion.createAndAddRule({
- name : "Beautify the Forest - Plainify",
- firstPriority : RegionRandom.ruleAddExtraConnections.firstPriority,
- priority : RegionRandom.ruleAddExtraConnections.priority + 1,
- code : () => {
- ForestFodder.definedRooms(<Array<ForestFodder>> Forest.region.getRooms().filter((room : RoomRandom) => {
- return room.placed && room instanceof ForestFodder;
- }));
- }
- });
- RegionRandom.rulebookRandomizeRegion.createAndAddRule({
- name : "Beautify the Forest - Make Beaten Paths",
- firstPriority : RegionRandom.ruleAddExtraConnections.firstPriority,
- priority : RegionRandom.ruleAddExtraConnections.priority - 1,
- code : () => {
- ForestFodder.makePaths(<Array<ForestFodder>> Forest.region.getRooms().filter((room : RoomRandom) => {
- return room.placed && room instanceof ForestFodder;
- }));
- }
- });
- RegionRandom.rulebookRandomizeRegion.createAndAddRule({
- name : "Beautify the Forest - Just give descriptions to them",
- firstPriority : RegionRandom.ruleAddExtraConnections.firstPriority,
- priority : RegionRandom.ruleAddExtraConnections.priority - 2,
- code : () => {
- ForestFodder.panicModeBeautify(<Array<ForestFodder>> Forest.region.getRooms().filter((room : RoomRandom) => {
- return room.placed && room instanceof ForestFodder;
- }));
- }
- });
- RegionRandom.rulebookRandomizeRegion.addRule(new Rule({
- name : "After placing and doing extra connections",
- firstPriority : -1,
- code : async runner => {
- // Add the clearing in the woods
- let cells = [
- ];
- for (let i = 0; i < cells.length; i++) {
- let options : RandomizingRoomOptions = {
- map : Forest.region.map,
- room : cells[i],
- region : Forest.region
- };
- await RegionRandom.rulebookBeforePlaceRoom.execute({noun : options});
- await RegionRandom.rulebookPlaceRoom.execute({noun : options});
- await RegionRandom.rulebookAfterPlaceRoom.execute({noun : options});
- }
- },
- conditions : runner => {
- return runner.noun == Forest.region;
- }
- }));
|