-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathGalaxy.h
134 lines (122 loc) · 3.97 KB
/
Galaxy.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
#ifndef GALAXY_H
#define GALAXY_H
#include "Equipment.h"
#include "Ship.h"
#include "Star.h"
#include "Planet.h"
#include "BlackHole.h"
#include "Galaxy.h"
#include <QImage>
#include <QPainter>
#include <QRectF>
#include <iostream>
#include <unordered_map>
#include <cmath>
class Galaxy
{
public:
explicit Galaxy();
void parseDump(QTextStream& stream);
void clear();
unsigned shipCount() const;
unsigned equipmentCount() const;
unsigned starCount() const;
unsigned blackHoleCount() const;
unsigned planetCount() const;
unsigned galaxyTechLevel() const;
void addEquipment(Equipment&& eq);
void addShip(const Ship&& ship);
void addStar(const Star&& star);
void addBlackHole(const BlackHole&& bh);
void addPlanet(const Planet&& planet);
QString starOwner(unsigned starId) const;
unsigned marketsCount() const;
QString marketName(unsigned row) const;
QString marketPlanetEconomy(unsigned row) const;
QString marketPlanetOwner(unsigned row) const;
unsigned marketPlanetSize(unsigned row) const;
unsigned marketPlanetTechLevel(unsigned row) const;
const GoodsArr& marketQuantity(unsigned row) const;
const GoodsArr& marketSale(unsigned row) const;
const GoodsArr& marketBuy(unsigned row) const;
unsigned marketId(unsigned row) const;
double marketDistFromPlayer(unsigned row) const;
QString marketStarName(unsigned row) const;
unsigned equipmentId(unsigned row) const;
QString equipmentName(unsigned row) const;
QString equipmentType(unsigned row) const;
unsigned equipmentSize(unsigned row) const;
QString equipmentOwner(unsigned row) const;
unsigned equipmentCost(unsigned row) const;
unsigned equipmentTechLevel(unsigned row) const;
QString equipmentLocationType(unsigned row) const;
QString equipmentLocationName(unsigned row) const;
int equipmentDepth(unsigned row) const;
QString equipmentStarName(unsigned row) const;
double equipmentDistFromPlayer(unsigned row) const;
QString equipmentStarOwner(unsigned row) const;
double equipmentDurability(unsigned row) const;
QString equipmentBonus(unsigned row) const;
unsigned blackHoleId(unsigned row) const;
QString blackHoleStar1(unsigned row) const;
float blackHoleStar1Distance(unsigned row) const;
QString blackHoleStar2(unsigned row) const;
float blackHoleStar2Distance(unsigned row) const;
int blackHoleTurnsToClose(unsigned row) const;
QString blackHoleNextLootChange(unsigned row) const;
const Planet& planet(unsigned row) const
{
return planetMap.at(planetVec[row]);
}
float planetDistance(unsigned row) const
{
unsigned planetStarId=planet(row).starId();
unsigned playerStarId=shipMap.at(0).starId();
QPointF playerPos=starMap.at(playerStarId).position();
QPointF planetPos=starMap.at(planetStarId).position();
QPointF delta=playerPos-planetPos;
return std::sqrt(std::pow(delta.x(), 2) + std::pow(delta.y(), 2));
}
QString planetStarName(unsigned row) const
{
unsigned planetStarId=planet(row).starId();
return starMap.at(planetStarId).name();
}
QString planetOwner(unsigned row) const
{
const auto& pl=planet(row);
if (pl.owner()=="Kling") {
unsigned planetStarId=pl.starId();
return starOwner(planetStarId);
}
return pl.owner();
}
const GoodsArr& maxBuyPrice() const
{
return _maxBuyPrice;
}
const GoodsArr& minSellPrice() const
{
return _minSellPrice;
}
QImage map(const unsigned width=700, const int fontSize=8) const;
private:
unsigned marketStarId(unsigned row) const;
unsigned equipmentStarId(unsigned row) const;
private:
std::unordered_map<unsigned,Equipment> eqMap;
std::unordered_map<unsigned,Ship> shipMap;
std::unordered_map<unsigned,Star> starMap;
std::unordered_map<unsigned,Planet> planetMap;
std::vector<BlackHole> blackHoles;
std::vector<unsigned> planetMarkets;
std::vector<unsigned> shipMarkets;
std::vector<unsigned> eqVec;
std::vector<unsigned> planetVec;
unsigned currentDay=0;
mutable GoodsArr _maxBuyPrice;
mutable GoodsArr _minSellPrice;
QRectF galaxyMapRect;
static const QMap<QString,QColor> _ownerToColor;//name,description
};
#endif // GALAXY_H