1
1

OrcVillage.ts 3.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. /// <reference path="../Forest.ts" />
  2. module Forest{
  3. export let OrcCoordinates = Forest.rnc.generate(3,4, 2, 4);
  4. export let OrcVillageSouthGates = new RoomRandom("The Orc Tribe - South Gates", false, true);
  5. export let OrcVillageNorthwestGates = new RoomRandom("The Orc Tribe - North Gates", false, true);
  6. export let OrcVillageWestWall = new RoomRandom("Around the Orc Tribe - West", false, true);
  7. export let OrcVillageNorthWall = new RoomRandom("Around the Orc Tribe - North", false, true);
  8. export let OrcVillageNortheastWall = new RoomRandom("Around the Orc Tribe - Northeast", false, true);
  9. export let OrcVillageEastWall = new RoomRandom("Around the Orc Tribe - East", false, true);
  10. export let OrcVillageSoutheastWall = new RoomRandom("Around the Orc Tribe - Southeast", false, true);
  11. export let OrcVillageSouthWall = new RoomRandom("Around the Orc Tribe - South", false, true);
  12. OrcVillageSouthGates.mapRoom(OrcVillageWestWall, Direction.NORTH);
  13. OrcVillageWestWall.mapRoom(OrcVillageNorthwestGates, Direction.NORTH);
  14. OrcVillageNorthwestGates.mapRoom(OrcVillageNorthWall, Direction.EAST);
  15. OrcVillageNorthWall.mapRoom(OrcVillageNortheastWall, Direction.EAST);
  16. OrcVillageNortheastWall.mapRoom(OrcVillageEastWall, Direction.SOUTH);
  17. OrcVillageEastWall.mapRoom(OrcVillageSoutheastWall, Direction.SOUTH);
  18. OrcVillageSoutheastWall.mapRoom(OrcVillageSouthWall, Direction.WEST);
  19. OrcVillageSouthWall.mapRoom(OrcVillageSouthGates, Direction.WEST);
  20. export let OrcVillageWalls = [OrcVillageWestWall, OrcVillageNorthWall, OrcVillageNortheastWall, OrcVillageEastWall, OrcVillageSoutheastWall, OrcVillageSouthWall];
  21. }
  22. Forest.region.place(Forest.OrcVillageSouthGates);
  23. Forest.region.place(Forest.OrcVillageNorthwestGates);
  24. Forest.OrcVillageSouthGates.backgroundImage = "roomOrcVillage";
  25. Forest.OrcVillageNorthwestGates.backgroundImage = "roomOrcVillage";
  26. Forest.OrcVillageWalls.forEach(wall => {
  27. Forest.region.place(wall);
  28. wall.backgroundImage = "roomOrcVillage";
  29. });
  30. RegionRandom.rulebookAfterPlaceRoom.addRule(new Rule({
  31. name : "After placing the Forest.OrcVillageSouthGates",
  32. code : (runner : RulebookRunner<RandomizingRoomOptions>) => {
  33. // Place the rest of the village
  34. let map = runner.noun.map;
  35. let southwest = map.getCoordinates(runner.noun.room);
  36. let center = [southwest[0] + 1, southwest[1] + 1];
  37. map.map(Forest.OrcVillageNorthwestGates, center[0] -1 , center[1] + 1) ;
  38. map.map(Forest.OrcVillageNorthWall, center[0], center[1] + 1) ;
  39. map.map(Forest.OrcVillageNortheastWall, center[0] + 1, center[1] + 1) ;
  40. map.map(Forest.OrcVillageWestWall, center[0] - 1, center[1]);
  41. map.block(center[0], center[1]);
  42. map.map(Forest.OrcVillageEastWall, center[0] + 1, center[1]) ;
  43. map.map(Forest.OrcVillageSouthWall, center[0], center[1] - 1) ;
  44. map.map(Forest.OrcVillageSoutheastWall, center[0] + 1, center[1] - 1);
  45. },
  46. conditions : (runner : RulebookRunner<RandomizingRoomOptions>) => {
  47. return runner.noun.room == Forest.OrcVillageSouthGates;
  48. }
  49. }));
  50. Forest.OrcVillageSouthGates.trickyCode = (options : TrickyOptions) => {
  51. while (!options.map.isFreeSquare(Forest.OrcCoordinates[0] + 1, Forest.OrcCoordinates[1] + 1, 1)) {
  52. Forest.OrcCoordinates[0] += 1;
  53. }
  54. return options.x == Forest.OrcCoordinates[0] && options.y == Forest.OrcCoordinates[1];
  55. };