pyscreeps-arena 0.5.7.6__tar.gz → 0.5.8.2__tar.gz

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.
Files changed (52) hide show
  1. {pyscreeps_arena-0.5.7.6 → pyscreeps_arena-0.5.8.2}/PKG-INFO +1 -1
  2. {pyscreeps_arena-0.5.7.6 → pyscreeps_arena-0.5.8.2}/pyscreeps_arena/compiler.py +60 -26
  3. {pyscreeps_arena-0.5.7.6 → pyscreeps_arena-0.5.8.2}/pyscreeps_arena/core/const.py +1 -1
  4. pyscreeps_arena-0.5.8.2/pyscreeps_arena/project.7z +0 -0
  5. {pyscreeps_arena-0.5.7.6 → pyscreeps_arena-0.5.8.2}/pyscreeps_arena.egg-info/PKG-INFO +1 -1
  6. {pyscreeps_arena-0.5.7.6 → pyscreeps_arena-0.5.8.2}/setup.py +1 -1
  7. pyscreeps_arena-0.5.7.6/pyscreeps_arena/project.7z +0 -0
  8. {pyscreeps_arena-0.5.7.6 → pyscreeps_arena-0.5.8.2}/pyscreeps_arena/__init__.py +0 -0
  9. {pyscreeps_arena-0.5.7.6 → pyscreeps_arena-0.5.8.2}/pyscreeps_arena/build.py +0 -0
  10. {pyscreeps_arena-0.5.7.6 → pyscreeps_arena-0.5.8.2}/pyscreeps_arena/core/__init__.py +0 -0
  11. {pyscreeps_arena-0.5.7.6 → pyscreeps_arena-0.5.8.2}/pyscreeps_arena/core/basic.py +0 -0
  12. {pyscreeps_arena-0.5.7.6 → pyscreeps_arena-0.5.8.2}/pyscreeps_arena/core/config.py +0 -0
  13. {pyscreeps_arena-0.5.7.6 → pyscreeps_arena-0.5.8.2}/pyscreeps_arena/core/core.py +0 -0
  14. {pyscreeps_arena-0.5.7.6 → pyscreeps_arena-0.5.8.2}/pyscreeps_arena/core/main.py +0 -0
  15. {pyscreeps_arena-0.5.7.6 → pyscreeps_arena-0.5.8.2}/pyscreeps_arena/core/utils.py +0 -0
  16. {pyscreeps_arena-0.5.7.6 → pyscreeps_arena-0.5.8.2}/pyscreeps_arena/localization.py +0 -0
  17. {pyscreeps_arena-0.5.7.6 → pyscreeps_arena-0.5.8.2}/pyscreeps_arena/ui/P2PY.py +0 -0
  18. {pyscreeps_arena-0.5.7.6 → pyscreeps_arena-0.5.8.2}/pyscreeps_arena/ui/__init__.py +0 -0
  19. {pyscreeps_arena-0.5.7.6 → pyscreeps_arena-0.5.8.2}/pyscreeps_arena/ui/creeplogic_edit.py +0 -0
  20. {pyscreeps_arena-0.5.7.6 → pyscreeps_arena-0.5.8.2}/pyscreeps_arena/ui/map_render.py +0 -0
  21. {pyscreeps_arena-0.5.7.6 → pyscreeps_arena-0.5.8.2}/pyscreeps_arena/ui/mapviewer.py +0 -0
  22. {pyscreeps_arena-0.5.7.6 → pyscreeps_arena-0.5.8.2}/pyscreeps_arena/ui/project_ui.py +0 -0
  23. {pyscreeps_arena-0.5.7.6 → pyscreeps_arena-0.5.8.2}/pyscreeps_arena/ui/qcreeplogic/__init__.py +0 -0
  24. {pyscreeps_arena-0.5.7.6 → pyscreeps_arena-0.5.8.2}/pyscreeps_arena/ui/qcreeplogic/model.py +0 -0
  25. {pyscreeps_arena-0.5.7.6 → pyscreeps_arena-0.5.8.2}/pyscreeps_arena/ui/qcreeplogic/qcreeplogic.py +0 -0
  26. {pyscreeps_arena-0.5.7.6 → pyscreeps_arena-0.5.8.2}/pyscreeps_arena/ui/qmapker/__init__.py +0 -0
  27. {pyscreeps_arena-0.5.7.6 → pyscreeps_arena-0.5.8.2}/pyscreeps_arena/ui/qmapker/qmapmarker.py +0 -0
  28. {pyscreeps_arena-0.5.7.6 → pyscreeps_arena-0.5.8.2}/pyscreeps_arena/ui/qmapker/qvariable.py +0 -0
  29. {pyscreeps_arena-0.5.7.6 → pyscreeps_arena-0.5.8.2}/pyscreeps_arena/ui/qmapker/test_compact_variable.py +0 -0
  30. {pyscreeps_arena-0.5.7.6 → pyscreeps_arena-0.5.8.2}/pyscreeps_arena/ui/qmapker/test_qmapmarker.py +0 -0
  31. {pyscreeps_arena-0.5.7.6 → pyscreeps_arena-0.5.8.2}/pyscreeps_arena/ui/qmapker/test_qvariable.py +0 -0
  32. {pyscreeps_arena-0.5.7.6 → pyscreeps_arena-0.5.8.2}/pyscreeps_arena/ui/qmapker/to_code.py +0 -0
  33. {pyscreeps_arena-0.5.7.6 → pyscreeps_arena-0.5.8.2}/pyscreeps_arena/ui/qmapv/__init__.py +0 -0
  34. {pyscreeps_arena-0.5.7.6 → pyscreeps_arena-0.5.8.2}/pyscreeps_arena/ui/qmapv/qcinfo.py +0 -0
  35. {pyscreeps_arena-0.5.7.6 → pyscreeps_arena-0.5.8.2}/pyscreeps_arena/ui/qmapv/qco.py +0 -0
  36. {pyscreeps_arena-0.5.7.6 → pyscreeps_arena-0.5.8.2}/pyscreeps_arena/ui/qmapv/qmapv.py +0 -0
  37. {pyscreeps_arena-0.5.7.6 → pyscreeps_arena-0.5.8.2}/pyscreeps_arena/ui/qmapv/test_array_drag.py +0 -0
  38. {pyscreeps_arena-0.5.7.6 → pyscreeps_arena-0.5.8.2}/pyscreeps_arena/ui/qmapv/test_drag.py +0 -0
  39. {pyscreeps_arena-0.5.7.6 → pyscreeps_arena-0.5.8.2}/pyscreeps_arena/ui/qmapv/test_qcinfo.py +0 -0
  40. {pyscreeps_arena-0.5.7.6 → pyscreeps_arena-0.5.8.2}/pyscreeps_arena/ui/qmapv/test_qco_drag.py +0 -0
  41. {pyscreeps_arena-0.5.7.6 → pyscreeps_arena-0.5.8.2}/pyscreeps_arena/ui/qmapv/test_qmapv.py +0 -0
  42. {pyscreeps_arena-0.5.7.6 → pyscreeps_arena-0.5.8.2}/pyscreeps_arena/ui/qmapv/test_simple_array.py +0 -0
  43. {pyscreeps_arena-0.5.7.6 → pyscreeps_arena-0.5.8.2}/pyscreeps_arena/ui/qrecipe/__init__.py +0 -0
  44. {pyscreeps_arena-0.5.7.6 → pyscreeps_arena-0.5.8.2}/pyscreeps_arena/ui/qrecipe/model.py +0 -0
  45. {pyscreeps_arena-0.5.7.6 → pyscreeps_arena-0.5.8.2}/pyscreeps_arena/ui/qrecipe/qrecipe.py +0 -0
  46. {pyscreeps_arena-0.5.7.6 → pyscreeps_arena-0.5.8.2}/pyscreeps_arena/ui/rs_icon.py +0 -0
  47. {pyscreeps_arena-0.5.7.6 → pyscreeps_arena-0.5.8.2}/pyscreeps_arena.egg-info/SOURCES.txt +0 -0
  48. {pyscreeps_arena-0.5.7.6 → pyscreeps_arena-0.5.8.2}/pyscreeps_arena.egg-info/dependency_links.txt +0 -0
  49. {pyscreeps_arena-0.5.7.6 → pyscreeps_arena-0.5.8.2}/pyscreeps_arena.egg-info/entry_points.txt +0 -0
  50. {pyscreeps_arena-0.5.7.6 → pyscreeps_arena-0.5.8.2}/pyscreeps_arena.egg-info/requires.txt +0 -0
  51. {pyscreeps_arena-0.5.7.6 → pyscreeps_arena-0.5.8.2}/pyscreeps_arena.egg-info/top_level.txt +0 -0
  52. {pyscreeps_arena-0.5.7.6 → pyscreeps_arena-0.5.8.2}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: pyscreeps-arena
