diff --git a/src/c/weapon.c b/src/c/weapon.c index c3f5cfc..99c6fce 100644 --- a/src/c/weapon.c +++ b/src/c/weapon.c @@ -43,4 +43,9 @@ void setDamageModifier(Weapon *weapon, int modifierSet) int getBaseDamage(Weapon *weapon) { return weapon->baseDamage; +} + +void setBaseDamage(Weapon *weapon, int baseDmgSet) +{ + weapon->baseDamage = baseDmgSet; } \ No newline at end of file diff --git a/src/c/weapon.h b/src/c/weapon.h index 0e11197..4149a10 100644 --- a/src/c/weapon.h +++ b/src/c/weapon.h @@ -27,11 +27,12 @@ void setFullName(Weapon *weapon, char *fullNameToSet); int getTypeID(Weapon *weapon); void setTypeID(Weapon *weapon, int typeToSet); -//typeName placeholder +// typeName placeholder int getDamageModifier(Weapon *weapon); void setDamageModifier(Weapon *weapon, int modifierSet); int getBaseDamage(Weapon *weapon); +void setBaseDamage(Weapon *weapon, int baseDmgSet); #endif \ No newline at end of file diff --git a/test/c/test_weapon.c b/test/c/test_weapon.c index 4984557..241c481 100644 --- a/test/c/test_weapon.c +++ b/test/c/test_weapon.c @@ -169,4 +169,21 @@ void test_getBaseDamage(void) TEST_ASSERT_EQUAL(baseDamage, result); } +void test_setBaseDamage(void) +{ + // arrange + int baseDamage = 43, result; + + // act + Weapon test; + setBaseDamage(&test, baseDamage); + result = test.baseDamage; + + // output + printf("setBaseDamage | baseDamage set to: %d -> after set: %d", baseDamage, result); + + // assert + TEST_ASSERT_EQUAL(baseDamage, result); +} + #endif // TEST