nodes/constants.pyΒΆ

Part of Casual Crusade.

 1"""Casual Crusade: global constants.
 2
 3Mirrors `src/index.ts`, `src/card.ts` and the game's tunables.
 4Sizes are scaled up relative to the upstream 800x600 canvas so the cards are
 5comfortable to drag at 1280x720.
 6
 7The port lays everything out in a fixed 1280x720 design space: every rect below,
 8and every hit-test built from one, is in those coordinates and the window opens
 9at that size.
10"""
11
12from __future__ import annotations
13
14# Design resolution. All layout and hit-testing below is in these coordinates.
15WIDTH = 1280
16HEIGHT = 720
17
18# Board / tile
19TILE_WIDTH = 110
20TILE_HEIGHT = 80
21CARD_BORDER = 9
22CARD_GAP = 3
23
24# Hand
25HAND_SIZE = 3
26HAND_Y_OFFSET = 110  # distance below board origin
27
28# Colours (RGBA tuples 0..1)
29BG_COLOUR = (0.45, 0.74, 0.46, 1.0)  # #74be75
30GRASS_DARK = (0.357, 0.486, 0.357, 1.0)  # #5b7c5b
31GRASS_LIGHT = (0.687, 0.835, 0.580, 1.0)  # #afd594
32CARD_BG = (1.0, 1.0, 1.0, 1.0)
33CARD_HOVER = (1.0, 1.0, 0.40, 1.0)  # #ffff66
34CARD_VISITED = (1.0, 1.0, 0.667, 1.0)  # #ffffaa
35CARD_BORDER_COL = (0.0, 0.0, 0.0, 1.0)
36CHEST_BLACK = (0.0, 0.0, 0.0, 1.0)
37CHEST_GOLD = (0.953, 0.863, 0.0, 1.0)  # #F3DC00
38LIGHT_GREY_PANEL = (0.86, 0.86, 0.86, 1.0)
39DECK_BACK_COL = (0.310, 0.250, 0.455, 1.0)  # #4F4074 deep purple card-back
40DARK_TEXT = (0.10, 0.13, 0.10, 1.0)  # readable on the green board
41
42# Gem colours (matching upstream `src/gem.ts`)
43GEM_COLOURS = {
44    "b": (0.0, 0.741, 0.898, 1.0),  # blue   #00BDE5
45    "p": (0.518, 0.416, 0.757, 1.0),  # purple #846AC1
46    "r": (0.914, 0.224, 0.533, 1.0),  # red    #E93988
47    "y": (0.953, 0.863, 0.0, 1.0),  # yellow #F3DC00
48    "o": (0.973, 0.624, 0.0, 1.0),  # orange #F89F00
49    "g": (0.706, 0.816, 0.0, 1.0),  # green  #B4D000
50}
51
52GEM_NAMES = {
53    "b": ("FIBONACCI'S BOON", "Draw an extra card when placed"),
54    "p": ("PENANCE", "Recycles a random card when stepped on"),
55    "r": ("POPE'S BLESSING", "Heal one when placed"),
56    "y": ("INDULGENCE", "Score earned when stepped on is tenfold"),
57    "o": ("DYNASTY", "Doubles move scores when stepped on"),
58    "g": ("KHAN'S LEGACY", "Fills neighbours with blank cards"),
59}
60
61GEM_TYPES = ("b", "p", "r", "y", "o", "g")
62DIRECTIONS = ("u", "r", "d", "l")
63
64# (direction, grid dx, grid dy) for the four orthogonal neighbours of a cell.
65NEIGHBOURS = (("u", 0, -1), ("d", 0, 1), ("l", -1, 0), ("r", 1, 0))
66
67LEVEL_TITLES = (
68    "THE FOURTH CRUSADE",
69    "THE FIFTH CRUSADE",
70    "CRUSADE OF FREDERICK II",
71    "THE BARONS' CRUSADE",
72    "CRUSADE OF LOUIS IX",
73    "THE SHEPHERDS' CRUSADE",
74    "THE CRUSADE OF 1267",
75    "THE INFANTS OF ARAGON",
76    "THE EIGHTH CRUSADE",
77)
78
79WIN_TITLES = (
80    "LAND CONQUERED",
81    "MIGHTY RIGHTEOUS",
82    "SUCCESS",
83    "GREAT SUCCESS",
84    "RECONQUISTA",
85    "SIGNED BY THE CROSS",
86)
87
88# Drag/feel tunables
89DRAG_SPEED_LIMIT = 5400.0
90HAND_LERP_SPEED = 18.0
91
92
93def opposite(direction: str) -> str:
94    return {"u": "d", "d": "u", "l": "r", "r": "l"}[direction]