3
- Version: 0.5.7.6
3
+ Version: 0.5.8.2
4
4
  Summary: Python api|interface to play game: Screeps: Arena.
5
5
  Author-email: 2229066748@qq.com
6
6
  Maintainer: Eagle'sBaby
@@ -17,6 +17,10 @@ python_version_info = sys.version_info
17
17
  python_version_info = f"{python_version_info.major}.{python_version_info.minor}.{python_version_info.micro}"
18
18
 
19
19
 
20
+ class MatchCaseError(Exception):
21
+ pass
22
+
23
+
20
24
  def replace_src_prefix(file_list):
21
25
  """
22
26
  将列表中以'./src.'开头的字符串替换为'./'
@@ -28,16 +32,17 @@ def replace_src_prefix(file_list):
28
32
  替换后的新列表
29
33
  """
30
34
  _ = []
31
-
35
+
32
36
  for item in file_list:
33
37
  if isinstance(item, str) and item.startswith('./src.'):
34
38
  _new = item.replace('./src.', './', 1)
35
39
  if _new in file_list:
36
40
  continue
37
41
  _.append(item)
38
-
42
+
39
43
  return _
40
44
 
45
+
41
46
  # def InsertPragmaBefore(content:str) -> str:
42
47
  # """
43
48
  # 在content的开头插入__pragma__('noalias', 'undefined')等内容 |
