-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathleague.cpp
More file actions
32 lines (28 loc) · 882 Bytes
/
league.cpp
File metadata and controls
32 lines (28 loc) · 882 Bytes
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
#include "league.hpp"
#include "command.hpp"
#include "bactery.hpp"
#include "interpreter.hpp"
League::League(Interpreter* parent, vector <Command> commands) : parent(parent), commands(commands) {
this->parent = parent;
this->commands = commands;
}
void League::addBactery(Bactery* bact) {
this->bacteries.push_back(bact);
}
void League::deleteBactery(Bactery *bact) {
auto it = this->bacteries.begin();
for (; *it != bact; it++);
this->bacteries.erase(it);
for (int i = 0; i < WORLD_SIZE; i++) {
for (int j = 0; j < WORLD_SIZE; j++) {
if (this->parent->getWorldItem(i, j) == bact) {
this->parent->setWorldItem(i, j, 0);
}
}
}
}
void League::steps() {
for (unsigned int i = 0; i < this->bacteries.size(); i++) {
this->commands[this->bacteries[i]->getLineNumber()].act(this->bacteries[i]);
}
}