diff options
author | hop311 <hop3114@gmail.com> | 2024-08-11 00:40:07 +0200 |
---|---|---|
committer | hop311 <hop3114@gmail.com> | 2024-08-14 00:07:46 +0200 |
commit | 7e05aaccf0e13299702ddeed17661831c3ddc692 (patch) | |
tree | b85022a240a4a24c0ee0fd44cd59ff6bc112c18f /src/openvic-simulation/misc/SongChance.cpp | |
parent | 9f9c5844bfedc5e366a35cdba386027fb9f3a14a (diff) |
Assorted minor fixes (clang-format.sh shebang, parse national foci scripts, factor song chance, update openvic-dataloader)assorted-fixes
Diffstat (limited to 'src/openvic-simulation/misc/SongChance.cpp')
-rw-r--r-- | src/openvic-simulation/misc/SongChance.cpp | 18 |
1 files changed, 8 insertions, 10 deletions
diff --git a/src/openvic-simulation/misc/SongChance.cpp b/src/openvic-simulation/misc/SongChance.cpp index 4a99362..94fb571 100644 --- a/src/openvic-simulation/misc/SongChance.cpp +++ b/src/openvic-simulation/misc/SongChance.cpp @@ -3,18 +3,16 @@ using namespace OpenVic; using namespace OpenVic::NodeTools; -SongChance::SongChance(size_t new_index, std::string_view new_filename, ConditionalWeight&& new_chance): -HasIdentifier { std::to_string(new_index) }, -file_name { new_filename }, -chance { std::move(new_chance) } -{} +SongChance::SongChance( + size_t new_index, std::string_view new_filename, ConditionalWeight&& new_chance +) : HasIdentifier { std::to_string(new_index) }, file_name { new_filename }, chance { std::move(new_chance) } {} bool SongChance::parse_scripts(DefinitionManager const& definition_manager) { return chance.parse_scripts(definition_manager); } bool SongChanceManager::load_songs_file(ast::NodeCPtr root) { - bool ret = true; + bool ret = true; ret &= expect_dictionary_reserve_length( song_chances, @@ -28,15 +26,15 @@ bool SongChanceManager::load_songs_file(ast::NodeCPtr root) { bool ret = expect_dictionary_keys( "name", ONE_EXACTLY, expect_string(assign_variable_callback(name)), - "chance", ONE_EXACTLY, chance.expect_conditional_weight(ConditionalWeight::BASE) + "chance", ONE_EXACTLY, chance.expect_conditional_weight(ConditionalWeight::FACTOR) )(value); - ret &= song_chances.add_item({song_chances.size(), name, std::move(chance) }); + ret &= song_chances.add_item({ song_chances.size(), name, std::move(chance) }); return ret; } )(root); - if(song_chances.size() == 0) { + if (song_chances.size() == 0) { Logger::error("No songs found in Songs.txt"); return false; } @@ -50,4 +48,4 @@ bool SongChanceManager::parse_scripts(DefinitionManager const& definition_manage ret &= songChance.parse_scripts(definition_manager); } return ret; -}
\ No newline at end of file +} |