@@ -160,8 +165,8 @@ class GameConstructionBoost{{
160
165
  }};
161
166
  import {{ Portal as GamePortal}} from 'arena/season_{config.season}/{const.ARENA_GREEN}/{"advanced" if config.level in ["advance", "advanced"] else "basic"}/prototypes';
162
167
  """,
163
- # import {Portal} from 'arena/season_1/portal_exploration/basic/prototypes';
164
-
168
+ # import {Portal} from 'arena/season_1/portal_exploration/basic/prototypes';
169
+
165
170
  const.ARENA_BLUE: lambda: f"""
166
171
  const ARENA_COLOR_TYPE = "BLUE";
167
172
  const GameScoreCollector = GameStructureSpawn;
@@ -415,8 +420,7 @@ class Compiler_Utils(Compiler_Const):
415
420
  py_files.append(item)
416
421
  elif os.path.isdir(_path):
417
422
  rel = os.path.relpath(final_dir_path, project_path)
418
- core.warn(f'Compiler.expand_folder_imports', core.lformat(LOC_DIR_UNDER_NONINIT_DIR, [item, rel]), end='', head='\n', ln=config.language )
419
-
423
+ core.warn(f'Compiler.expand_folder_imports', core.lformat(LOC_DIR_UNDER_NONINIT_DIR, [item, rel]), end='', head='\n', ln=config.language)
420
424
 
421
425
  # 为每个 .py 文件生成导入语句
422
426
  if py_files:
@@ -436,7 +440,6 @@ class Compiler_Utils(Compiler_Const):
436
440
  with open(fpath, 'w', encoding='utf-8') as f:
437
441
  f.write(new_content)
438
442
 
439
-
440
443
  def find_chain_import(self, fpath: str, search_dirs: list[str], project_path: str = None, records: dict[str, None] = None) -> list[str]:
441
444
  r"""
442
445
  查找文件中的所有import语句,并返回所有import的文件路径 | find all import statements in a file and return the paths of all imported files
@@ -572,13 +575,13 @@ class Compiler_Utils(Compiler_Const):
572
575
  return imps
573
576
 
574
577
  @staticmethod
575
- def relist_pyimports_to_jsimports(base_dir:str, pyimps:list[str]) -> list[str]:
578
+ def relist_pyimports_to_jsimports(base_dir: str, pyimps: list[str]) -> list[str]:
576
579
  """
577
580
  将python的imports路径列表转换为js的imports路径列表 | convert a list of python imports paths to a list of js imports paths
578
581
  """
579
582
  jsimps = []
580
583
  for pyimp in pyimps:
581
- rel_path_nodes:list[str] = os.path.relpath(pyimp, base_dir).replace('\\', '/').split('/')
584
+ rel_path_nodes: list[str] = os.path.relpath(pyimp, base_dir).replace('\\', '/').split('/')
582
585
  if rel_path_nodes[-1] == '__init__.py':
583
586
  rel_path_nodes.pop()
584
587
  else:
@@ -644,7 +647,7 @@ class Compiler_Utils(Compiler_Const):
644
647
  result = '\n'.join(calls_to_add) + '\n' + result
645
648
 
646
649
  return result
647
-
650
+
648
651
  @staticmethod
649
652
  def process_mate_code(code):
650
653
  # 用于存储匹配到的信息
@@ -678,12 +681,11 @@ class Compiler_Utils(Compiler_Const):
678
681
  for variable_name, class_name in mate_assignments:
679
682
  output_string = f"# > insert Object.defineProperty ({class_name}, '{variable_name}', property.call ({class_name}, {class_name}.{variable_name}._MateGet_, {class_name}.{variable_name}._MateSet_));"
680
683
  output_strings.append(output_string)
681
-
682
- return code + '\n'.join(output_strings)
683
684
 
685
+ return code + '\n'.join(output_strings)
684
686
 
685
687
  @staticmethod
686
- def remove_long_docstring(content:str) -> str:
688
+ def remove_long_docstring(content: str) -> str:
687
689
  """
