Skip to content

Commit

Permalink
Add 'Delay Advancements [modification]
Browse files Browse the repository at this point in the history
Depsite being a [modification] this is actuall implemented
in the C++ code the [modification] just sets a flag.

This is meant as an alterntive to the preset advancement
type of mod, i want to play around with it a bit in 1.15
maybe we will remove it later.

The problbme this is supposed to fix is that advancemnts
are done randomly during the enemeies turn. It has a few
advantages over the preset advancemnt approach:
1) It can easily handle amlas and normal advancement
2) It doesn't need special code to handle the case that
   A unit advances multiple times.
3) It doesn't break in case that other wml code changed
   The advancements  of a unit after the preselected advancement was chosen
4) The user never needs to think about an advancement of
   a unit that might not even advance

It also has a disadvantage: it changes the rules of the
game quite a bit, in partiucar if the units heals form
an adcancement (which us usally the case), since now
with this 'healing the unit on advancement by retaliation'
during the enemies turn can no longer happen. I still
think its wirth to think about this and test it though.
  • Loading branch information
gfgtdf authored and Pentarctagon committed Oct 9, 2020
1 parent af344d2 commit f599c77
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 1 deletion.
1 change: 1 addition & 0 deletions data/_main.cfg
Expand Up @@ -37,6 +37,7 @@

{campaigns/}

{modifications.cfg}
[ais]
default_ai_algorithm=ai_default_rca
[default_config]
Expand Down
5 changes: 5 additions & 0 deletions data/modifications.cfg
@@ -0,0 +1,5 @@
[modification]
id = "delay_advancements"
name = _ "Delay Advancements"
type = "hybrid"
[/modification]
11 changes: 11 additions & 0 deletions src/play_controller.cpp
Expand Up @@ -20,6 +20,7 @@

#include "play_controller.hpp"

#include "actions/advancement.hpp"
#include "actions/create.hpp"
#include "actions/heal.hpp"
#include "actions/undo.hpp"
Expand Down Expand Up @@ -528,6 +529,16 @@ void play_controller::do_init_side()

// Make sure vision is accurate.
actions::clear_shroud(current_side(), true);
{
const auto& active_mods = get_saved_game().classification().active_mods;
bool delay_advancements = std::find(active_mods.begin(), active_mods.end(), "delay_advancements") != active_mods.end();

for(unit &u : resources::gameboard->units()) {
if(u.side() == current_side()) {
advance_unit_at(u.get_location());
}
}
}
init_side_end();
check_victory();
sync.do_final_checkup();
Expand Down
15 changes: 14 additions & 1 deletion src/units/helper.cpp
Expand Up @@ -20,6 +20,9 @@
#include "units/unit.hpp"
#include "units/helper.hpp"
#include "units/types.hpp"
#include "resources.hpp"
#include "play_controller.hpp"
#include "saved_game.hpp"

namespace unit_helper {

Expand All @@ -30,7 +33,17 @@ int number_of_possible_advances(const unit &u)

bool will_certainly_advance(const unit_map::iterator &u)
{
return u.valid() && u->advances() && number_of_possible_advances(*u) > 0;
if(!u.valid()) {
return false;
}
if(resources::controller) {
const auto& active_mods = resources::controller->get_saved_game().classification().active_mods;
bool delay_advancements = std::find(active_mods.begin(), active_mods.end(), "delay_advancements") != active_mods.end();
if(delay_advancements && resources::controller->current_side() != u->side()) {
return false;
}
}
return u->advances() && number_of_possible_advances(*u) > 0;
}

std::string resistance_color(const int resistance)
Expand Down

0 comments on commit f599c77

Please sign in to comment.