-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathloadSave.cc
43 lines (38 loc) · 1.38 KB
/
loadSave.cc
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
#include "loadSave.h"
#include "player.h"
#include "ownable.h"
#include "square.h"
#include "residence.h"
#include "academic.h"
#include "gym.h"
#include "seeds.h"
#include "transactions.h"
// assume the ownableName is passed in correctly
void LoadSave::loadProperty(std::string ownableName, std::shared_ptr<Player> buyer, int imprLevel) {
// create a new property for player
int propID = indexOfSquare(ownableName); // the id is the unique index of square on the map
int propCostToBuy = costToBuyProp(ownableName);
char propOwner = buyer->getGamePiece();
std::shared_ptr<Ownable> ownable;
if (isGym(ownableName))
{
auto production = std::make_shared<Gym>(propID, ownableName, propCostToBuy, propOwner);
ownable = std::dynamic_pointer_cast<Ownable>(production);
}
else if (isResidence(ownableName))
{
auto production = std::make_shared<Residence>(propID, ownableName, propCostToBuy, propOwner);
ownable = std::dynamic_pointer_cast<Ownable>(production);
}
else if (isAcademic(ownableName))
{
auto production = std::make_shared<Academic>(propID, ownableName, propCostToBuy, propOwner);
ownable = std::dynamic_pointer_cast<Ownable>(production);
}
buyer->addProp(ownable);
if (imprLevel == -1) {
ownable->setMortStatus(true);
} else {
ownable->setImprLevel(imprLevel + 1);
}
}