mima-engine 0.1.5__py3-none-any.whl → 0.2.1__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of mima-engine might be problematic. Click here for more details.

Files changed (80) hide show
  1. mima/__init__.py +1 -1
  2. mima/backend/pygame_assets.py +14 -8
  3. mima/backend/pygame_audio.py +5 -2
  4. mima/backend/pygame_backend.py +255 -57
  5. mima/backend/pygame_camera.py +63 -0
  6. mima/backend/pygame_events.py +369 -120
  7. mima/collision.py +182 -111
  8. mima/engine.py +155 -15
  9. mima/maps/tiled/tiled_map.py +3 -3
  10. mima/maps/tiled/tiled_tileset.py +1 -0
  11. mima/maps/tilemap.py +78 -15
  12. mima/maps/tileset.py +8 -2
  13. mima/maps/transition_map.py +6 -8
  14. mima/mode_engine.py +80 -0
  15. mima/objects/animated_sprite.py +23 -15
  16. mima/objects/attributes.py +3 -0
  17. mima/objects/creature.py +54 -17
  18. mima/objects/dynamic.py +30 -8
  19. mima/objects/effects/colorize_screen.py +22 -6
  20. mima/objects/effects/debug_box.py +124 -0
  21. mima/objects/effects/light.py +21 -30
  22. mima/objects/effects/show_sprite.py +39 -0
  23. mima/objects/effects/walking_on_grass.py +25 -7
  24. mima/objects/effects/walking_on_water.py +17 -6
  25. mima/objects/loader.py +24 -13
  26. mima/objects/projectile.py +21 -6
  27. mima/objects/sprite.py +7 -8
  28. mima/objects/world/color_gate.py +5 -2
  29. mima/objects/world/color_switch.py +12 -6
  30. mima/objects/world/container.py +17 -8
  31. mima/objects/world/floor_switch.py +8 -4
  32. mima/objects/world/gate.py +8 -5
  33. mima/objects/world/light_source.py +11 -9
  34. mima/objects/world/logic_gate.py +8 -7
  35. mima/objects/world/movable.py +72 -28
  36. mima/objects/world/oneway.py +14 -9
  37. mima/objects/world/pickup.py +10 -5
  38. mima/objects/world/switch.py +28 -25
  39. mima/objects/world/teleport.py +76 -55
  40. mima/scene_engine.py +19 -20
  41. mima/scripts/command.py +16 -2
  42. mima/scripts/commands/change_map.py +23 -4
  43. mima/scripts/commands/equip_weapon.py +23 -0
  44. mima/scripts/commands/give_item.py +5 -3
  45. mima/scripts/commands/move_map.py +9 -9
  46. mima/scripts/commands/parallel.py +16 -3
  47. mima/scripts/commands/present_item.py +7 -5
  48. mima/scripts/commands/screen_fade.py +30 -12
  49. mima/scripts/commands/serial.py +30 -7
  50. mima/scripts/commands/set_spawn_map.py +6 -3
  51. mima/scripts/commands/show_choices.py +16 -7
  52. mima/scripts/commands/show_dialog.py +110 -3
  53. mima/scripts/script_processor.py +41 -20
  54. mima/states/game_state.py +2 -0
  55. mima/states/memory.py +28 -0
  56. mima/states/quest.py +2 -3
  57. mima/types/keys.py +48 -0
  58. mima/types/mode.py +4 -10
  59. mima/types/player.py +9 -0
  60. mima/types/position.py +13 -0
  61. mima/types/tile_collision.py +11 -0
  62. mima/types/window.py +44 -0
  63. mima/usables/item.py +1 -0
  64. mima/util/colors.py +5 -0
  65. mima/util/constants.py +6 -0
  66. mima/util/functions.py +27 -0
  67. mima/util/input_defaults.py +109 -0
  68. mima/util/runtime_config.py +234 -30
  69. mima/util/trading_item.py +20 -0
  70. mima/view/camera.py +160 -19
  71. mima/view/mima_mode.py +612 -0
  72. mima/view/mima_scene.py +225 -0
  73. mima/view/mima_view.py +12 -0
  74. mima/view/mima_window.py +153 -0
  75. {mima_engine-0.1.5.dist-info → mima_engine-0.2.1.dist-info}/METADATA +4 -2
  76. mima_engine-0.2.1.dist-info/RECORD +128 -0
  77. {mima_engine-0.1.5.dist-info → mima_engine-0.2.1.dist-info}/WHEEL +1 -1
  78. mima/view/scene.py +0 -322
  79. mima_engine-0.1.5.dist-info/RECORD +0 -114
  80. {mima_engine-0.1.5.dist-info → mima_engine-0.2.1.dist-info}/top_level.txt +0 -0
