summaryrefslogtreecommitdiff
path: root/src/engine/Cup.cpp
blob: 36e1927234a0e8a5b06642c30a09841fa0a3d8aa (plain)
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
#include "Cup.h"
#include "courses/Course.h"

Cup::Cup(std::string id, const char* name, std::vector<std::shared_ptr<Course>> courses) {
    Id = id;
    Name = name;
    Courses = courses;

    if (Courses.size() != 4) {
        throw std::invalid_argument("A cup must contain exactly 4 courses.");
    }
}

void Cup::Next() {
    if (CursorPosition < Courses.size() - 1) {
        CursorPosition++;
    }
}

void Cup::Previous() {
    if (CursorPosition > 0) {
        CursorPosition--;
    }
}

void Cup::SetCourse(size_t position) {
    if ((position < 0) || (position >= Courses.size())) {
        throw std::invalid_argument("Invalid course index.");
    }
    CursorPosition = position;
}

std::shared_ptr<Course> Cup::GetCourse() {
    return Courses[CursorPosition];
}

size_t Cup::GetSize() {
    return Courses.size();
}

// Function to shuffle the courses randomly
void Cup::ShuffleCourses() {
    // std::random_device rd;
    // std::mt19937 g(rd());
    //std::shuffle(Courses.begin(), Courses.end(), g);
}