-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaction_catalyse.cpp
55 lines (47 loc) · 1.28 KB
/
action_catalyse.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
#include "action_catalyse.h"
#include "action_transmute.h"
#include "gamesimulator.h"
Catalyse::Catalyse(bool fromMe, bool toMe, position pos, case_type dest_type)
{
_fromMe = fromMe;
_toMe = toMe;
_pos = pos;
_type = dest_type;
}
void Catalyse::simulate(GameSimulator& sim)
{
if(_toMe)
{
_prevType = sim.myBoard.typeCase(_pos);
sim.myBoard.setCase(_pos, _type);
}
else
{
_prevType = sim.oppBoard.typeCase(_pos);
sim.oppBoard.setCase(_pos, _type);
}
if(_fromMe) sim.myCatalyser--;
else sim.oppCatalyser--;
}
void Catalyse::undo(GameSimulator& sim)
{
if(_toMe) sim.myBoard.setCase(_pos, _prevType);
else sim.oppBoard.setCase(_pos, _prevType);
if(_fromMe) sim.myCatalyser++;
else sim.oppCatalyser++;
}
void Catalyse::execute()
{
erreur err = catalyser(_pos, _toMe ? moi() : adversaire(), _type);
if(err != OK) printf("FAIL Catalyse (%d)...", err);
}
void Catalyse::debugPrint()
{
if(_toMe) printf("Catalyse Me (%d,%d)->%d\n", _pos.ligne, _pos.colonne, _type);
else printf("Catalyse Opp (%d,%d)->%d\n", _pos.ligne, _pos.colonne, _type);
}
Action* Catalyse::defenseReaction(GameSimulator& game)
{
if(!_toMe) return nullptr;
return new Transmute(true, game.myBoard.regionOf(_pos));
}