Coverage report for ai


src/
File: src/ressources/Ressources.cpp
Date: 2024-06-25 10:57:00
Lines:
27/27
100.0%
Functions:
4/4
100.0%
Branches:
13/22
59.1%

Line Branch Exec Source
1 /*
2 ** EPITECH PROJECT, 2024
3 ** zappy/ai
4 ** File description:
5 ** Ressources.cpp
6 */
7
8 #include "Ressources.hpp"
9
10
1/2
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
10 Ressources::Ressources()
11 {
12
1/2
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
20 ressourcesMap["food"] = &food;
13
1/2
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
20 ressourcesMap["linemate"] = &linemate;
14
1/2
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
20 ressourcesMap["deraumere"] = &deraumere;
15
1/2
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
20 ressourcesMap["sibur"] = &sibur;
16
1/2
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
20 ressourcesMap["mendiane"] = &mendiane;
17
1/2
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
20 ressourcesMap["phiras"] = &phiras;
18
1/2
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
20 ressourcesMap["thystame"] = &thystame;
19
1/2
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
20 ressourcesMap["player"] = &player;
20
21 10 food = 0;
22 10 linemate = 0;
23 10 deraumere = 0;
24 10 sibur = 0;
25 10 mendiane = 0;
26 10 phiras = 0;
27 10 thystame = 0;
28 10 player = 0;
29 10 }
30
31 16 Ressources::~Ressources()
32 {
33 16 }
34
35 4 void Ressources::addRessource(std::string ressource)
36 {
37 auto it = ressourcesMap.find(ressource);
38
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 1 times.
4 if (it != ressourcesMap.end())
39 {
40 3 (*(it->second))++;
41 }
42 4 }
43
44 5 int Ressources::getRessource(const std::string &ressource) const
45 {
46 auto it = ressourcesMap.find(ressource);
47
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 1 times.
5 if (it != ressourcesMap.end())
48 {
49 4 return *(it->second);
50 }
51 return 0;
52 }
53