Skip to content

Commit

Permalink
try 5.1, not fix
Browse files Browse the repository at this point in the history
  • Loading branch information
flick-ai committed Aug 31, 2024
1 parent cc05431 commit 5e168f6
Show file tree
Hide file tree
Showing 37 changed files with 1,320 additions and 198 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,8 @@ A simulator of the Genius Invokation TCG in Genshin impact
- [ ] 完成了强化学习算法的实习和训练

## 版本更新说明
4.8版本:为所有内容维护了id信息编码。
5.0版本:增加特技效果的维护;优化切换角色的代码实现;新增了预览功能
4.8版本:为所有内容维护了id信息编码。
5.0版本:增加特技效果的维护;优化切换角色的代码实现;新增了预览功能


## 本地运行
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
from genius_invocation.utils import *
from genius_invocation.card.action.equipment.artifact.base import ArtifactCard
from genius_invocation.entity.status import Artifact
from typing import TYPE_CHECKING

if TYPE_CHECKING:
from genius_invocation.game.game import GeniusGame
from genius_invocation.game.player import GeniusPlayer


class ConductorsTopHatEntity(Artifact):
name: str = "Conductor's Top Hat"
name_ch = "指挥的礼帽"
id = 31203091
def __init__(self, game: 'GeniusGame', from_player: 'GeniusPlayer', from_character = None, artifact_card = None):
super().__init__(game, from_player, from_character, artifact_card)
self.round_usage = 1
self.is_excute = False

def on_change_character(self, game: 'GeniusGame'):
if game.current_switch.to_character == self.from_character:
if self.round_usage > 0:
self.is_excute = True
player = self.from_character.from_player
max_id = max_count_card(player.hand_zone.card)
player.hand_zone.discard_card(max_id)
num = self.from_player.dice_zone.num()
self.from_player.dice_zone.remove([num-2, num-1])
self.from_player.dice_zone.add([DiceType.OMNI for _ in range(2)])
self.round_usage -= 1

def on_calculate_dice(self, game: 'GeniusGame'):
if game.active_player_index == self.from_player.index:
if self.is_excute:
if game.current_dice.use_type in SkillType:
if self.round_usage > 0:
if game.current_dice.cost[0]['cost_num'] > 0:
game.current_dice.cost[0]['cost_num'] -= 1
return True
if len(game.current_dice.cost)>1:
if game.current_dice.cost[1]['cost_num'] > 0:
game.current_dice.cost[1]['cost_num'] -= 1
return True
if game.current_dice.use_type == ActionCardType.EQUIPMENT_TALENT:
if self.round_usage > 0:
if game.current_dice.cost[0]['cost_num'] > 0:
game.current_dice.cost[0]['cost_num'] -= 1
return True
if game.current_dice.cost[1]['cost_num'] > 0:
game.current_dice.cost[1]['cost_num'] -= 1
return True
return False

def on_use_skill(self, game: 'GeniusGame'):
if self.on_calculate_dice(game):
self.is_excute = False

def on_play_card(self, game: 'GeniusGame'):
if self.on_calculate_dice(game):
self.is_excute = False

def update_listener_list(self):
self.listeners = [
(EventType.ON_PLAY_CARD, ZoneType.CHARACTER_ZONE, self.on_change_character),
(EventType.ON_USE_SKILL, ZoneType.CHARACTER_ZONE, self.on_use_skill),
(EventType.CALCULATE_DICE, ZoneType.CHARACTER_ZONE, self.on_calculate_dice),
(EventType.AFTER_CHANGE_CHARACTER, ZoneType.CHARACTER_ZONE, self.on_change_character),
]


class ConductorsTopHat(ArtifactCard):
id: int = 312030
name: str = "Marechaussee Hunter"
name_ch = "指挥的礼帽"
time = 5.1
cost_num: int = 1
cost_type: CostType = CostType.WHITE

def __init__(self) -> None:
super().__init__()
self.artifact_entity = ConductorsTopHatEntity

