Skip to content

Commit

Permalink
Merge pull request #218 from ChilliHugger/feature/217-game-difficulty…
Browse files Browse the repository at this point in the history
…-number-of-soldiers-should-affect-the-outcome-of-a-fight

#217 Armies affect outcome of fight
  • Loading branch information
IcemarkUK committed Nov 9, 2023
2 parents 35162d6 + 1499899 commit 0647908
Show file tree
Hide file tree
Showing 2 changed files with 108 additions and 1 deletion.
8 changes: 8 additions & 0 deletions main/midnight/src/tme/scenario/item_character.cpp
Expand Up @@ -974,6 +974,14 @@ namespace tme {
if ( followers >= 3 )
return false;
}

s32 total = warriors.total + riders.total ;
if ( mx->Difficulty() == DF_EASY && total >= 250 )
return false;

if ( mx->Difficulty() == DF_MEDIUM && total >= 750 )
return false;

return true;
}

Expand Down
101 changes: 100 additions & 1 deletion main/midnight/tests/revenge/tests/cmd_fight_tests.cpp
Expand Up @@ -51,6 +51,12 @@ string LordNeedstoFightNasty( const string& name, mxthing_t nasty)
return name;
}

void ThingHasZeroKillRate()
{
auto mock = GetMockThing(currentThing);
mock->mockData.properties["KillRate"] = "0";
}

SCENARIO("Lord fights a thing")
{
LPCSTR nasty_text[] = { "", "WOLVES","ICE TROLLS", "SKULKRIN", "DRAGONS" };
Expand Down Expand Up @@ -138,7 +144,7 @@ SCENARIO("Lord fights a nasty with no object and no army but leads others")
{
ShouldFightAndWillLose(lord);

THEN("the lord will be killed in hard")
THEN("the lord will be killed in hard and normal")
{
if ( mode == DF_HARD ) {
LordDead(lord);
Expand All @@ -151,3 +157,96 @@ SCENARIO("Lord fights a nasty with no object and no army but leads others")
}
}


SCENARIO("Lord fights a nasty with no object but armies")
{
LPCSTR mode_text[] = { "NORMAL", "EASY", "MEDIUM", "HARD", };
auto mode = GENERATE( DF_NORMAL, DF_EASY, DF_MEDIUM, DF_HARD );

GIVEN(StringExtensions::Format("Difficulty is %s", mode_text[mode]))
{
TMEStep::NewStory(RF_DEFAULT, mode);

auto lord = LordNeedstoFightNasty( TMEStep::ch_morkin, OB_DRAGONS );
ThingHasZeroKillRate();

AND_GIVEN("and has 249 soldiers")
{
GetCharacter(lord)->warriors.Total(100);
GetCharacter(lord)->riders.Total(149);

WHEN("lord fights thing")
{
ShouldFightAndWillLose(lord);

THEN("the lord will be killed")
{
LordDead(lord);
}
}
}

AND_GIVEN("and has 250 soldiers")
{
GetCharacter(lord)->warriors.Total(101);
GetCharacter(lord)->riders.Total(149);

WHEN("lord fights thing")
{
ShouldFightAndWillLose(lord);

THEN("the thing will be killed in easy")
{
if ( mode == DF_EASY ) {
ThingKilled();
}else{
LordDead(lord);
}
}
}
}

AND_GIVEN("and has 749 soldiers")
{
GetCharacter(lord)->warriors.Total(600);
GetCharacter(lord)->riders.Total(149);

WHEN("lord fights thing")
{
ShouldFightAndWillLose(lord);

THEN("the thing will be killed in easy")
{
if ( mode == DF_EASY ) {
ThingKilled();
}else{
LordDead(lord);
}
}
}
}

AND_GIVEN("and has 750 soldiers")
{
GetCharacter(lord)->warriors.Total(601);
GetCharacter(lord)->riders.Total(149);

WHEN("lord fights thing")
{
ShouldFightAndWillLose(lord);

THEN("the thing will be killed in easy and medium")
{
if ( mode == DF_EASY || mode == DF_MEDIUM) {
ThingKilled();
}else{
LordDead(lord);
}
}
}
}
}
}



0 comments on commit 0647908

Please sign in to comment.