Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
hegugu-ng committed Jun 26, 2023
2 parents 7bb1687 + 8a65953 commit 8e42b0b
Show file tree
Hide file tree
Showing 9 changed files with 23 additions and 9 deletions.
2 changes: 1 addition & 1 deletion gisim/cards/characters/Dendro/Tighnari.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
from typing import cast

from classes.message import DealDamageMsg, RoundEndMsg
from gisim.classes.status import CharacterStatusEntity
from env import INF_INT

from gisim.cards.characters.base import CharacterCard, CharacterSkill, GenericSkill
from gisim.classes.enums import ElementType, Nation, SkillType, WeaponType
from gisim.classes.status import CharacterStatusEntity
from gisim.classes.summon import AttackSummon


Expand Down
3 changes: 1 addition & 2 deletions gisim/cards/characters/Electro/RaidenShogun.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
from queue import PriorityQueue
from typing import TYPE_CHECKING, Dict, cast

from gisim.classes.status import CharacterStatusEntity

from gisim.cards.characters.base import CharacterCard, CharacterSkill, GenericSkill
from gisim.classes.enums import (
AttackType,
Expand All @@ -22,6 +20,7 @@
RoundEndMsg,
UseSkillMsg,
)
from gisim.classes.status import CharacterStatusEntity
from gisim.classes.summon import AttackSummon
from gisim.env import INF_INT

Expand Down
1 change: 1 addition & 0 deletions gisim/cards/characters/Hydro/Xingqiu.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
from gisim.classes.status import CombatStatusEntity
from gisim.classes.summon import AttackSummon, Summon
from gisim.env import INF_INT
from gisim.get_game_info import get_game_info


class GuhuaStyle(GenericSkill):
Expand Down
3 changes: 1 addition & 2 deletions gisim/cards/characters/Pyro/Hutao.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
from queue import PriorityQueue
from typing import TYPE_CHECKING, Dict, List, cast

from gisim.classes.status import CharacterStatusEntity

from gisim.cards.characters.base import CharacterCard, CharacterSkill, GenericSkill
from gisim.classes.enums import (
AttackType,
Expand All @@ -14,6 +12,7 @@
WeaponType,
)
from gisim.classes.message import DealDamageMsg, HealHpMsg, RoundEndMsg, UseSkillMsg
from gisim.classes.status import CharacterStatusEntity
from gisim.env import INF_INT

if TYPE_CHECKING:
Expand Down
8 changes: 7 additions & 1 deletion gisim/game.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,13 @@


class Game:
def __init__(
def __new__(cls):
"""Singleton Mode for global game info access"""
if not hasattr(cls, "instance"):
cls.instance = super(Game, cls).__new__(cls)
return cls.instance

def init_deck(
self, player1_deck: dict, player2_deck: dict, seed: Optional[int] = None
):
if seed is None:
Expand Down
5 changes: 5 additions & 0 deletions gisim/get_game_info.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
def get_game_info():
from gisim.game import Game

game = Game()
return game.encode_game_info()
3 changes: 2 additions & 1 deletion tests/test_element_reaction.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@
from gisim.classes.reaction import (
can_attachable,
element_reaction,
get_reaction_system,
get_reaction_system_by_type,
sum_element_reaction,
)
from gisim.elemental_reaction import get_reaction_system, get_reaction_system_by_type

# 获取反应体系 多元素反应

Expand Down
3 changes: 2 additions & 1 deletion tests/test_framework.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@
"characters": ["Kamisato Ayaka", "Kamisato Ayaka", "Kamisato Ayaka"],
"cards": [],
}
game = Game(player1_deck, player2_deck, seed=10)
game = Game()
game.init_deck(player1_deck, player2_deck, seed=10)
player1_agent = AttackOnlyAgent(PlayerID.PLAYER1)
player2_agent = NoAttackAgent(PlayerID.PLAYER2)
game_end = False
Expand Down
4 changes: 3 additions & 1 deletion tests/test_framework_with_reaction.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@
"characters": ["KamisatoAyaka", "Xingqiu", "Sucrose"],
"cards": [],
}
game = Game(player1_deck, player2_deck, seed=10)
game = Game()
game.init_deck(player1_deck=player1_deck, player2_deck=player1_deck, seed=10)

player1_agent = AttackOnlyAgent(PlayerID.PLAYER1)
player2_agent = AttackOnlyAgent(PlayerID.PLAYER2)
# player2_agent = NoAttackAgent(PlayerID.PLAYER2)
Expand Down

0 comments on commit 8e42b0b

Please sign in to comment.