def on_played(self, game: 'GeniusGame') -> None:
super().on_played(game)

Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
from genius_invocation.utils import *
from genius_invocation.card.action.equipment.specialskill.base import SpecialSkillCard
from genius_invocation.entity.status import SpecialSkill, Shield
from typing import TYPE_CHECKING

if TYPE_CHECKING:
from genius_invocation.game.game import GeniusGame
from genius_invocation.game.player import GeniusPlayer


class TepetlisaurusEntity(SpecialSkill):
name: str = "Tepetlisaurus"
name_ch = "特佩利龙"
id = "313004s1"
cost = [{'cost_num': 2, 'cost_type': CostType.BLACK}]
def __init__(self, game: 'GeniusGame', from_player: 'GeniusPlayer', from_character = None):
super().__init__(game, from_player, from_character)
self.usage = 2

def on_call(self, game: 'GeniusGame') -> None:
super().on_call(game)
self.from_player.get_card(num=2)
num = 0
for card in self.from_player.hand_zone.card:
card_name = card.name
if card_name not in self.from_player.card_zone.card_name:
num += 1
self.from_character.character_zone.add_entity(Shield(
game, self.from_player, self.from_character, usage=num,
))
game.manager.invoke(EventType.AFTER_USE_SPECIAL, game)



class Tepetlisaurus(SpecialSkillCard):
id: int = 313004
name: str = "Koholasaurus"
name_ch = "嵴锋龙"
time: float = 5.1
cost_num: int = 2
cost_type: CostType = CostType.WHITE

def __init__(self) -> None:
super().__init__()
self.equipment_entity = TepetlisaurusEntity

def on_played(self, game: 'GeniusGame') -> None:
super().on_played(game)
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def on_call(self, game: 'GeniusGame'):
def on_calculate_dice(self, game: 'GeniusGame'):
if game.active_player_index == self.from_player.index:
if game.current_dice.from_character == self.from_character:
if game.current_dice.use_type == SkillType.SPECIAL_SKILL:
if game.current_dice.use_type == SpecialSkillType.SPECIAL_SKILL:
if len(self.from_player.hand_zone.card) <= 2:
if game.current_dice.cost[0]['cost_num'] > 0:
game.current_dice.cost[0]['cost_num'] -= 1
Expand Down
10 changes: 9 additions & 1 deletion genius_invocation/card/action/equipment/talent/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,14 @@ class TalentCard(EquipmentCard):
cost: list[dict]
def __init__(self) -> None:
super().__init__()
self.from_character = None
for i in range(len(self.cost)):
self.cost[i]['cost_type'] = CostType(self.cost[i]['cost_type'])

def on_played(self, game: 'GeniusGame') -> None:
target_character = game.active_player.character_list[game.current_action.target_idx]
target_character.equip_talent(game, self.is_action, self)
self.from_character = target_character

def find_target(self, game: 'GeniusGame'):
if not self.is_action:
Expand All @@ -43,4 +45,10 @@ def count_cost(self):
if self.is_equip:
return sum([cost['cost_num'] for cost in self.cost])
else:
return 0
return 0

def on_destroy(self, game):
game.current_remove_from = self.from_character
game.manager.invoke(EventType.ON_EQUIP_REMOVE, game)
game.current_remove_from = None
self.from_character.character_zone.talent_card = None
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
from genius_invocation.card.action.equipment.talent.import_head import *
from genius_invocation.card.character.characters.AbyssLectorVioletLightning import *

class EngulfingStorm(TalentCard):
id: int = 224061
name: str = "Surging Undercurrent"
name_ch = "侵雷重闪"
time = 5.1
is_action = False
cost = [{'cost_num': 1, 'cost_type': CostType.ELECTRO.value}]
cost_power = 0
character = AbyssLectorVioletLightning
def __init__(self) -> None:
super().__init__()
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
from genius_invocation.card.action.equipment.talent.import_head import *
from genius_invocation.card.character.characters.Chiori import *

