Skip to content

Commit

Permalink
Fixed platformer levels appearing in the roulette
Browse files Browse the repository at this point in the history
  • Loading branch information
SpaghettDev committed Feb 6, 2024
1 parent 50c6600 commit 686e7ac
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 17 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/)
and this project adheres to [Semantic Versioning](http://semver.org/).

## [1.6.0-beta.4] - 2024-02-06

### Fixed

- Platformer levels appearing in the roulette

## [1.6.0-beta.3] - 2024-02-04

### Added
Expand Down
2 changes: 1 addition & 1 deletion mod.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"win": "2.204",
"android": "2.205"
},
"version": "v1.6.0-beta.3",
"version": "v1.6.0-beta.4",
"id": "spaghettdev.gd-roulette",
"name": "GD-Roulette",
"developer": "SpaghettDev",
Expand Down
29 changes: 13 additions & 16 deletions src/listfetcher/ListFetcher.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ void ListFetcher::getRandomNormalListLevel(int stars, matjson::Value& json, std:
if (stars > 10)
{
json = {};
error = "Invalid request given to the ListFetcher";
isFetching = false;
return;
}
Expand All @@ -32,24 +33,20 @@ void ListFetcher::getRandomNormalListLevel(int stars, matjson::Value& json, std:
.then([&, stars](auto const& fjson) {
json = fjson;

// TODO: support platformer levels
// Prevent auto levels from appearing in the Easy difficulty, and platformer levels because idk how this roulette would work with them lol!
// Prevent auto levels from appearing in the Easy difficulty, and platformer levels because this roulette doesn't work with them lol!
if (!json.is_null())
{
if (stars == 1)
{
matjson::Array& arr = json.as_array();

arr.erase(
std::remove_if(
arr.begin(), arr.end(),
[](const auto& level) {
return level.template get<std::string>("difficulty") == "Auto" || level.template get<bool>("platformer");
}
),
arr.end()
);
}
matjson::Array& arr = json.as_array();

arr.erase(
std::remove_if(
arr.begin(), arr.end(),
[=](const auto& level) {
return (stars == 1 ? level.template get<std::string>("difficulty") == "Auto" : false) || level.template get<bool>("platformer");
}
),
arr.end()
);

json = json[roulette::utils::randomInt(0, json.as_array().size() - 1)];
}
Expand Down

0 comments on commit 686e7ac

Please sign in to comment.