mirror of
https://github.com/HarbourMasters/SpaghettiKart
synced 2026-05-24 07:11:22 -04:00
956058a32d
* correct use of pointer and fix mistake * remove CM_WeirdLength * Update Game.cpp * Update Game.cpp --------- Co-authored-by: MegaMech <MegaMech@users.noreply.github.com>
47 lines
1022 B
C++
47 lines
1022 B
C++
#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);
|
|
}
|