22 lines
739 B
C++
22 lines
739 B
C++
#include "city.h"
|
|
|
|
City::City(int cId, int pId, const QString &cName, int tx, int ty, const QVector3D &pos,
|
|
int initInhabitants, int initInhabitantsPerPop, int initRadius)
|
|
: id(cId), playerId(pId), name(cName), tileX(tx), tileY(ty), worldPos(pos),
|
|
inhabitants(initInhabitants), inhabitantsPerPop(initInhabitantsPerPop)
|
|
{
|
|
// Claim center tile
|
|
territory.emplace_back(tx, ty);
|
|
|
|
// Claim surrounding 6 tiles (radius 1)
|
|
if (initRadius >= 1) {
|
|
for (int e = 0; e < 6; ++e) {
|
|
int nx, ny;
|
|
getHexNeighbor(tx, ty, e, nx, ny);
|
|
if (nx >= 0 && nx < MAP_WIDTH && ny >= 0 && ny < MAP_HEIGHT) {
|
|
territory.emplace_back(nx, ny);
|
|
}
|
|
}
|
|
}
|
|
}
|