mima/types/player.py ADDED
@@ -0,0 +1,9 @@
1
+ from enum import Enum
2
+
3
+
4
+ class Player(Enum):
5
+ P0 = 0
6
+ P1 = 1
7
+ P2 = 2
8
+ P3 = 3
9
+ P4 = 4
mima/types/position.py ADDED
@@ -0,0 +1,13 @@
1
+ from enum import Enum
2
+
3
+
4
+ class Position:
5
+ BOTTOM = 0
6
+ BOTTOM_LEFT = 1
7
+ LEFT = 2
8
+ TOP_LEFT = 3
9
+ TOP = 4
10
+ TOP_RIGHT = 5
11
+ RIGHT = 6
12
+ BOTTOM_RIGHT = 7
13
+ CENTER = 8
@@ -0,0 +1,11 @@
1
+ from enum import Enum
2
+
3
+
4
+ class TileCollision(Enum):
5
+ TOP = 0
6
+ BOTTOM = 1
7
+ ANY = 2
8
+ TOP_2 = 3
9
+ TOP_3 = 4
10
+ BOTTOM_2 = 5
11
+ BOTTOM_3 = 6
mima/types/window.py ADDED
@@ -0,0 +1,44 @@
1
+ from enum import Enum
2
+
3
+
4
+ class Window(Enum):
5
+ PLACEHOLDER = -1
6
+ LOADING = 0
7
+ TITLE = 1
8
+ SELECT_GAME = 2
9
+ SETTINGS = 3
10
+ CONTROLS = 4
11
+ TOP_DOWN_MAP_1 = 5
12
+ TOP_DOWN_MAP_2 = 6
13
+ TOP_DOWN_MAP_3 = 7
14
+ SIDE_MAP_1 = 8
15
+ SIDE_MAP_2 = 9
16
+ SIDE_MAP_3 = 10
17
+ WORLD_MAP_1 = 11
18
+ WORLD_MAP_2 = 12
19
+ WORLD_MAP_3 = 13
20
+ INVENTORY_START = 14
21
+ INVENTORY_STATUS = 15
22
+ INVENTORY_ITEMS = 16
23
+ INVENTORY_EQUIPMENT = 17
24
+ INVENTORY_MAGIC = 18
25
+ INVENTORY_SKILLS = 19
26
+ INVENTORY_QUESTS = 20
27
+ INVENTORY_PROGRESS = 21
28
+ COMBAT = 22
29
+ TEAM_ACTION = 23
30
+ CHANGE_POSITION = 24
31
+ ESCAPCE = 25
32
+ CHARACTER_ACTION = 26
33
+ ITEM_SELECT = 27
34
+ MAGIC_SELECT = 28
35
+ SPECIAL_SELECT = 29
36
+ TARGET_SELECT = 30
37
+ OPPONENTS = 31
38
+ THEATRE = 32
39
+ VICTORY = 33
40
+ SHOP = 34
41
+ GAME_OVER = 35
42
+ CONTROLS_1 = 36
43
+ CONTROLS_2 = 37
44
+ CONTROLS_3 = 38
mima/usables/item.py CHANGED
@@ -23,6 +23,7 @@ class Item:
23
23
  self.sprite_height: int = DEFAULT_SPRITE_HEIGHT
24
24
  self.key_item: bool = False
25
25
  self.equipable: bool = False
26
+ self.price: int = 0
26
27
 
27
28
  def on_interaction(self, obj: Dynamic):
