Skip to content

Commit

Permalink
fix: add ScriptConditionType for active game mode check (e.g. checkin…
Browse files Browse the repository at this point in the history
…g if ring heroes are enabled)
  • Loading branch information
DarkAtra committed Jan 26, 2022
1 parent 4c0a809 commit c50ab94
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,8 @@ enum class ScriptConditionType(
UNIT_HAS_TOGGLED_WEAPON(180u),
ANY_UNITS_USING_BLOODTHIRSTY(181u),
UNIT_USING_AUTO_PICKUP(182u),
UNIT_IN_ALT_FORMATION(183u);
UNIT_IN_ALT_FORMATION(183u),
IS_GAME_MODE_ACTIVE(201u);

companion object {
fun ofId(id: UInt): ScriptConditionType {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ internal class MapFileReaderTest {

private val bmfe1MapWithSkyboxSettings = MapFileReaderTest::class.java.getResourceAsStream("/maps/bfme1/skybox.map")!!
private val bmfe2rotwkMapWithScripts = MapFileReaderTest::class.java.getResourceAsStream("/maps/bfme2-rotwk/script.map")!!
private val bmfe2rotwkMapWithScriptsThatChecksForActiveGameModes = MapFileReaderTest::class.java.getResourceAsStream("/maps/bfme2-rotwk/map mp westmarch.zlib")!!

private val uncompressedMapPath = MapFileReaderTest::class.java.getResourceAsStream("/maps/bfme2-rotwk/Legendary War.txt")!!
private val refpackCompressedMapPath = MapFileReaderTest::class.java.getResourceAsStream("/maps/bfme2-rotwk/Legendary War.refpack")!!
Expand Down Expand Up @@ -63,6 +64,21 @@ internal class MapFileReaderTest {
assertThat(map.playerScripts!![0].scriptFolders[0].scripts[1].actionsIfFalse[0].enabled).isTrue
}

@Test
internal fun shouldReadBfme2MapWithScriptThatChecksForActiveGameModes() {

val map = MapFileReader().read(bmfe2rotwkMapWithScriptsThatChecksForActiveGameModes)

assertThat(map.playerScripts).isNotEmpty
assertThat(map.playerScripts!![2].scriptFolders).isNotEmpty
assertThat(map.playerScripts!![2].scriptFolders[0].name).isEqualTo("SkirmishGollum_Spawn")
assertThat(map.playerScripts!![2].scriptFolders[0].scripts).isNotEmpty
assertThat(map.playerScripts!![2].scriptFolders[0].scripts[0].name).isEqualTo("SkirmishGollum_PickSpawnPoint")
assertThat(map.playerScripts!![2].scriptFolders[0].scripts[0].orConditions).isNotEmpty
assertThat(map.playerScripts!![2].scriptFolders[0].scripts[0].orConditions[0].conditions).isNotEmpty
assertThat(map.playerScripts!![2].scriptFolders[0].scripts[0].orConditions[0].conditions[0].type).isEqualTo(ScriptConditionType.IS_GAME_MODE_ACTIVE)
}

@Test
internal fun shouldReadMap() {

Expand Down
Binary file not shown.

0 comments on commit c50ab94

Please sign in to comment.