Player Action and Instruction

from dgisim import PlayerAction, Instruction
  • PlayerAction is any action that can be taken by a player in the game.

  • Instruction is the additional information added in player actions to specify how an action should be performed.

class PlayerAction
class Instruction(*, dice: 'ActualDice')
dice: ActualDice

dice to be paid.

class CardAction(*, card: type[Card], instruction: Instruction)

Bases: GameAction

Used to play a card.

card: type[Card]

type of card to be used.

instruction: Instruction

detailed instruction on how the card should be used.

class CardsSelectAction(*, selected_cards: 'Cards')

Bases: PlayerAction

selected_cards: Cards

cards selected.

class CharacterSelectAction(*, char_id: 'int')

Bases: PlayerAction

char_id: int

selected character’s id.

class DeathSwapAction(*, char_id: int)

Bases: GameAction

Used when active character is defeated and requires swapping.

char_id: int

target character’s id.

class DiceOnlyInstruction(*, dice: ActualDice)

Bases: Instruction

An instruction that only contains dice.

class DiceSelectAction(*, selected_dice: 'ActualDice')

Bases: PlayerAction

selected_dice: ActualDice

dice selected.

class ElementalTuningAction(*, card: type[Card], dice_elem: Element)

Bases: GameAction

Used tune an elemental die.

card: type[Card]

type of card to be used for tuning.

dice_elem: Element

the element of die to be tuned.

class EndRoundAction

Bases: PlayerAction

class GameAction

Bases: PlayerAction

A superclass for actions that are mainly performed in action phase.

class SkillAction(*, skill: CharacterSkill, instruction: DiceOnlyInstruction)

Bases: GameAction

Used to cast the skill of the active character.

instruction: DiceOnlyInstruction

instruction on which dice to be paid for the skill.

skill: CharacterSkill

type of skill to cast (by the active character).

class SourceTargetInstruction(*, dice: ActualDice, source: StaticTarget, target: StaticTarget)

Bases: Instruction

An instruction that can choose two targets.

source: StaticTarget

source target.

target: StaticTarget

target target.

class StaticTargetInstruction(*, dice: ActualDice, target: StaticTarget)

Bases: Instruction

An instruction that can choose a single target.

target: StaticTarget

the target selected.

class SwapAction(*, char_id: int, instruction: DiceOnlyInstruction)

Bases: GameAction

Used when normal character swap is performed.

char_id: int

target character’s id.

instruction: DiceOnlyInstruction

instruction on which dice to be paid for the skill.

All classes above are frozen dataclass that is key_word only. This means in order to initialize any of these, you need to specify all key words:

from dgisim import ActualDice, CardAction, Element, Pid, StaticTarget, StaticTargetInstruction
from dgisim.card import SendOff
from dgisim.summon import OceanicMimicFrogSummon

# just an example of using SendOff on OceanicMimicFrog (summon)
card_action = CardAction(
    card=SendOff,
    instruction=StaticTargetInstruction(
        dice=ActualDice({Element.ELECTRO: 1, Element.ANEMO: 1}),
        target=StaticTarget.from_summon(Pid.P2, OceanicMimicFrogSummon),
    ),
)