-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaction_transmute.cpp
62 lines (54 loc) · 1.52 KB
/
action_transmute.cpp
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
#include "action_transmute.h"
#include "prototypes.h"
#include "gamesimulator.h"
Transmute::Transmute(bool me, std::vector<position> region)
{
_me = me;
_region = region;
}
void Transmute::simulate(GameSimulator& sim)
{
BoardSimulator& board = _me ? sim.myBoard : sim.oppBoard;
_type = board.typeCase(_region[0]);
_diffScore = regionGoldValue(_region.size(), _type);
_diffCatalyser = regionCatalyserValue(_region.size(), _type);
board.fillRegion(_region, VIDE);
if(_me)
{
if(_region.size() == 1) sim.penalty += ONE_PENALTY;
sim.myScore += _diffScore;
sim.myCatalyser += _diffCatalyser;
}
else
{
if(_region.size() == 1) sim.penalty -= ONE_PENALTY;
sim.oppScore += _diffScore;
sim.oppCatalyser += _diffCatalyser;
}
}
void Transmute::undo(GameSimulator& sim)
{
if(_me)
{
sim.myBoard.fillRegion(_region, _type);
if(_region.size() == 1) sim.penalty -= ONE_PENALTY;
sim.myScore -= _diffScore;
sim.myCatalyser -= _diffCatalyser;
}
else
{
sim.oppBoard.fillRegion(_region, _type);
if(_region.size() == 1) sim.penalty += ONE_PENALTY;
sim.oppScore -= _diffScore;
sim.oppCatalyser -= _diffCatalyser;
}
}
void Transmute::execute()
{
erreur err = transmuter(_region[0]);
if(err != OK) printf("FAIL Transmute (%d,%d)...\n", _region[0].ligne, _region[0].colonne);
}
void Transmute::debugPrint()
{
printf("Transmuter (%d,%d)\n", _region[0].ligne, _region[0].colonne);
}