diff --git a/src/c/weapon.c b/src/c/weapon.c index 8d34e27..a2f7add 100644 --- a/src/c/weapon.c +++ b/src/c/weapon.c @@ -33,4 +33,9 @@ void setTypeID(Weapon *weapon, int typeToSet) int getDamageModifier(Weapon *weapon) { return weapon->damageModifier; +} + +void setDamageModifier(Weapon *weapon, int modifierSet) +{ + weapon->damageModifier = modifierSet; } \ No newline at end of file diff --git a/src/c/weapon.h b/src/c/weapon.h index 4693398..ff6e1de 100644 --- a/src/c/weapon.h +++ b/src/c/weapon.h @@ -30,5 +30,6 @@ void setTypeID(Weapon *weapon, int typeToSet); //typeName placeholder int getDamageModifier(Weapon *weapon); +void setDamageModifier(Weapon *weapon, int modifierSet); #endif \ No newline at end of file diff --git a/test/c/test_weapon.c b/test/c/test_weapon.c index db8830e..56e0cb4 100644 --- a/test/c/test_weapon.c +++ b/test/c/test_weapon.c @@ -134,4 +134,21 @@ void test_getDamageModifier(void) TEST_ASSERT_EQUAL(damageModifier, result); } +void test_setDamageModifier(void) +{ + // arrange + int damageModifier = 5, result; + + // act + Weapon test; + setDamageModifier(&test, damageModifier); + result = test.damageModifier; + + // output + printf("setDamageModifier | damageModifier set to: %d -> after set: %d", damageModifier, result); + + // assert + TEST_ASSERT_EQUAL(damageModifier, result); +} + #endif // TEST