class InFiveColorsDyed(TalentCard):
id: int = 216091
name: str = "In Five Colors Dyed"
name_ch = "落染五色"
time = 5.1
is_action = True
cost = [{'cost_num': 3, 'cost_type': CostType.GEO.value}]
cost_power = 0
character = Chiori
def __init__(self) -> None:
super().__init__()
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
from genius_invocation.utils import *
from genius_invocation.card.action.equipment.weapon.base import WeaponCard
from typing import TYPE_CHECKING
from genius_invocation.entity.status import Weapon

if TYPE_CHECKING:
from genius_invocation.game.game import GeniusGame


class PortablePowerSawWeapon(Weapon):
id: int = 31130981
name: str = "Portable Power Saw"
name_ch = "便携动力锯"
def __init__(self, game: 'GeniusGame', from_player: 'GeniusPlayer', from_character = None, weapon_card = None):
super().__init__(game, from_player, from_character, weapon_card)
self.round_usage = 1
self.stoicssymbol = 0
self.add_damage = False

def on_damage_execute(self, game: 'GeniusGame'):
if self.round_usage <=0 :
return
if game.current_damage.damage_to == self.from_character:
if game.current_damage.main_damage_element == ElementType.PIERCING:
return
if game.current_damage.main_damage > 0:
max_id = max_count_card()
if max_id == None:
return
else:
game.current_damage.main_damage -= 1
self.stoicssymbol += 1
self.round_usage -= 1

def on_add_damage(self, game:'GeniusGame'):
if self.add_damage:
game.current_damage.main_damage += 1
self.add_damage = False

def after_use_skill(self, game: 'GeniusGame'):
if self.add_damage:
self.add_damage = False

def on_use_skill(self, game: 'GeniusGame'):
if game.current_skill.from_character == self.from_character:
if self.stoicssymbol > 0:
self.add_damage = True
self.from_player.get_card(num=self.stoicssymbol)
self.stoicssymbol = 0

def update_listener_list(self):
self.listeners = [
(EventType.FINAL_EXECUTE, ZoneType.CHARACTER_ZONE, self.on_damage_execute),
(EventType.DAMAGE_ADD, ZoneType.CHARACTER_ZONE, self.on_add_damage),
(EventType.AFTER_USE_SKILL, ZoneType.CHARACTER_ZONE, self.after_use_skill),
(EventType.ON_USE_SKILL, ZoneType.CHARACTER_ZONE, self.on_use_skill)
]


class PortablePowerSaw(WeaponCard):
id: int = 311309
name: str = "Portable Power Saw"
name_ch = "便携动力锯"
time = 5.1
weapon_type: WeaponType = WeaponType.CLAYMORE
cost_num: int = 2
cost_type: CostType = CostType.WHITE

def __init__(self) -> None:
super().__init__()
self.equipment_entity = PortablePowerSawWeapon

def on_played(self, game: 'GeniusGame') -> None:
super().on_played(game)
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ def on_damage_execute(self, game: 'GeniusGame'):
return
else:
game.current_damage.main_damage -= 1
self.solidarity += 1
self.round_usage -= 1

def on_add_damage(self, game:'GeniusGame'):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,13 @@ def __init__(self) -> None:
self.now_phase: GamePhase

def on_played(self, game: 'GeniusGame'):
game.active_player.get_card(num=1)
self.now_phase = game.game_phase
game.game_phase = GamePhase.SET_CARD
game.special_phase = self
game.active_player.get_card(num=1)


def on_finished(self, game: 'GeniusGame'):
game.game_phase = self.now_phase
game.special_phase = None
game.special_phase = None
game.resolve_action(None)
1 change: 1 addition & 0 deletions genius_invocation/card/action/event/events/Blessing.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ def on_finished(self, game: 'GeniusGame'):

game.game_phase = self.now_phase
game.special_phase = None
game.resolve_action(None)

def find_target(self, game:'GeniusGame'):
target = []
Expand Down
Loading

0 comments on commit 5e168f6

Please sign in to comment.