|
14 | 14 | import sys |
15 | 15 | import time |
16 | 16 | import warnings |
17 | | -from typing import List |
| 17 | +from typing import Any, List |
18 | 18 |
|
19 | 19 | import numpy as np |
20 | 20 | import tcod |
@@ -101,14 +101,14 @@ class TrueColorSample(Sample): |
101 | 101 | def __init__(self) -> None: |
102 | 102 | self.name = "True colors" |
103 | 103 | # corner colors |
104 | | - self.colors = np.array( |
| 104 | + self.colors: NDArray[np.int16] = np.array( |
105 | 105 | [(50, 40, 150), (240, 85, 5), (50, 35, 240), (10, 200, 130)], |
106 | 106 | dtype=np.int16, |
107 | 107 | ) |
108 | 108 | # color shift direction |
109 | | - self.slide_dir = np.array([[1, 1, 1], [-1, -1, 1], [1, -1, 1], [1, 1, -1]], dtype=np.int16) |
| 109 | + self.slide_dir: NDArray[np.int16] = np.array([[1, 1, 1], [-1, -1, 1], [1, -1, 1], [1, 1, -1]], dtype=np.int16) |
110 | 110 | # corner indexes |
111 | | - self.corners = np.array([0, 1, 2, 3]) |
| 111 | + self.corners: NDArray[np.int16] = np.array([0, 1, 2, 3], dtype=np.int16) |
112 | 112 |
|
113 | 113 | def on_draw(self) -> None: |
114 | 114 | self.slide_corner_colors() |
@@ -509,7 +509,7 @@ def ev_keydown(self, event: tcod.event.KeyDown) -> None: |
509 | 509 | "##############################################", |
510 | 510 | ] |
511 | 511 |
|
512 | | -SAMPLE_MAP = np.array([list(line) for line in SAMPLE_MAP_]).transpose() |
| 512 | +SAMPLE_MAP: NDArray[Any] = np.array([list(line) for line in SAMPLE_MAP_]).transpose() |
513 | 513 |
|
514 | 514 | FOV_ALGO_NAMES = [ |
515 | 515 | "BASIC ", |
@@ -545,17 +545,17 @@ def __init__(self) -> None: |
545 | 545 |
|
546 | 546 | map_shape = (SAMPLE_SCREEN_WIDTH, SAMPLE_SCREEN_HEIGHT) |
547 | 547 |
|
548 | | - self.walkable = np.zeros(map_shape, dtype=bool, order="F") |
| 548 | + self.walkable: NDArray[np.bool_] = np.zeros(map_shape, dtype=bool, order="F") |
549 | 549 | self.walkable[:] = SAMPLE_MAP[:] == " " |
550 | 550 |
|
551 | | - self.transparent = np.zeros(map_shape, dtype=bool, order="F") |
| 551 | + self.transparent: NDArray[np.bool_] = np.zeros(map_shape, dtype=bool, order="F") |
552 | 552 | self.transparent[:] = self.walkable[:] | (SAMPLE_MAP == "=") |
553 | 553 |
|
554 | 554 | # Lit background colors for the map. |
555 | | - self.light_map_bg = np.full(SAMPLE_MAP.shape, LIGHT_GROUND, dtype="3B") |
| 555 | + self.light_map_bg: NDArray[np.uint8] = np.full(SAMPLE_MAP.shape, LIGHT_GROUND, dtype="3B") |
556 | 556 | self.light_map_bg[SAMPLE_MAP[:] == "#"] = LIGHT_WALL |
557 | 557 | # Dark background colors for the map. |
558 | | - self.dark_map_bg = np.full(SAMPLE_MAP.shape, DARK_GROUND, dtype="3B") |
| 558 | + self.dark_map_bg: NDArray[np.uint8] = np.full(SAMPLE_MAP.shape, DARK_GROUND, dtype="3B") |
559 | 559 | self.dark_map_bg[SAMPLE_MAP[:] == "#"] = DARK_WALL |
560 | 560 |
|
561 | 561 | def draw_ui(self) -> None: |
@@ -948,7 +948,7 @@ class BSPSample(Sample): |
948 | 948 | def __init__(self) -> None: |
949 | 949 | self.name = "Bsp toolkit" |
950 | 950 | self.bsp = tcod.bsp.BSP(1, 1, SAMPLE_SCREEN_WIDTH - 1, SAMPLE_SCREEN_HEIGHT - 1) |
951 | | - self.bsp_map = np.zeros((SAMPLE_SCREEN_WIDTH, SAMPLE_SCREEN_HEIGHT), dtype=bool, order="F") |
| 951 | + self.bsp_map: NDArray[np.bool_] = np.zeros((SAMPLE_SCREEN_WIDTH, SAMPLE_SCREEN_HEIGHT), dtype=bool, order="F") |
952 | 952 | self.bsp_generate() |
953 | 953 |
|
954 | 954 | def bsp_generate(self) -> None: |
@@ -1214,7 +1214,7 @@ def ev_keydown(self, event: tcod.event.KeyDown) -> None: |
1214 | 1214 | # xc = [[1, 2, 3, 4], [1, 2, 3, 4], [1, 2, 3, 4]] |
1215 | 1215 | # yc = [[1, 1, 1, 1], [2, 2, 2, 2], [3, 3, 3, 3]] |
1216 | 1216 | if numpy_available: |
1217 | | - (xc, yc) = np.meshgrid(range(SCREEN_W), range(SCREEN_H)) # type: ignore |
| 1217 | + (xc, yc) = np.meshgrid(range(SCREEN_W), range(SCREEN_H)) |
1218 | 1218 | # translate coordinates of all pixels to center |
1219 | 1219 | xc = xc - HALF_W |
1220 | 1220 | yc = yc - HALF_H |
|
0 commit comments