mirror of
https://github.com/RichieCahill/dotfiles.git
synced 2026-04-17 04:58:19 -04:00
added load_cards and load_nobles
This commit is contained in:
@@ -3,12 +3,14 @@
|
|||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
import itertools
|
import itertools
|
||||||
|
import json
|
||||||
import random
|
import random
|
||||||
from dataclasses import dataclass, field
|
from dataclasses import dataclass, field
|
||||||
from typing import TYPE_CHECKING, Literal, Protocol
|
from typing import TYPE_CHECKING, Literal, Protocol
|
||||||
|
|
||||||
if TYPE_CHECKING:
|
if TYPE_CHECKING:
|
||||||
from collections.abc import Sequence
|
from collections.abc import Sequence
|
||||||
|
from pathlib import Path
|
||||||
|
|
||||||
GemColor = Literal["white", "blue", "green", "red", "black", "gold"]
|
GemColor = Literal["white", "blue", "green", "red", "black", "gold"]
|
||||||
|
|
||||||
@@ -602,6 +604,18 @@ def create_random_nobles() -> list[Noble]:
|
|||||||
return nobles
|
return nobles
|
||||||
|
|
||||||
|
|
||||||
|
def load_nobles(file: Path) -> list[Noble]:
|
||||||
|
"""Load nobles from a file."""
|
||||||
|
nobles = json.loads(file.read_text())
|
||||||
|
return [Noble(**noble) for noble in nobles]
|
||||||
|
|
||||||
|
|
||||||
|
def load_cards(file: Path) -> list[Card]:
|
||||||
|
"""Load cards from a file."""
|
||||||
|
cards = json.loads(file.read_text())
|
||||||
|
return [Card(**card) for card in cards]
|
||||||
|
|
||||||
|
|
||||||
def new_game(
|
def new_game(
|
||||||
strategies: Sequence[Strategy],
|
strategies: Sequence[Strategy],
|
||||||
config: GameConfig,
|
config: GameConfig,
|
||||||
|
|||||||
Reference in New Issue
Block a user