688
690
  移除长注释 | remove long docstring
689
691
  """
@@ -1082,7 +1084,6 @@ class Compiler(CompilerBase):
1082
1084
  with open(fpath, 'w', encoding='utf-8') as f:
1083
1085
  f.write(content)
1084
1086
 
1085
-
1086
1087
  core.lprint(GREEN.format('[2/6]'), LOC_DONE, " ", LOC_PREPROCESSING_FINISH, sep="", head="\r", ln=config.language)
1087
1088
  return _imports, _js_imports, _pre_sort_, _pre_define_, _js_replace_
1088
1089
 
@@ -1153,7 +1154,7 @@ class Compiler(CompilerBase):
1153
1154
 
1154
1155
  content = self.auto_read(self.target_js)
1155
1156
  if modules is None: modules = []
1156
- new_modules, new_content = [],""
1157
+ new_modules, new_content = [], ""
1157
1158
  for line in content.split('\n'):
1158
1159
  m = re.search(self.JS_IMPORT_PAT, line)
1159
1160
  if not m:
@@ -1199,7 +1200,7 @@ class Compiler(CompilerBase):
1199
1200
  """
1200
1201
  return re.sub(r'import[^\n]*\n', '', raw)
1201
1202
 
1202
- def generate_total_js(self, usr_modules, t_imps: list[str], f_sorts, f_replaces, g_replaces) -> str:
1203
+ def generate_total_js(self, usr_modules, t_imps: list[str], f_sorts, f_replaces, g_replaces, min_js_files=None) -> str:
1203
1204
  """
1204
1205
  生成总的main.js
1205
1206
  按照如下顺序组合:
@@ -1213,6 +1214,7 @@ class Compiler(CompilerBase):
1213
1214
  :param f_sorts: dict{module_name: sort_priority}
1214
1215
  :param f_replaces: dict{module_name: dict{old: new}}
1215
1216
  :param g_replaces: dict{old: new}
1217
+ :param min_js_files: list[str] # .min.js文件路径列表
1216
1218
  :return: str
1217
1219
  """
1218
1220
  arena_name = const.ARENA_NAMES.get(config.arena, const.ARENA_NAMES['green']) # like green -> spawn_and_swamp
@@ -1220,6 +1222,13 @@ class Compiler(CompilerBase):
1220
1222
  total_js = f"const __VERSION__ = '{const.VERSION}';\nconst __PYTHON_VERSION__ = '{python_version_info}';" + self.TOTAL_INSERT_AT_HEAD + f"\nexport var LANGUAGE = '{config.language}';\n"
1221
1223
  total_js += f"const __AUTHOR__ = '{const.AUTHOR}';\nconst __AUTHOR_CN__ = '{const.BILIBILI_NAME}';"
1222
1224
 
1225
+ # 添加.min.js文件的import语句
1226
+ if min_js_files:
1227
+ for min_js_path in min_js_files:
1228
+ min_js_filename = os.path.basename(min_js_path)
1229
+ total_js += f"\nimport \"./{min_js_filename}\";"
1230
+ total_js += "\n"
1231
+
1223
1232
  core.lprint(WAIT, LOC_GENERATING_TOTAL_MAIN_JS, end="", ln=config.language)
1224
1233
 
1225
1234
  # TODO: IMPS donot work
@@ -1285,19 +1294,29 @@ class Compiler(CompilerBase):
1285
1294
  def find_add_pure_js_files(self, sorts, modules):
1286
1295
  """
1287
1296
  找到所有的纯js文件,并添加到modules中
1297
+ 忽略.min.js文件,这些文件会被单独处理
1288
1298
  :param sorts:
1289
1299
  :param modules:
1290
- :return:
1300
+ :return: list 返回所有.min.js文件的列表
1291
1301
  """
1302
+ min_js_files = []
1292
1303
  for root, dirs, files in os.walk(self.lib_dir):
1293
1304
  for file in files:
1294
1305
  if file.endswith('.js') and file not in modules:
