1
1

CentaurVillage.ts 3.6 KB

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