1 #pragma once 2 3 #include "JsonObject.h" 4 #include "Strategic.h" 5 #include "UndergroundSectorModel.h" 6 7 #include <array> 8 #include <rapidjson/document.h> 9 #include <string> 10 #include <vector> 11 12 struct CreatureAttackSector 13 { 14 uint8_t sectorId; 15 uint8_t chance; 16 InsertionCode insertionCode; 17 int16_t insertionGridNo; 18 }; 19 20 struct CreatureLairSector 21 { 22 uint8_t sectorId; 23 uint8_t sectorLevel; 24 uint8_t habitatType; 25 }; 26 27 class CreatureLairModel 28 { 29 public: 30 CreatureLairModel(const uint8_t lairId_, const uint8_t associatedMineId_, 31 const uint8_t entranceSector_, const uint8_t entranceSectorLevel_, 32 const std::vector<CreatureLairSector> lairSectors_, 33 const std::vector<CreatureAttackSector> attackSectors_, 34 const uint8_t warpExitSector_, const uint16_t warpExitGridNo_); 35 36 const uint8_t lairId; 37 const uint8_t associatedMineId; 38 39 // underground sector where the lair entrance is at 40 const uint8_t entranceSector; 41 42 // sector Z of the lair entrance 43 const uint8_t entranceSectorLevel; 44 45 // underground sectors making up the lair, the list always starts from the innermost sector, i.e. the creature queen location 46 const std::vector<CreatureLairSector> lairSectors; 47 48 // town sectors that may be attacked by creatures 49 const std::vector<CreatureAttackSector> attackSectors; 50 51 // destination sector of the "travel to surface" warp 52 const uint8_t warpExitSector; 53 54 // destination gridNo of the "travel to surface" warp 55 const uint16_t warpExitGridNo; 56 57 // returns if the given sector is part of the lair 58 bool isSectorInLair(uint8_t sectorX, uint8_t sectorY, uint8_t sectorZ) const; 59 60 // randomly choose a town sector to attack, returns the placement details of the attack 61 const CreatureAttackSector* chooseTownSectorToAttack() const; 62 63 // returns the placeent details of an attack to the specific sector 64 const CreatureAttackSector* getTownAttackDetails(uint8_t sectorId) const; 65 66 static CreatureLairModel* deserialize(const rapidjson::Value& json); 67 static void validateData(const std::vector<const CreatureLairModel*>& lairs, const std::vector<const UndergroundSectorModel*>& ugSectors, uint8_t numMines); 68 }; 69