28
29
  return False
mima/util/colors.py CHANGED
@@ -43,3 +43,8 @@ DARK_YELLOW = Color(64, 64, 0, 160)
43
43
  DARK_CYAN = Color(0, 64, 64, 160)
44
44
  DARK_PURPLE = Color(64, 0, 64, 160)
45
45
  TRANS_CYAN = Color(0, 64, 64, 128)
46
+ TRANS_LIGHT_RED = Color(255, 0, 0, 128)
47
+ TRANS_LIGHT_YELLOW = Color(255, 255, 0, 128)
48
+ TRANS_LIGHT_CYAN = Color(0, 255, 255, 128)
49
+ TRANS_LIGHT_PURPLE = Color(255, 0, 255, 128)
50
+ TRANS_LIGHT_GREEN = Color(0, 255, 0, 128)
mima/util/constants.py CHANGED
@@ -45,3 +45,9 @@ ABYSS_DAMAGE: int = 1
45
45
  PLAYER_BASE_HEALTH: int = 30
46
46
  PLAYER_BASE_SPEED: float = 4.5
47
47
  PLAYER_BASE_RUN_SPEED: float = 6.0
48
+
49
+ # Dialog
50
+ DIALOG_WIDTH: float = 14.0
51
+ DIALOG_HEIGHT: float = 3.0
52
+ DIALOG_CHARS_PER_LINE: int = 36
53
+ DIALOG_N_LINES: int = 4
mima/util/functions.py CHANGED
@@ -1,3 +1,6 @@
1
+ from .constants import BIG_FONT_WIDTH
2
+
3
+
1
4
  def strtobool(val: str) -> bool:
