Skip to content

Commit

Permalink
格式化:进行格式化
Browse files Browse the repository at this point in the history
  • Loading branch information
hegugu-ng committed Jun 5, 2023
1 parent 8002785 commit 0a44fc7
Show file tree
Hide file tree
Showing 62 changed files with 667 additions and 350 deletions.
12 changes: 6 additions & 6 deletions gisim/Status/__init__.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
# from .FrozenEffect import *
from typing import cast

from gisim.classes.enums import CharPos, ElementType, PlayerID,StatusType
from gisim.status.base import CharacterStatusEntity,CombatStatusEntity
from gisim.classes.enums import CharPos, ElementType, PlayerID, StatusType
from gisim.env import INF_INT
from gisim.status.base import CharacterStatusEntity, CombatStatusEntity
from gisim.status.character_status import *
from gisim.status.reaction_status import *
from gisim.status.combat_status import get_combat_status_entity
from gisim.env import INF_INT
from gisim.status.reaction_status import *


def get_character_status_entity(
Expand All @@ -28,7 +28,7 @@ def get_character_status_entity(
remaining_round=remaining_round,
remaining_usage=remaining_usage,
element=element,
status_type=buff_type
status_type=buff_type,
)
status = cast(CharacterStatusEntity, status)
return status
Expand All @@ -39,6 +39,6 @@ def get_character_status_entity(
position=position,
remaining_round=remaining_round,
remaining_usage=remaining_usage,
status_type=buff_type
status_type=buff_type,
)
return status
7 changes: 4 additions & 3 deletions gisim/Status/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,15 @@
from typing import cast

from gisim.classes.entity import Entity
from gisim.classes.enums import CharPos, PlayerID,StatusType
from gisim.classes.enums import CharPos, PlayerID, StatusType


class CharacterStatusEntity(Entity, ABC):
"""Status which is attached to a fixed character.
Shown in the upper line of the character card. Will be calculated earlier."""

player_id: PlayerID
status_type:StatusType
status_type: StatusType
position: CharPos
name: str
description: str
Expand Down Expand Up @@ -45,4 +46,4 @@ def msg_handler(self, msg_queue: PriorityQueue):
...

def encode(self):
return OrderedDict(self.dict(exclude={"_uuid", "_logger"}))
return OrderedDict(self.dict(exclude={"_uuid", "_logger"}))
41 changes: 23 additions & 18 deletions gisim/Status/character_status/Hutao.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
from queue import PriorityQueue
from typing import cast

from gisim.classes.enums import *
from gisim.status import CharacterStatusEntity
from gisim.classes.message import DealDamageMsg, RoundEndMsg
from gisim.env import INF_INT
from typing import cast
from gisim.status import CharacterStatusEntity

from gisim.classes.message import DealDamageMsg,RoundEndMsg

class ParamitaPapilio(CharacterStatusEntity):
"""The character to which this is attached has their Physical DMG dealt converted to Pyro DMG,
"""The character to which this is attached has their Physical DMG dealt converted to Pyro DMG,
and they will deal +1 Pyro DMG.Some times can Apply [Blood Blossom].
Duration (Rounds): 2
"""

name: str = "Paramita Papilio"
element: ElementType = ElementType.PYRO
status_type: StatusType = StatusType.ATTACK_BUFF
Expand All @@ -27,12 +29,18 @@ def msg_handler(self, msg_queue: PriorityQueue):
if isinstance(top_msg, DealDamageMsg):
top_msg = cast(DealDamageMsg, top_msg)
if top_msg.attacker == (self.player_id, self.position):
for idx, (target_id, target_pos, element_type, dmg_val) in enumerate(top_msg.targets):
print(f" Character Status Effect:\n {self.name}:{self.description}\n Origin DMG: {element_type.name} -> {dmg_val} + Add: 1\n {self.player_id.name}-{self.position}\n")
for idx, (target_id, target_pos, element_type, dmg_val) in enumerate(
top_msg.targets
):
print(
f" Character Status Effect:\n {self.name}:{self.description}\n Origin DMG: {element_type.name} -> {dmg_val} + Add: 1\n {self.player_id.name}-{self.position}\n"
)
top_msg.targets[idx] = (
target_id,
target_pos,
self.element if element_type is ElementType.NONE else element_type,
self.element
if element_type is ElementType.NONE
else element_type,
dmg_val + 1,
)
updated = True
Expand All @@ -48,22 +56,20 @@ def msg_handler(self, msg_queue: PriorityQueue):
if updated:
msg_queue.queue[0].responded_entities.append(self._uuid)


return updated




class BloodBlossom(CharacterStatusEntity):
"""End Phase: Deal 1 Pyro DMG to the character to which this is attached.
"""End Phase: Deal 1 Pyro DMG to the character to which this is attached.
Usage(s): 1
"""

name: str = "Paramita Papilio"
element: ElementType = ElementType.PYRO
status_type: StatusType = StatusType.NEGATIVE_BUFF
description:str = """End Phase: Deal 1 Pyro DMG to the character to which this is attached. Usage(s): 1"""
value:int = 0
active:bool = True
description: str = """End Phase: Deal 1 Pyro DMG to the character to which this is attached. Usage(s): 1"""
value: int = 0
active: bool = True
remaining_round: int = 1
remaining_usage: int = 1

Expand All @@ -74,10 +80,10 @@ def msg_handler(self, msg_queue: PriorityQueue):
updated = False
if isinstance(top_msg, RoundEndMsg):
new_msg = DealDamageMsg(
sender_id= self.player_id,
sender_id=self.player_id,
attack_type=AttackType.COMBAT_STATUS,
attacker=(self.player_id,self.position),
targets=[(self.player_id,self.position,self.element,1)]
attacker=(self.player_id, self.position),
targets=[(self.player_id, self.position, self.element, 1)],
)
msg_queue.put(new_msg)
updated = True
Expand All @@ -88,5 +94,4 @@ def msg_handler(self, msg_queue: PriorityQueue):
if updated:
msg_queue.queue[0].responded_entities.append(self._uuid)


return updated
2 changes: 1 addition & 1 deletion gisim/Status/character_status/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
from .elemental_infusion import *
from .Hutao import *
from .Hutao import *
3 changes: 2 additions & 1 deletion gisim/Status/character_status/elemental_infusion.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ def msg_handler(self, msg_queue: PriorityQueue):
for idx, target in enumerate(top_msg.targets):
if target[2] == ElementType.NONE:
print(
f" Character Status Effect:\n {self.name}:{self.description}\n Origin DMG: {target[2]} -> {target[3]} + Add: 0\n {self.player_id.name}-{self.position}\n")
f" Character Status Effect:\n {self.name}:{self.description}\n Origin DMG: {target[2]} -> {target[3]} + Add: 0\n {self.player_id.name}-{self.position}\n"
)
top_msg.targets[idx] = (
target[0],
target[1],
Expand Down
26 changes: 15 additions & 11 deletions gisim/Status/combat_status/Xingqiu.py
Original file line number Diff line number Diff line change
@@ -1,32 +1,33 @@
from gisim.status.base import CombatStatusEntity
from queue import PriorityQueue
from gisim.classes.message import (
DealDamageMsg,
RoundEndMsg,
)
from typing import cast

from gisim.classes.enums import *
from gisim.classes.message import DealDamageMsg, RoundEndMsg
from gisim.env import INF_INT
from gisim.status.base import CombatStatusEntity


class RainSword(CombatStatusEntity):
"""[Combat Status]When your active character receives at least 3 DMG:
"""[Combat Status]When your active character receives at least 3 DMG:
Decrease DMG taken by 1.
Usage(s): 2
"""

name: str = "Rain Sword"
description: str = """When your active character receives at least 3 DMG: Decrease DMG taken by 1.Usage(s): 2"""
active: bool = True
value: int = 0
remaining_round: int = INF_INT
remaining_usage: int = 2

def msg_handler(self, msg_queue: PriorityQueue) -> bool:
top_msg = msg_queue.queue[0]
top_msg = msg_queue.queue[0]
if isinstance(top_msg, DealDamageMsg):
top_msg = cast(DealDamageMsg, top_msg)

for idx, (target_id, target_pos, element_type, dmg_val) in enumerate(top_msg.targets):
for idx, (target_id, target_pos, element_type, dmg_val) in enumerate(
top_msg.targets
):
if target_id == self.player_id:
top_msg.targets[idx] = (
target_id,
Expand All @@ -42,11 +43,14 @@ def msg_handler(self, msg_queue: PriorityQueue) -> bool:


class RainbowBladework(CombatStatusEntity):
"""[Combat Status]After your character uses a Normal Attack:
"""[Combat Status]After your character uses a Normal Attack:
Deal 1 Hydro DMG.
Usage(s): 3"""

name = "Rainbow Bladework"
description = "After your character uses a Normal Attack: Deal 1 Hydro DMG.Usage(s): 3"
description = (
"After your character uses a Normal Attack: Deal 1 Hydro DMG.Usage(s): 3"
)
active: bool = True
value: int = 0
remaining_round: int = INF_INT
Expand Down
10 changes: 4 additions & 6 deletions gisim/Status/combat_status/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,15 @@

from .Xingqiu import *


def get_combat_status_entity(
name: str,
player_id: PlayerID,
remaining_round: int,
remaining_usage: int = INF_INT
name: str, player_id: PlayerID, remaining_round: int, remaining_usage: int = INF_INT
):
stripped_name = name.replace(" ", "")
status_cls = globals()[stripped_name]
status: CombatStatusEntity = status_cls(
player_id=player_id,
remaining_round=remaining_round,
remaining_usage=remaining_usage
remaining_usage=remaining_usage,
)
return status
return status
2 changes: 1 addition & 1 deletion gisim/Status/reaction_status/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
from .frozen_effect import *
from .frozen_effect import *
21 changes: 15 additions & 6 deletions gisim/Status/reaction_status/frozen_effect.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,17 @@

class FrozenEffect(CharacterStatusEntity):
"""
[Character Status]the target is unable to perform any Actions this round
(Can be removed in advance after the target receives Physical or Pyro DMG,
[Character Status]the target is unable to perform any Actions this round
(Can be removed in advance after the target receives Physical or Pyro DMG,
in which case they will take +2 DMG)
"""

name: str = "Frozen Effect"
element: ElementType = ElementType.NONE
description: str = """[Character Status]the target is unable to perform any Actions this round(Can be removed in advance after the target receives Physical or Pyro DMG, in which case they will take +2 DMG)"""
value: int = 0
active: bool = True
status_type:StatusType = StatusType.UNDER_ATTACK_BUFF
status_type: StatusType = StatusType.UNDER_ATTACK_BUFF

def msg_handler(self, msg_queue: PriorityQueue):
top_msg = msg_queue.queue[0]
Expand All @@ -29,9 +30,17 @@ def msg_handler(self, msg_queue: PriorityQueue):
top_msg = cast(DealDamageMsg, top_msg)
if top_msg.damage_calculation_ended:
return False
for idx, (target_id, target_pos, element_type, dmg_val) in enumerate(top_msg.targets):
if target_id == self.player_id and target_pos == self.position and element_type in [ElementType.NONE, ElementType.PYRO]:
print(f" Character Status Effect:\n {self.name}:{self.description}\n Origin DMG: {element_type.name} -> {dmg_val} + Add: 2\n {self.player_id.name}-{self.position}\n")
for idx, (target_id, target_pos, element_type, dmg_val) in enumerate(
top_msg.targets
):
if (
target_id == self.player_id
and target_pos == self.position
and element_type in [ElementType.NONE, ElementType.PYRO]
):
print(
f" Character Status Effect:\n {self.name}:{self.description}\n Origin DMG: {element_type.name} -> {dmg_val} + Add: 2\n {self.player_id.name}-{self.position}\n"
)

top_msg.targets[idx] = (
target_id,
Expand Down
1 change: 1 addition & 0 deletions gisim/cards/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ class Card(BaseModel):
卡牌基类
~~~~~~~
"""

id: int
name: str
costs: Dict[ElementType, int]
Expand Down
14 changes: 9 additions & 5 deletions gisim/cards/characters/Anemo/Jean.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
"""Jean"""
from gisim.cards.characters.base import (CharacterCard, CharacterSkill,
GenericSkill)
from gisim.classes.enums import ElementType, Nation, SkillType, WeaponType
from gisim.cards.characters.base import CharacterCard, CharacterSkill, GenericSkill
from gisim.classes.enums import CharPos, ElementType, Nation, SkillType, WeaponType
from gisim.classes.summon import AttackSummon


Expand All @@ -10,6 +9,7 @@ class FavoniusBladework(GenericSkill):
Normal Attack: Favonius Bladework
Deals 2 Physical DMG.
"""

id: int = 15021
name: str = "Favonius Bladework"
text: str = """
Expand All @@ -25,6 +25,7 @@ class GaleBlade(GenericSkill):
"""Elemental Skill: Gale Blade
Deals 3 Anemo DMG, the target is forcibly switched to the next character.
"""

id: int = 15022
name: str = "Gale Blade"
text: str = """
Expand All @@ -35,20 +36,21 @@ class GaleBlade(GenericSkill):
damage_element: ElementType = ElementType.ANEMO
damage_value: int = 3
# TODO: forcibly switched to the next character
CharPos.ACTIVE


class DandelionBreeze(CharacterSkill):
"""Elemental Burst: Dandelion Breeze
Heals all your characters for 2 HP, summons 1 Dandelion Field.
"""

id: int = 15023
name: str = "Dandelion Breeze"
text: str = """
Heals all your characters for 2 HP, summons 1 Dandelion Field.
"""
type: SkillType = SkillType.ELEMENTAL_BURST
costs: dict[ElementType, int] = {
ElementType.ANEMO: 4, ElementType.POWER: 3}
costs: dict[ElementType, int] = {ElementType.ANEMO: 4, ElementType.POWER: 3}
heal_all_value: int = 2
summon_name: str = "Dandelion Field"

Expand All @@ -59,6 +61,7 @@ class DandelionField(AttackSummon):
End Phase: Deal 2 Anemo DMG, heal your active character for 1 HP.
Usage(s): 2
"""

name: str = "Dandelion Field"
damage_element: ElementType = ElementType.ANEMO
damage_value: int = 1
Expand All @@ -67,6 +70,7 @@ class DandelionField(AttackSummon):

class Jean(CharacterCard):
"""Jean"""

id: int = 1502
name: str = "Jean"
element_type: ElementType = ElementType.ANEMO
Expand Down
Loading

0 comments on commit 0a44fc7

Please sign in to comment.