diff --git a/src/c/weapon.c b/src/c/weapon.c index ddb66e8..a29d223 100644 --- a/src/c/weapon.c +++ b/src/c/weapon.c @@ -53,4 +53,9 @@ void setBaseDamage(Weapon *weapon, int baseDmgSet) bool getAvailable(Weapon *weapon) { return weapon->canBeUsed; +} + +void setAvailable(Weapon *weapon, bool availableSet) +{ + weapon->canBeUsed = availableSet; } \ No newline at end of file diff --git a/src/c/weapon.h b/src/c/weapon.h index cbc0661..d016ec9 100644 --- a/src/c/weapon.h +++ b/src/c/weapon.h @@ -36,6 +36,6 @@ int getBaseDamage(Weapon *weapon); void setBaseDamage(Weapon *weapon, int baseDmgSet); bool getAvailable(Weapon *weapon); - +void setAvailable(Weapon *weapon, bool availableSet); #endif \ No newline at end of file diff --git a/test/c/test_weapon.c b/test/c/test_weapon.c index 8f23f5b..609aa62 100644 --- a/test/c/test_weapon.c +++ b/test/c/test_weapon.c @@ -204,4 +204,21 @@ void test_getAvailable(void) TEST_ASSERT_EQUAL(canBeUsed, result); } +void test_setAvailable(void) +{ + // arrange + bool canBeUsed = false, result; + + // act + Weapon test; + setAvailable(&test, canBeUsed); + result = test.canBeUsed; + + // output + printf("setAvailable | canBeUsed set to: %d -> after set: %d", canBeUsed, result); + + // assert + TEST_ASSERT_EQUAL(canBeUsed, result); +} + #endif // TEST