1295
- fpath = str(os.path.join(root, file))
1296
- fname = file.replace('\\', '/')
1297
- # copy file to target
1298
- shutil.copy(fpath, os.path.join(self.target_dir, fname))
1299
- sorts[fname] = self.__parse_js_file_sort(fpath)
1300
- modules.append("./" + fname)
1306
+ # 如果是.min.js文件,不拷贝到target,而是记录到单独列表
1307
+ if file.endswith('.min.js'):
1308
+ fpath = str(os.path.join(root, file))
1309
+ min_js_files.append(fpath)
1310
+ else:
1311
+ # 普通js文件,按原逻辑处理
1312
+ fpath = str(os.path.join(root, file))
1313
+ fname = file.replace('\\', '/')
1314
+ # copy file to target
1315
+ shutil.copy(fpath, os.path.join(self.target_dir, fname))
1316
+ sorts[fname] = self.__parse_js_file_sort(fpath)
1317
+ modules.append("./" + fname)
1318
+
1319
+ return min_js_files
1301
1320
 
1302
1321
  def compile(self, paste=False):
1303
1322
  """
@@ -1308,8 +1327,7 @@ class Compiler(CompilerBase):
1308
1327
  imps, jimps, sorts, defs, reps = self.pre_compile()
1309
1328
  self.transcrypt_cmd()
1310
1329
  imports, modules = self.analyze_rebuild_main_js(defs, jimps)
1311
- self.find_add_pure_js_files(sorts, modules)
1312
- total_js = imports + "\n" + self.generate_total_js(replace_src_prefix(modules), imps, sorts, self.FILE_STRONG_REPLACE, reps)
1330
+ min_js_files = self.find_add_pure_js_files(sorts, modules)
1313
1331
 
1314
1332
  core.lprint(WAIT, LOC_EXPORTING_TOTAL_MAIN_JS, end="", ln=config.language)
1315
1333
 
@@ -1320,12 +1338,28 @@ class Compiler(CompilerBase):
1320
1338
  if not mjs_path.endswith('js'):
1321
1339
  mjs_path = os.path.join(mjs_path, 'main.mjs')
1322
1340
 
1341
+ # 获取目标目录路径
1342
+ dir_path = os.path.dirname(mjs_path)
1343
+ build_dir_path = os.path.dirname(build_main_mjs)
1344
+
1345
+ # 复制.min.js文件到目标目录
1346
+ for min_js_path in min_js_files:
1347
+ min_js_filename = os.path.basename(min_js_path)
1348
+ # 复制到build目录
1349
+ shutil.copy(min_js_path, os.path.join(build_dir_path, min_js_filename))
1350
+ # 复制到最终导出目录
1351
+ shutil.copy(min_js_path, os.path.join(dir_path, min_js_filename))
1352
+
1353
+ # 生成total_js,传入.min.js文件列表
1354
+ total_js = imports + "\n" + self.generate_total_js(
1355
+ replace_src_prefix(modules), imps, sorts, self.FILE_STRONG_REPLACE, reps, min_js_files
1356
+ )
1357
+
1323
1358
  # write main.mjs
1324
1359
  with open(build_main_mjs, 'w', encoding='utf-8') as f:
1325
1360
  f.write(total_js)
1326
1361
 
1327
1362
  # export main.mjs
1328
- dir_path = os.path.dirname(mjs_path)
1329
1363
  if not os.path.exists(dir_path):
1330
1364
  core.error('Compiler.compile', core.lformat(LOC_EXPORT_DIR_PATH_NOT_EXISTS, [dir_path]), head='\n', ln=config.language)
1331
1365
  with open(mjs_path, 'w', encoding='utf-8') as f:
@@ -9,7 +9,7 @@
9
9
  #
10
10
  import re
11
11
 
12
- VERSION = "0.5.7.6"
12
+ VERSION = "0.5.8.2"
13
13
  AUTHOR = "●ω<🤍♪"
14
14
  STEAM_ID = "1029562896"
15
15
  GITHUB_NAME = "EagleBaby"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: pyscreeps-arena
3
- Version: 0.5.7.6
3
+ Version: 0.5.8.2
4
4
  Summary: Python api|interface to play game: Screeps: Arena.
5
5
  Author-email: 2229066748@qq.com
6
6
  Maintainer: Eagle'sBaby
@@ -7,7 +7,7 @@ with open(r"T:\New_PC\Import_Project\uploads\pyscreeps-arena_upload\pyscreeps-ar
7
7
  long_description = f.read()
8
8
  setup(
9
9
  name='pyscreeps-arena',
10
- version='0.5.7.6',
10
+ version='0.5.8.2',
11
11
  description='Python api|interface to play game: Screeps: Arena.',
12
12
  long_description=long_description,
13
13
  long_description_content_type='text/markdown',