-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcommercial.cpp
More file actions
38 lines (31 loc) · 1.04 KB
/
commercial.cpp
File metadata and controls
38 lines (31 loc) · 1.04 KB
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
#include "commercial.h"
#include "clan.h"
#include <iostream>
Commercial* Commercial::instance = NULL;
unsigned Commercial::prixResource[4] = {500,100,50,20}; ///< Prix d'achat des différentes ressources par le marchant.
const unsigned Commercial::prixRobot = 70000; ///< Prix de vente d'un robot.
Commercial::Commercial()
{
}
bool Commercial::achatRobot(Clan *clanAcheteur, Position& posRobot)
{
bool ret = (clanAcheteur->getArgent() >= prixRobot);
if(ret)
{
clanAcheteur->decArgent(prixRobot);
clanAcheteur->addMember(posRobot,posRobot,Member_type(2),Alliance(clanAcheteur->getAlliance()));
std::cout << " >>> pop robot." << std::endl;
}
return ret;
}
void Commercial::sellResources(Clan *clanVendeur, Resource *sellRes)
{
clanVendeur->incArgent(sellRes->getRessourcesProduite()*prixResource[sellRes->getType()]);
sellRes->RAZRessourcesProduite();
}
Commercial* Commercial::getInstance()
{
if(!instance)
instance = new Commercial();
return instance;
}