Defense
src.model.defense
¶
Defense competence model.
A defense is an active competence that reduces incoming damage by a percentage stored in its power value. It also triggers the corresponding defensive visual effect when one is available for the unit.
The documentation follows Google-style docstrings so tools such as pdoc, Sphinx Napoleon, or MkDocs-based pipelines can expose parameters, return values, and side effects in a consistent HTML API reference.
Defense
¶
Bases: Competence
Defensive competence that reduces incoming damage.
The defense interprets its power as a percentage reduction and can trigger a visual effect on the protected unit.
Attributes:
| Name | Type | Description |
|---|---|---|
power |
int
|
Percentage reduction applied to incoming damage. |
Notes
This class is documented as part of the public project API and is intended to be readable in generated HTML documentation.
Source code in src\model\defense.py
reduce_damage(damage, animation_manager, user)
¶
Reduce an incoming damage value and trigger the defense effect.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
damage
|
Incoming damage value to transform or apply. |
required | |
animation_manager
|
AnimationManager coordinating unit animations and effects. |
required | |
user
|
Unit that owns or activates the competence. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
object |
Value produced by the underlying game or rendering operation. |
Side Effects
Triggers defensive feedback and returns the reduced damage value.
Source code in src\model\defense.py
activate(user, animation_manager)
¶
Trigger the defense activation feedback for the protected unit.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
user
|
Unit
|
Unit that owns or activates the competence. |
required |
animation_manager
|
AnimationManager coordinating unit animations and effects. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
None |
This method is executed for its side effects. |
Side Effects
Applies gameplay effects defined by the concrete competence.
Notes
Concrete subclasses define whether activation changes health, damage, or visual effects.