2
5
  """Convert a string representation of truth to true (1) or false (0).
3
6
  True values are 'y', 'yes', 't', 'true', 'on', and '1'; false values
@@ -11,3 +14,27 @@ def strtobool(val: str) -> bool:
11
14
  return 0
12
15
  else:
13
16
  raise ValueError("invalid truth value %r" % (val,))
17
+
18
+
19
+ def wrap_text(text: str, n_chars: int = 0):
20
+ if n_chars == 0:
21
+ return [text]
22
+
23
+ words = text.split(" ")
24
+ lines = []
25
+ new_text = ""
26
+ for idx, word in enumerate(words):
27
+ if len(new_text + word) > n_chars:
28
+ lines.append(new_text)
29
+ new_text = ""
30
+
31
+ new_text += f"{word.strip()} "
32
+ # new_text.strip()
33
+ lines.append(new_text.strip())
34
+ return lines
35
+
36
+
37
+ def text_to_center(
38
+ text: str, ppx: int, pwidth: int, font_width=BIG_FONT_WIDTH
39
+ ):
40
+ return int(ppx + pwidth / 2 - (len(text) / 2 * BIG_FONT_WIDTH))
@@ -13,6 +13,54 @@ BUTTONS = [
13
13
  K.Y,
14
14
  K.L,
15
15
  K.R,
16
+ K.P1_UP,
17
+ K.P1_DOWN,
18
+ K.P1_LEFT,
19
+ K.P1_RIGHT,
20
+ K.P1_START,
21
+ K.P1_SELECT,
22
+ K.P1_A,
23
+ K.P1_B,
24
+ K.P1_X,
25
+ K.P1_Y,
26
+ K.P1_L,
27
+ K.P1_R,
28
+ K.P2_UP,
29
+ K.P2_DOWN,
30
+ K.P2_LEFT,
31
+ K.P2_RIGHT,
32
+ K.P2_START,
33
+ K.P2_SELECT,
34
+ K.P2_A,
35
+ K.P2_B,
36
+ K.P2_X,
37
+ K.P2_Y,
38
+ K.P2_L,
39
+ K.P2_R,
40
+ K.P3_UP,
41
+ K.P3_DOWN,
42
+ K.P3_LEFT,
43
+ K.P3_RIGHT,
44
+ K.P3_START,
45
+ K.P3_SELECT,
46
+ K.P3_A,
47
+ K.P3_B,
48
+ K.P3_X,
49
+ K.P3_Y,
50
+ K.P3_L,
51
+ K.P3_R,
52
+ K.P4_UP,
53
+ K.P4_DOWN,
54
+ K.P4_LEFT,
55
+ K.P4_RIGHT,
56
+ K.P4_START,
57
+ K.P4_SELECT,
58
+ K.P4_A,
59
+ K.P4_B,
60
+ K.P4_X,
61
+ K.P4_Y,
62
+ K.P4_L,
63
+ K.P4_R,
16
64
  ]
17
65
 
18
66
 
@@ -31,6 +79,56 @@ DEFAULT_KEYBOARD_MAP = {
31
79
  K.Y: ["j"],
32
80
  K.L: ["o"],
33
81
  K.R: ["c"],
82
+ K.P1_UP: [],
83
+ K.P1_DOWN: [],
84
+ K.P1_LEFT: [],
85
+ K.P1_RIGHT: [],
86
+ K.P1_START: [],
87
+ K.P1_SELECT: [],
88
+ K.P1_A: [],
89
+ K.P1_B: [],
90
+ K.P1_X: [],
91
+ K.P1_Y: [],
92
+ K.P1_L: [],
93
+ K.P1_R: [],
94
+ K.P1_UP: [],
95
+ K.P1_UP: [],
96
+ K.P2_DOWN: [],
97
+ K.P2_LEFT: [],
98
+ K.P2_RIGHT: [],
99
+ K.P2_START: [],
100
+ K.P2_SELECT: [],
101
+ K.P2_A: [],
102
+ K.P2_B: [],
103
+ K.P2_X: [],
104
+ K.P2_Y: [],
105
+ K.P2_L: [],
106
+ K.P2_R: [],
107
+ K.P2_UP: [],
108
+ K.P3_UP: [],
109
+ K.P3_DOWN: [],
110
+ K.P3_LEFT: [],
111
+ K.P3_RIGHT: [],
112
+ K.P3_START: [],
113
+ K.P3_SELECT: [],
114
+ K.P3_A: [],
115
+ K.P3_B: [],
116
+ K.P3_X: [],
117
+ K.P3_Y: [],
118
+ K.P3_L: [],
119
+ K.P3_R: [],
120
+ K.P4_UP: [],
121
+ K.P4_DOWN: [],
122
+ K.P4_LEFT: [],
123
+ K.P4_RIGHT: [],
124
+ K.P4_START: [],
125
+ K.P4_SELECT: [],
126
+ K.P4_A: [],
127
+ K.P4_B: [],
128
+ K.P4_X: [],
129
+ K.P4_Y: [],
130
+ K.P4_L: [],
131
+ K.P4_R: [],
34
132
  }
35
133
 
36
134
  DEFAULT_JOYSTICK_MAP = {
@@ -47,3 +145,14 @@ DEFAULT_JOYSTICK_MAP = {
47
145
  K.L: [4],
48
146
  K.R: [5],
49
147
  }
148
+
149
+ DEFAULT_TOUCHSCREEN_MAP = {
150
+ K.P1_UP: [[0, 0], [0.5, 1.0]],
151
+ K.P1_L: [[0, 0], [0.0625, 0.1111]],
152
+ K.P1_R: [[0.9375, 0], [1.0, 0.1111]],
153
+ K.P1_START: [[0.5, 0], [1.0, 0.3]],
154
+ K.P1_Y: [[0.5, 0.3], [0.75, 0.5]],
155
+ K.P1_X: [[0.75, 0.3], [1.0, 0.5]],
156
+ K.P1_B: [[0.5, 0.5], [0.75, 1.0]],
157
+ K.P1_A: [[0.75, 0.5], [1.0, 1.0]],
158
+ }
@@ -1,26 +1,90 @@
1
1
  import configparser
2
2
  import os
3
3
  from copy import deepcopy
4
- from typing import Any, Dict, Optional
4
+ from typing import Any, Dict, List, Optional, Tuple
5
5
 
6
6
  from ..types.keys import Key as K
7
- from .colors import Color
7
+ from ..types.player import Player
8
+ from .colors import (
9
+ BLACK,
10
+ BLUE,
11
+ DARK_GREY,
12
+ DARK_RED,
13
+ GREEN,
14
+ RED,
15
+ VERY_LIGHT_GREY,
16
+ WHITE,
17
+ Color,
18
+ )
19
+ from .constants import (
20
+ BIG_FONT_HEIGHT,
21
+ BIG_FONT_NAME,
22
+ BIG_FONT_WIDTH,
23
+ SMALL_FONT_HEIGHT,
24
+ SMALL_FONT_NAME,
25
+ SMALL_FONT_WIDTH,
26
+ TILE_HEIGHT,
27
+ TILE_WIDTH,
28
+ )
8
29
  from .functions import strtobool
9
30
 
10
31
  DEFAULT_CONFIG = {
11
- "keymap": {
32
+ "keyboard_map_p1": {
12
33
  "UP": "w",
13
34
  "DOWN": "s",
14
35
  "LEFT": "a",
15
36
  "RIGHT": "d",
16
- "A": "k",
17
- "B": "h",
18
- "X": "l",
19
- "Y": "j",
20
- "L": "o",
21
- "R": "c",
22
- "START": "i",
23
- "SELECT": "t",
37
+ "A": "e",
38
+ "B": "q",
39
+ "X": "x",
40
+ "Y": "y",
41
+ "L": "1",
42
+ "R": "2",
43
+ "START": "r",
44
+ "SELECT": "c",
45
+ },
46
+ "keyboard_map_p2": {
47
+ "UP": "up",
48
+ "DOWN": "down",
49
+ "LEFT": "left",
50
+ "RIGHT": "right",
51
+ "A": "6",
52
+ "B": "2",
53
+ "X": "8",
54
+ "Y": "4",
55
+ "L": "7",
56
+ "R": "9",
57
+ "START": "5",
58
+ "SELECT": "0",
59
+ },
60
+ "joysticks": {"p1": 0, "p2": 1},
61
+ "joystick_map_p1": {
62
+ "UP": "up",
63
+ "DOWN": "down",
64
+ "LEFT": "left",
65
+ "RIGHT": "right",
66
+ "A": "0",
67
+ "B": "1",
68
+ "X": "2",
69
+ "Y": "3",
70
+ "L": "7",
71
+ "R": "8",
72
+ "START": "5",
73
+ "SELECT": "6",
74
+ },
75
+ "joystick_map_p2": {
76
+ "UP": "up",
77
+ "DOWN": "down",
78
+ "LEFT": "left",
79
+ "RIGHT": "right",
80
+ "A": "0",
81
+ "B": "1",
82
+ "X": "2",
83
+ "Y": "3",
84
+ "L": "7",
85
+ "R": "8",
86
+ "START": "5",
87
+ "SELECT": "6",
24
88
  },
25
89
  "colors": {},
26
90
  "color_remaps": {},
@@ -38,11 +102,12 @@ class RuntimeConfig:
38
102
  default_config = DEFAULT_CONFIG
39
103
 
40
104
  self._loaded: Dict[str, Any] = deepcopy(default_config)
105
+
41
106
  self._converted: Dict[str, Any] = {}
42
107
 
43
108
  if not config_path:
44
109
  config_path = os.path.abspath(
45
- os.path.join(os.getcwd(), "avenight.ini")
110
+ os.path.join(os.getcwd(), "mima.ini")
46
111
  )
47
112
 
48
113
  self._config_path = config_path
@@ -53,17 +118,48 @@ class RuntimeConfig:
53
118
 
54
119
  if config.sections():
55
120
  self._read_config(config)
56
-
57
121
  else:
58
122
  self._write_config(config)
59
-
60
123
  else:
61
124
  self._write_config(config)
62
125
 
126
+ # Per-game constants
127
+ ## Colors
128
+ self.color_black = BLACK
129
+ self.color_white = WHITE
130
+ self.color_red = RED
131
+ self.color_blue = BLUE
132
+ self.color_green = GREEN
133
+ self.color_dark_red = DARK_RED
134
+ self.color_dark_grey = DARK_GREY
135
+ self.color_very_light_grey = VERY_LIGHT_GREY
136
+
137
+ self.tile_width = TILE_WIDTH
138
+ self.tile_height = TILE_HEIGHT
139
+
140
+ ## Font
141
+ self.big_font_name = BIG_FONT_NAME
142
+ self.big_font_width = BIG_FONT_WIDTH
143
+ self.big_font_height = BIG_FONT_HEIGHT
144
+ self.small_font_name = SMALL_FONT_NAME
145
+ self.small_font_width = SMALL_FONT_WIDTH
146
+ self.small_font_height = SMALL_FONT_HEIGHT
147
+
63
148
  def _read_config(self, config: configparser.ConfigParser):
64
- for key, mapping in config["keymap"].items():
65
- vals = mapping.strip().split(",")
66
- self._loaded["keymap"][key.upper()] = vals
149
+ mappings = [
150
+ "keyboard_map_p1",
151
+ "keyboard_map_p2",
152
+ "joystick_map_p1",
153
+ "joystick_map_p2",
154
+ ]
155
+ for m in mappings:
156
+ for key, mapping in config[m].items():
157
+ vals = mapping.strip().split(",")
158
+ self._loaded[m][key.upper()] = vals
159
+ self._loaded["joysticks"] = {
160
+ "p1": int(config["joysticks"].get("p1", 0)),
161
+ "p2": int(config["joysticks"].get("p2", 1)),
162
+ }
67
163
 
68
164
  default_colors = {}
69
165
  for color_name, color in self._loaded["colors"].items():
@@ -74,12 +170,34 @@ class RuntimeConfig:
74
170
  for flag in self._loaded["flags"]:
75
171
  self._loaded["flags"][flag] = config["flags"][flag]
76
172
 
173
+ def save_config(self):
174
+ config = configparser.ConfigParser()
175
+ self._write_config(config)
176
+
77
177
  def _write_config(self, config: configparser.ConfigParser):
78
- config["keymap"] = {}
178
+ mappings = [
179
+ "keyboard_map_p1",
180
+ "keyboard_map_p2",
181
+ "joystick_map_p1",
182
+ "joystick_map_p2",
183
+ ]
184
+ for m in mappings:
185
+ config[m] = {}
186
+ for key, mapping in self._loaded[m].items():
187
+ config[m][key.lower()] = ",".join(mapping)
188
+ # config["keyboard_map_p1"] = {}
189
+ # config["keyboard_map_p2"] = {}
190
+ config["joysticks"] = {
191
+ "p1": self._loaded["joysticks"].get("p1", 0),
192
+ "p2": self._loaded["joysticks"].get("p2", 1),
193
+ }
194
+ # config["joystick_map_p1"] = {}
195
+ # config["joystick_p2"] =
196
+ # config["joystick_map_p2"] = {}
79
197
  config["colors"] = {}
80
198
  config["flags"] = {}
81
- for key, mapping in self._loaded["keymap"].items():
82
- config["keymap"][key.lower()] = mapping
199
+
200
+ # for key, mapping in self._loaded["keyboard_map_p1"].items():
83
201
 
84
202
  for color_name, color in self._loaded["colors"].items():
85
203
  if color_name.endswith("_default"):
@@ -92,18 +210,104 @@ class RuntimeConfig:
92
210
  with open(self._config_path, "w") as cfg_file:
93
211
  config.write(cfg_file)
94
212
 
95
- @property
96
- def keymap(self):
97
- if "keymap" in self._converted:
98
- return self._converted["keymap"]
99
- else:
100
- self._converted["keymap"] = {}
101
- for but in K:
102
- self._converted["keymap"][but] = self._loaded["keymap"][
103
- but.name
213
+ def update_keyboard_map(self, kbmap: Dict[K, List[str]]):
214
+ mappings = [
215
+ "keyboard_map_p1",
216
+ "keyboard_map_p2",
217
+ # "joystick_map_p3",
218
+ # "keyboard_map_p4",
219
+ ]
220
+ mip = 1
221
+ for idx, (key, mapping) in enumerate(kbmap.items()):
222
+ mip = idx // 12
223
+ if mip < 1 or mip > 2:
224
+ continue
225
+ key_name = key.name.split("_")[1]
226
+ self._loaded[mappings[mip - 1]][key_name] = mapping
227
+
228
+ def update_joystick_map(self, jsmap: Dict[K, List[str]]):
229
+ mappings = [
230
+ # "keyboard_map_p1",
231
+ # "keyboard_map_p2",
232
+ "joystick_map_p1",
233
+ "keyboard_map_p2",
234
+ ]
235
+ mip = 1
236
+ for idx, (key, mapping) in enumerate(jsmap.items()):
237
+ mip = idx // 12
238
+ if mip < 1 or mip > 2:
239
+ continue
240
+ key_name = key.name.split("_")[1]
241
+ self._loaded[mappings[mip - 1]][key_name] = mapping
242
+
243
+ def update_joysticks(self, reassign: List[Tuple[int, Player]]):
244
+ self._loaded["joysticks"] = {}
245
+ for item in reassign:
246
+ self._loaded["joysticks"][item[1].name.lower()] = item[0]
247
+
248
+ def get_keyboard_map(self) -> Dict[K, List[str]]:
249
+ kbmap = {}
250
+ for but in K:
251
+ if but.value < 12:
252
+ kbmap[but] = []
253
+ elif but.value < 24:
254
+ kbmap[but] = self._loaded["keyboard_map_p1"][
255
+ but.name.split("_")[1]
256
+ ]
257
+
258
+ elif but.value < 36:
259
+ kbmap[but] = self._loaded["keyboard_map_p2"][
260
+ but.name.split("_")[1]
261
+ ]
262
+
263
+ else:
264
+ kbmap[but] = []
265
+ return kbmap
266
+
267
+ def get_joystick_map(self) -> Dict[K, List[str]]:
268
+ jsmap = {}
269
+
270
+ for but in K:
271
+ if but.value < 12:
272
+ jsmap[but] = []
273
+ elif but.value < 24:
274
+ jsmap[but] = self._loaded["joystick_map_p1"][
275
+ but.name.split("_")[1]
276
+ ]
277
+
278
+ elif but.value < 36:
279
+ jsmap[but] = self._loaded["joystick_map_p2"][
280
+ but.name.split("_")[1]
104
281
  ]
105
282
 
106
- return self._converted["keymap"]
283
+ else:
284
+ jsmap[but] = []
285
+ return jsmap
286
+
287
+ def get_joy_to_player(self) -> Dict[int, Player]:
288
+ joy2p = {}
289
+ for p, j in self._loaded["joysticks"].items():
290
+ joy2p[j] = Player[p.upper()]
291
+ return joy2p
292
+
293
+ def get_player_to_joy(self) -> Dict[Player, int]:
294
+ p2joy = {}
295
+ for p, j in self._loaded["joysticks"].items():
296
+ p2joy[Player[p.upper()]] = j
297
+ return p2joy
298
+
299
+ # @property
300
+ # def keymap(self):
301
+ # if "keymap" in self._converted:
302
+ # return self._converted["keymap"]
303
+ # else:
304
+ # self._converted["keymap"] = {}
305
+ # for but in K:
306
+ # self._converted["keymap"][but] = self._loaded["keymap"][
307
+ # but.name
308
+ # ]
309
+
310
+ # return self._converted["keymap"]
107
311
 
108
312
  @property
109
313
  def colors(self) -> Dict[str, Color]:
@@ -0,0 +1,20 @@
1
+ from __future__ import annotations
2
+
3
+ from dataclasses import dataclass
4
+ from typing import TYPE_CHECKING
5
+
6
+ if TYPE_CHECKING:
7
+ from ..usables.item import Item
8
+
9
+
10
+ @dataclass
11
+ class TradingItem:
12
+ item: Item
13
+ price: int
14
+ count: int = 1
15
+ factor: float = 1.0
16
+ available: int = 1
17
+ tid: int = 0
18
+
19
+ def __eq__(self, other):
20
+ return self.tid == other.tid