Attack
src.model.attack
¶
Attack competence model.
An attack is an active competence that can damage a target when the target is within range. The model stores attack metadata, computes damage based on the effect-zone center, and triggers the associated visual effect through the animation manager.
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.
Attack
¶
Bases: Competence
Offensive competence that applies damage to a target.
The attack checks range before applying damage. Damage is strongest at the center of the effect zone and weaker on surrounding affected positions.
Attributes:
| Name | Type | Description |
|---|---|---|
target |
Unit | None
|
Optional target associated with the attack. |
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\attack.py
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 | |
target
property
writable
¶
Target associated with the attack, if one has been assigned.
Returns:
| Type | Description |
|---|---|
|
Unit | None: Stored target reference. |
Side Effects
Updates the stored target reference.
calcul_degat(target_position, center_position)
¶
Compute damage according to distance from the effect-zone center.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
target_position
|
Tuple[int, int]
|
Target position expressed as an |
required |
center_position
|
Tuple[int, int]
|
Center position of the effect zone as an |
required |
Returns:
| Name | Type | Description |
|---|---|---|
int |
int
|
Damage value computed for the target position. |
Source code in src\model\attack.py
activate(user, target, animation_manager)
¶
Apply the attack to a target when it is within range.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
user
|
Unit that owns or activates the competence. |
required | |
target
|
Target unit affected by an attack or 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.