Coverage report for gui


src/
File: src/parser/Player.hpp
Date: 2024-06-25 10:57:02
Lines:
7/7
100.0%
Functions:
3/3
100.0%
Branches:
22/45
48.9%

Line Branch Exec Source
1
2 #ifndef PLAYER_HPP
3 #define PLAYER_HPP
4
5 #include <vector>
6 #include <string>
7
8
9 enum Actions
10 {
11 EGGING,
12 PUSHED,
13 INCANTATING,
14 PICKUP,
15 DROP,
16 MOVING,
17 LVLUP,
18 NONE
19 };
20
21
22
5/10
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 5 taken 18 times.
✗ Branch 6 not taken.
✓ Branch 8 taken 18 times.
✗ Branch 9 not taken.
✓ Branch 12 taken 2 times.
✓ Branch 13 taken 8 times.
✓ Branch 15 taken 10 times.
✗ Branch 16 not taken.
38 class Event {
23 public:
24 std::vector<int> params;
25 Actions action;
26
27
8/16
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 2 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 2 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 2 times.
✗ Branch 11 not taken.
✓ Branch 13 taken 2 times.
✗ Branch 14 not taken.
✓ Branch 16 taken 2 times.
✗ Branch 17 not taken.
✓ Branch 19 taken 3 times.
✗ Branch 20 not taken.
✓ Branch 22 taken 3 times.
✗ Branch 23 not taken.
10 Event(Actions action, std::vector<int> params) : params(params), action(action) {};
28
4/7
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 3 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 3 times.
✗ Branch 8 not taken.
13 Event(Actions action) : params(std::vector<int>()), action(action) {};
29
1/4
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
27 ~Event() {};
30 };
31
32 enum Orientation
33 {
34 UP = 1,
35 RIGHT = 2,
36 DOWN = 3,
37 LEFT = 4
38 };
39
40 class Player
41 {
42 private:
43 std::vector<int> position = {0, 0};
44 std::vector<std::vector<int>> nextPositions = {};
45 int orientation = UP;
46
47 int lvl = 1;
48 int id = 0;
49 bool isAlive = true;
50 std::string team = "default";
51
52 std::vector<int> inventory = {0, 0, 0, 0, 0, 0, 0};
53 std::vector<Event> events = {};
54
55 void popNextPosition();
56
57 public:
58
2/4
✓ Branch 2 taken 18 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 18 times.
✗ Branch 6 not taken.
18 Player() {};
59
2/4
✓ Branch 2 taken 21 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 21 times.
✗ Branch 6 not taken.
21 Player(int id, std::vector<int> position, int orientation, int lvl, std::string team) : position(position), orientation(orientation), lvl(lvl), id(id), team(team) {};
60 72 ~Player() {};
61
62 void setPosition(std::vector<int> newPos);
63 void setOrientation(int newOrientation);
64 void setIncanting();
65 void setEgging();
66 void setPushed();
67 void setPickup(int res);
68 void setDrop(int res);
69 void setAlive(bool alive);
70 void setLvl(int newLvl);
71 void setTeam(std::string newTeam);
72 void setPlayerNb(int newId);
73 void setInventory(std::vector<int> inventoryVals);
74
75 std::vector<int> getInventory();
76 std::vector<int> getPosition();
77 int getOrientation();
78 int getPlayerNb();
79 int getLvl();
80 std::string getTeam();
81 Event getNextEvent();
82 bool getAlive();
83 };
84
85 #endif // PLAYER_HPP
86