-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTacticsHockeyistsAttack.cpp
118 lines (89 loc) · 3.79 KB
/
TacticsHockeyistsAttack.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
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
#include "MyStrategy.h"
#include "AllSystem.h"
#include "UsefulFunctions.h"
#include "constants.h"
#define PI 3.14159265358979323846
#define _USE_MATH_DEFINES
#include <cmath>
#include <cstdlib>
using namespace std;
using namespace model;
using namespace MySystem;
using namespace UsefulFunctions;
void TacticsHockeyists::moveToAttack(Information& information, AllSystem& system) {
const Hockeyist& self = information.self;
const World& world = information.world;
const Game& game = information.game;
Move& move = information.move;
int selfId = self.getTeammateIndex();
bool wasInAttackSector = system.getHockeyistsInAttack(information.self.getTeammateIndex())[0];
bool wasInStrikeSector = system.getHockeyistsInAttack(information.self.getTeammateIndex())[1];
if (wasInAttackSector) {
moveToStrikeSector(information, system);
system.setMovingSectorChoosed(selfId, false);
}
else {
moveToAttackSector(information, system);
}
}
void TacticsHockeyists::moveToAttackSector(Information& information, AllSystem& system) {
const Hockeyist& self = information.self;
const World& world = information.world;
const Game& game = information.game;
Move& move = information.move;
int selfId = self.getTeammateIndex();
Sector attackSector = system.getMovingSector(selfId);
if (system.isMovingSectorChoosed(selfId) == false) {
attackSector = getAttackSector(information, system);
system.setMovingSector(selfId, attackSector);
system.setMovingSectorChoosed(selfId, true);
}
moveQuickToSector(information, system, attackSector);
}
void TacticsHockeyists::moveToStrikeSector(Information& information, AllSystem& system) {
const Hockeyist& self = information.self;
const World& world = information.world;
const Game& game = information.game;
Move& move = information.move;
int selfId = self.getTeammateIndex();
Sector strikeSector = system.getMovingSector(selfId);
if (system.isMovingSectorChoosed(selfId) == false) {
strikeSector = getStrikeSector(information, system);
system.setMovingSector(selfId, strikeSector);
system.setMovingSectorChoosed(selfId, false);
}
moveQuickToSector(information, system, strikeSector);
}
void TacticsHockeyists::strikePuckAttacker(Information& information, AllSystem& system) {
int selfId = information.self.getTeammateIndex();
if (getEffectiveSwingingTicks(information, system) <= information.self.getSwingTicks()) {
information.move.setAction(ActionType::STRIKE);
}
else {
information.move.setAction(ActionType::SWING);
}
}
void TacticsHockeyists::moveToSupportSector(Information& information, AllSystem& system) {
const Hockeyist& self = information.self;
const World& world = information.world;
const Game& game = information.game;
Move& move = information.move;
int selfId = self.getTeammateIndex();
Sector supportSector = system.getMovingSector(selfId);
if (system.isMovingSectorChoosed(selfId) == false) {
supportSector = getSupportSector(information, system);
system.setMovingSector(selfId, supportSector);
system.setMovingSectorChoosed(selfId, true);
}
moveQuickToSector(information, system, supportSector);
}
void TacticsHockeyists::mayBeContinueAttack(Information& information, AllSystem& system) {
const Hockeyist& self = information.self;
int selfId = self.getTeammateIndex();
Sector strikeSector = getStrikeSector(information, system);
double angleToStrikeSector = self.getAngleTo(strikeSector.x, strikeSector.y);
if (abs(angleToStrikeSector) < PI / 2) {
system.setHockeyistsInAttack(selfId, 0, true);
system.setHockeyistsInAttack(selfId, 0, true);
}
}