1
1

MapNote.ts 938 B

12345678910111213141516171819202122232425262728293031323334
  1. /// <reference path="../Thing.ts" />
  2. /// <reference path="../Room.ts" />
  3. /**
  4. * Maps can hold information of certain rooms or a region.
  5. * If a player has a map, all the rooms in the map are always remembered.
  6. */
  7. class MapNote extends Thing {
  8. public rooms : Array<Room> = [];
  9. public regions : Array<Region> = [];
  10. public addRoom (...rooms : Array<Room>) {
  11. rooms.forEach((room) => {
  12. this.rooms.push(room);
  13. });
  14. }
  15. public addRegion (...regions : Array<Region>) {
  16. regions.forEach(region => {
  17. this.regions.push(region);
  18. });
  19. }
  20. public contains (room : Room) {
  21. if(this.rooms.indexOf(room) != -1) {
  22. return true;
  23. } else {
  24. for (var i = 0; i < this.regions.length; i++) {
  25. if (this.regions[i].getRooms().indexOf(room) != -1) {
  26. return true;
  27. }
  28. }
  29. }
  30. }
  31. }