-
Notifications
You must be signed in to change notification settings - Fork 4.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Fris0uman
committed
Aug 24, 2020
1 parent
c1230a7
commit 5d9e81c
Showing
5 changed files
with
148 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
[ | ||
{ | ||
"id": "test_bio_night", | ||
"type": "bionic", | ||
"name": { "str": "Artificial Night Generator" }, | ||
"description": "When active, this bionic eliminates all light within a 2 tile radius through destructive interference.", | ||
"occupied_bodyparts": [ [ "torso", 16 ] ], | ||
"flags": [ "BIONIC_TOGGLED" ], | ||
"enchantments": [ "TEST_ENCH" ], | ||
"act_cost": "9 kJ", | ||
"react_cost": "9 kJ", | ||
"time": 1 | ||
} | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
[ | ||
{ | ||
"type": "enchantment", | ||
"id": "TEST_ENCH", | ||
"condition": "ALWAYS", | ||
"emitter": "emit_shadow_field", | ||
"values": [ { "value": "STRENGTH", "multiply": 2, "add": 25 } ], | ||
"hit_me_effect": [ | ||
{ | ||
"id": "generic_blinding_spray_1", | ||
"hit_self": false, | ||
"message": "Your ink glands spray some ink into %2$s's eyes.", | ||
"npc_message": "%1$s's ink glands spay some ink into %2$s's eyes." | ||
} | ||
], | ||
"ench_effects": [ { "effect": "invisibility", "intensity": 1 } ] | ||
} | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
[ | ||
{ | ||
"type": "mutation", | ||
"id": "TEST_INK_GLANDS", | ||
"name": "Ink glands", | ||
"points": 1, | ||
"visibility": 1, | ||
"ugliness": 1, | ||
"description": "Several ink glands have grown onto your torso. They can be used to spray defensive ink and blind an attacker in an emergency, as long as the torso isn't covered.", | ||
"enchantments": [ "TEST_ENCH" ], | ||
"category": [ "CEPHALOPOD" ] | ||
} | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
#include "catch/catch.hpp" | ||
|
||
#include "avatar.h" | ||
#include "bionics.h" | ||
#include "character.h" | ||
#include "field.h" | ||
#include "map.h" | ||
#include "map_helpers.h" | ||
#include "monster.h" | ||
#include "mutation.h" | ||
#include "player_helpers.h" | ||
#include "item.h" | ||
|
||
|
||
|
||
static void test_generic_ench( avatar &p, int str_before ) | ||
{ | ||
// wait a turn for the effect to kick in | ||
p.process_turn(); | ||
|
||
CHECK( p.get_str() == str_before + p.get_str_base() * 2 + 25 ); | ||
|
||
CHECK( p.has_effect( efftype_id( "invisibility" ) ) ); | ||
|
||
const field &fields_here = get_map().field_at( p.pos() ); | ||
CHECK( fields_here.find_field( field_type_id( "fd_shadow" ) ) != nullptr ); | ||
|
||
// place a zombie next to the avatar | ||
const tripoint spot( 61, 60, 0 ); | ||
monster &zombie = spawn_test_monster( "mon_zombie", spot ); | ||
|
||
p.on_hit( &zombie, bodypart_id( "torso" ), 0.0, nullptr ); | ||
|
||
CHECK( zombie.has_effect( efftype_id( "blind" ) ) ); | ||
} | ||
|
||
TEST_CASE( "worn enchantments", "[enchantments][worn][items]" ) | ||
{ | ||
avatar p; | ||
clear_character( p ); | ||
|
||
int str_before = p.get_str(); | ||
|
||
// put on the ring | ||
item ring_strplus_one( "test_ring_strength_1" ); | ||
p.wear( ring_strplus_one ); | ||
|
||
// wait a turn for the effect to kick in | ||
p.recalculate_enchantment_cache(); | ||
p.process_turn(); | ||
|
||
CHECK( p.get_str() == str_before + 1 ); | ||
|
||
} | ||
|
||
TEST_CASE( "bionic enchantments", "[enchantments][bionics]" ) | ||
{ | ||
avatar p; | ||
clear_character( p ); | ||
|
||
int str_before = p.get_str(); | ||
|
||
p.set_max_power_level( 100_kJ ); | ||
p.set_power_level( 100_kJ ); | ||
|
||
give_and_activate_bionic( p, bionic_id( "test_bio_night" ) ); | ||
|
||
test_generic_ench( p, str_before ); | ||
} | ||
|
||
TEST_CASE( "mutation enchantments", "[enchantments][mutations]" ) | ||
{ | ||
avatar p; | ||
clear_character( p ); | ||
|
||
const trait_id test_ink( "TEST_INK_GLANDS" ); | ||
int str_before = p.get_str(); | ||
|
||
p.toggle_trait( test_ink ); | ||
REQUIRE( p.has_trait( test_ink ) ); | ||
|
||
p.recalculate_enchantment_cache(); | ||
|
||
test_generic_ench( p, str_before ); | ||
} |