-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: implement small eleental artifacts
add card target select in request. fix bug in match.start with skills. add position and id when creating DamageValue. support equip and remove artifact. fix bug in DiceCostValue initilalization.
- Loading branch information
Showing
15 changed files
with
365 additions
and
63 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
from .version_3_3 import SmallElementalArtifact | ||
|
||
Artifacts = SmallElementalArtifact | SmallElementalArtifact |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
from typing import Literal, List, Any | ||
|
||
from server.struct import ObjectPosition | ||
from ....object_base import CardBase | ||
from ....struct import DiceCost | ||
from ....consts import ObjectType, DiceCostLabels, ObjectPositionType | ||
from ....action import MoveObjectAction, RemoveObjectAction | ||
from ....struct import CardActionTarget | ||
|
||
|
||
class ArtifactBase(CardBase): | ||
""" | ||
Base class of artifacts. | ||
""" | ||
name: str | ||
type: Literal[ObjectType.ARTIFACT] = ObjectType.ARTIFACT | ||
cost_label: int = DiceCostLabels.CARD.value | DiceCostLabels.ARTIFACT.value | ||
|
||
version: str | ||
cost: DiceCost | ||
usage: int | ||
|
||
def act(self): | ||
""" | ||
when this support card is activated from hand, this function is called | ||
to update the status. | ||
""" | ||
raise NotImplementedError() | ||
|
||
def get_targets(self, match: Any) -> List[CardActionTarget]: | ||
# can quip on all self alive charactors | ||
ret: List[CardActionTarget] = [] | ||
for charactor in match.player_tables[ | ||
self.position.player_id].charactors: | ||
if charactor.is_alive: | ||
ret.append(CardActionTarget( | ||
target_position = charactor.position.copy(deep = True), | ||
target_id = charactor.id, | ||
)) | ||
return ret | ||
|
||
def get_actions( | ||
self, target: CardActionTarget | None, match: Any | ||
) -> List[MoveObjectAction | RemoveObjectAction]: | ||
""" | ||
Act the artifact. will place it into artifact area. | ||
TODO: when artifact is equipped, remove the old one. | ||
""" | ||
assert target is not None | ||
ret: List[MoveObjectAction | RemoveObjectAction] = [] | ||
position = target.target_position | ||
id = target.target_id | ||
assert position.area == ObjectPositionType.CHARACTOR | ||
assert position.player_id == self.position.player_id | ||
charactors = match.player_tables[position.player_id].charactors | ||
for charactor in charactors: | ||
if charactor.id == id: | ||
# check if need to remove current artifact | ||
if charactor.artifact is not None: | ||
ret.append(RemoveObjectAction( | ||
object_position = charactor.artifact.position, | ||
object_id = charactor.artifact.id, | ||
)) | ||
ret.append(MoveObjectAction( | ||
object_position = self.position, | ||
object_id = self.id, | ||
target_position = position.copy(), | ||
)) | ||
return ret |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
from typing import Literal | ||
from .base import ArtifactBase | ||
from ....struct import DiceCost | ||
from ....modifiable_values import DiceCostValue | ||
from ....consts import ElementType, ObjectPositionType, DiceCostLabels | ||
from ....event import RoundPrepareEventArguments | ||
from ....action import ActionBase | ||
|
||
|
||
class SmallElementalArtifact(ArtifactBase): | ||
""" | ||
Seven artifacts that decrease elemental cost. | ||
""" | ||
|
||
name: Literal[ | ||
"Broken Rime's Echo", # cryo | ||
"Laurel Coronet", # dendro | ||
"Mask of Solitude Basalt", # geo | ||
"Thunder Summoner's Crown", # electro | ||
"Viridescent Venerer's Diadem", # anemo | ||
"Wine-Stained Tricorne", # hydro | ||
"Witch's Scorching Hat", # pyro | ||
] | ||
|
||
version: Literal["4.0"] = "4.0" | ||
usage: int = 1 | ||
cost: DiceCost = DiceCost(any_dice_number=2) | ||
element: ElementType = ElementType.NONE | ||
|
||
def __init__(self, *argv, **kwargs): | ||
super().__init__(*argv, **kwargs) | ||
if self.name == "Broken Rime's Echo": | ||
self.element = ElementType.CRYO | ||
elif self.name == "Laurel Coronet": | ||
self.element = ElementType.DENDRO | ||
elif self.name == "Mask of Solitude Basalt": | ||
self.element = ElementType.GEO | ||
elif self.name == "Thunder Summoner's Crown": | ||
self.element = ElementType.ELECTRO | ||
elif self.name == "Viridescent Venerer's Diadem": | ||
self.element = ElementType.ANEMO | ||
elif self.name == "Wine-Stained Tricorne": | ||
self.element = ElementType.HYDRO | ||
elif self.name == "Witch's Scorching Hat": | ||
self.element = ElementType.PYRO | ||
|
||
def event_handler_ROUND_PREPARE(self, event: RoundPrepareEventArguments) \ | ||
-> list[ActionBase]: | ||
""" | ||
When in round prepare, reset usage | ||
""" | ||
self.usage = 1 | ||
return [] | ||
|
||
def act(self): | ||
""" | ||
When activated, reset usage | ||
""" | ||
self.usage = 1 | ||
|
||
def value_modifier_DICE_COST( | ||
self, | ||
value: DiceCostValue, | ||
mode: Literal['TEST', 'REAL'], | ||
) -> DiceCostValue: | ||
""" | ||
When charactor equipped with this artifact and used skill, decrease | ||
the elemental cost by 1. If element not match, decrease any dice cost | ||
by 1. | ||
""" | ||
if ( | ||
self.usage > 0 | ||
and self.position.area == ObjectPositionType.CHARACTOR | ||
): # has usage and equipped | ||
label = value.cost.label | ||
if label & ( | ||
DiceCostLabels.NORMAL_ATTACK.value | ||
| DiceCostLabels.ELEMENTAL_SKILL.value | ||
| DiceCostLabels.ELEMENTAL_BURST.value | ||
) == 0: # no label match | ||
return value | ||
position = value.position | ||
if position.area != ObjectPositionType.CHARACTOR: | ||
# cost not from charactor | ||
return value | ||
assert self.position.charactor_id != -1 | ||
if position.charactor_id != self.position.charactor_id: | ||
# not same charactor | ||
return value | ||
# can decrease cost | ||
used = 0 | ||
if (value.cost.elemental_dice_color == self.element | ||
and value.cost.elemental_dice_number > 0): | ||
value.cost.elemental_dice_number -= 1 | ||
used += 1 | ||
elif value.cost.any_dice_number > 0: | ||
value.cost.any_dice_number -= 1 | ||
used += 1 | ||
if mode == 'REAL': | ||
self.usage -= used | ||
return value |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.