pyscreeps-arena 0.4a7__tar.gz → 0.4b0__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 (22) hide show
  1. {pyscreeps-arena-0.4a7 → pyscreeps-arena-0.4b0}/PKG-INFO +1 -1
  2. {pyscreeps-arena-0.4a7 → pyscreeps-arena-0.4b0}/pyscreeps_arena/compiler.py +61 -8
  3. {pyscreeps-arena-0.4a7 → pyscreeps-arena-0.4b0}/pyscreeps_arena/core/const.py +3 -2
  4. pyscreeps-arena-0.4b0/pyscreeps_arena/project.7z +0 -0
  5. {pyscreeps-arena-0.4a7 → pyscreeps-arena-0.4b0}/pyscreeps_arena.egg-info/PKG-INFO +1 -1
  6. {pyscreeps-arena-0.4a7 → pyscreeps-arena-0.4b0}/setup.py +1 -1
  7. pyscreeps-arena-0.4a7/pyscreeps_arena/project.7z +0 -0
  8. {pyscreeps-arena-0.4a7 → pyscreeps-arena-0.4b0}/pyscreeps_arena/__init__.py +0 -0
  9. {pyscreeps-arena-0.4a7 → pyscreeps-arena-0.4b0}/pyscreeps_arena/build.py +0 -0
  10. {pyscreeps-arena-0.4a7 → pyscreeps-arena-0.4b0}/pyscreeps_arena/core/__init__.py +0 -0
  11. {pyscreeps-arena-0.4a7 → pyscreeps-arena-0.4b0}/pyscreeps_arena/core/basic.py +0 -0
  12. {pyscreeps-arena-0.4a7 → pyscreeps-arena-0.4b0}/pyscreeps_arena/core/config.py +0 -0
  13. {pyscreeps-arena-0.4a7 → pyscreeps-arena-0.4b0}/pyscreeps_arena/core/core.py +0 -0
  14. {pyscreeps-arena-0.4a7 → pyscreeps-arena-0.4b0}/pyscreeps_arena/core/main.py +0 -0
  15. {pyscreeps-arena-0.4a7 → pyscreeps-arena-0.4b0}/pyscreeps_arena/core/utils.py +0 -0
  16. {pyscreeps-arena-0.4a7 → pyscreeps-arena-0.4b0}/pyscreeps_arena/localization.py +0 -0
  17. {pyscreeps-arena-0.4a7 → pyscreeps-arena-0.4b0}/pyscreeps_arena.egg-info/SOURCES.txt +0 -0
  18. {pyscreeps-arena-0.4a7 → pyscreeps-arena-0.4b0}/pyscreeps_arena.egg-info/dependency_links.txt +0 -0
  19. {pyscreeps-arena-0.4a7 → pyscreeps-arena-0.4b0}/pyscreeps_arena.egg-info/entry_points.txt +0 -0
  20. {pyscreeps-arena-0.4a7 → pyscreeps-arena-0.4b0}/pyscreeps_arena.egg-info/requires.txt +0 -0
  21. {pyscreeps-arena-0.4a7 → pyscreeps-arena-0.4b0}/pyscreeps_arena.egg-info/top_level.txt +0 -0
  22. {pyscreeps-arena-0.4a7 → pyscreeps-arena-0.4b0}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: pyscreeps-arena
3
- Version: 0.4a7
3
+ Version: 0.4b0
4
4
  Summary: Python api|interface to play game: Screeps: Arena.
5
5
  Author-email: 2229066748@qq.com
6
6
  Maintainer: Eagle'sBaby
@@ -60,7 +60,6 @@ var monitor = Monitor(1);
60
60
  know.now = 0;
61
61
 
62
62
  StageMachineLogicMeta.__types__ = []; // 清空js首次构造时引入的数据
63
- StageMachineLogicMeta.__recursive__ = []; // 清空js首次构造时引入的数据
64
63
  __init_my_exists_creep_before_k__();
65
64
  let knowCost = 0;
66
65
  let monitorCost = 0;
@@ -185,9 +184,10 @@ const GameScoreCollector = GameStructureSpawn;
185
184
  const RESOURCE_SCORE_X = "undefined";
186
185
  const RESOURCE_SCORE_Y = "undefined";
187
186
  const RESOURCE_SCORE_Z = "undefined";
187
+ let GameFlag = GameStructureSpawn;
188
188
  import("game/prototypes")
189
- .then((module) => {{ const GameFlag = module.Flag; }})
190
- .catch((error) => {{ const GameFlag = undefined; }});
189
+ .then((module) => {{ GameFlag = module.Flag; }})
190
+ .catch((error) => {{}});
191
191
  """,
192
192
  }
193
193
 
@@ -336,7 +336,7 @@ class Compiler_Utils(Compiler_Const):
336
336
  if records is None:
337
337
  records = {}
338
338
  if not os.path.exists(fpath):
339
- core.error('Compiler.find_chain_import', core.lformat(LOC_FILE_NOT_EXISTS, [fpath]), head='\n', ln=config.language)
339
+ core.error('Compiler.find_chain_import', core.lformat(LOC_FILE_NOT_EXISTS, ["py", fpath]), head='\n', ln=config.language)
340
340
  imps = []
341
341
  content = self.auto_read(fpath)
342
342
  project_path = project_path or os.path.dirname(fpath)
@@ -482,7 +482,52 @@ class Compiler_Utils(Compiler_Const):
482
482
  @\s*recursive\s+def\s+([^\s\(]+)
483
483
  """
484
484
  return re.sub(r'@\s*recursive(\s+def\s+)([^\s\(]+)', r'@recursive("\2")\1\2', content)
485
+
486
+ @staticmethod
487
+ def process_mate_code(code):
488
+ # 用于存储匹配到的信息
489
+ mate_assignments = []
490
+ # 匹配变量赋值为Mate()的正则表达式,允许变量定义中包含或不包含类型注解
491
+ assign_pattern = re.compile(r'(\w+)\s*(?:\:\s*\w*)?\s*=\s*Mate\s*\(')
492
+ # 匹配类定义的正则表达式
493
+ class_pattern = re.compile(r'class\s+(\w+)')
494
+ # 用于记录当前所在的类名
495
+ current_class = None
496
+ # 将代码按行分割
497
+ lines = code.split('\n')
498
+ # 遍历每一行
499
+ for i, line in enumerate(lines):
500
+ # 匹配类定义
501
+ class_match = class_pattern.match(line)
502
+ if class_match:
503
+ current_class = class_match.group(1)
504
+ # 匹配变量赋值为Mate()
505
+ assign_match = assign_pattern.search(line)
506
+ if assign_match:
507
+ # 检查group(1)前面同一行内是否有#,如果有则忽略
508
+ comment = re.search(r'#', line[:assign_match.start()])
509
+ if comment:
510
+ continue
511
+ variable_name = assign_match.group(1)
512
+ # 存储匹配到的信息
513
+ mate_assignments += [(variable_name, current_class)]
514
+
515
+ output_strings = []
516
+ for variable_name, class_name in mate_assignments:
517
+ output_string = f"# > insert Object.defineProperty ({class_name}, '{variable_name}', property.call ({class_name}, {class_name}.{variable_name}._MateGet_, {class_name}.{variable_name}._MateSet_));"
518
+ output_strings.append(output_string)
519
+
520
+ return code + '\n'.join(output_strings)
521
+
485
522
 
523
+ @staticmethod
524
+ def remove_long_docstring(content:str) -> str:
525
+ """
526
+ 移除长注释 | remove long docstring
527
+ """
528
+ code = re.sub(r'"""[^"]*"""', '', content)
529
+ code = re.sub(r"'''[^']*'''", '', code)
530
+ return code
486
531
 
487
532
 
488
533
  class CompilerBase(Compiler_Utils):
@@ -552,6 +597,7 @@ class Compiler(CompilerBase):
552
597
  # 将PYFILE_PRAGMA_INSERTS.replace("\t", "").replace(" ", "")插入到文件开头
553
598
  content = self.auto_read(fpath)
554
599
  content = self.PYFILE_PRAGMA_INSERTS.replace("\t", "").replace(" ", "") + content
600
+ # content = self.remove_long_docstring(content) # 移除长注释 | remove long docstring
555
601
 
556
602
  with open(fpath, 'w', encoding='utf-8') as f: # 注意,这里修改的是build目录下的文件,不是源文件 | Note that the file under the build directory is modified here, not the source file
557
603
  f.write(content)
@@ -623,6 +669,13 @@ class Compiler(CompilerBase):
623
669
  else:
624
670
  _pre_sort_[fname] = 65535
625
671
 
672
+ # ------------------------------------ 自定义:调用process_mate_code ------------------------------------ #
673
+ for fpath in py_fpath:
674
+ content = self.auto_read(fpath)
675
+ content = self.process_mate_code(content) # 调用process_mate_code
676
+ with open(fpath, 'w', encoding='utf-8') as f:
677
+ f.write(content)
678
+
626
679
  # ------------------------------------ DEFINE ------------------------------------ #
627
680
  # 扫描所有# > define的内容,然后在.py中移除这些行,并记录下来
628
681
  # | get all # > define in .py files, and record them
@@ -696,14 +749,14 @@ class Compiler(CompilerBase):
696
749
  with open(fpath, 'w', encoding='utf-8') as f:
697
750
  f.write(new_content)
698
751
 
699
- # ------------------------------------ 自定义 ------------------------------------ #
700
- # 调用stage_recursive_replace
752
+ # ------------------------------------ 自定义:调用stage_recursive_replace ------------------------------------ #
701
753
  for fpath in py_fpath:
702
754
  content = self.auto_read(fpath)
703
- content = self.stage_recursive_replace(content)
755
+ content = self.stage_recursive_replace(content) # 调用stage_recursive_replace
704
756
  with open(fpath, 'w', encoding='utf-8') as f:
705
757
  f.write(content)
706
758
 
759
+
707
760
  core.lprint(GREEN.format('[2/6]'), LOC_DONE, " ", LOC_PREPROCESSING_FINISH, sep="", head="\r", ln=config.language)
708
761
  return _imports, _js_imports, _pre_sort_, _pre_define_, _js_replace_
709
762
 
@@ -839,7 +892,7 @@ class Compiler(CompilerBase):
839
892
  arena_name = const.ARENA_NAMES.get(config.arena, const.ARENA_NAMES['green']) # like green -> spawn_and_swamp
840
893
  self.TOTAL_INSERT_AT_HEAD += self.ARENA_IMPORTS_GETTER[arena_name]() # add arena imports
841
894
  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"
842
- total_js += f"const __AUTHOR__ = '---unfilled---';\n"
895
+ total_js += f"const __AUTHOR__ = '{const.AUTHOR}';\nconst __AUTHOR_CN__ = '{const.BILIBILI_NAME}';"
843
896
 
844
897
  core.lprint(WAIT, LOC_GENERATING_TOTAL_MAIN_JS, end="", ln=config.language)
845
898
 
@@ -9,10 +9,11 @@
9
9
  #
10
10
  import re
11
11
 
12
- VERSION = "0.4a7"
13
- AUTHOR = "我阅读理解一直可以的"
12
+ VERSION = "0.4b0"
13
+ AUTHOR = "●ω<🤍♪"
14
14
  STEAM_ID = "1029562896"
15
15
  GITHUB_NAME = "EagleBaby"
16
+ BILIBILI_NAME = "我阅读理解一直可以的"
16
17
 
17
18
  ARENA_GREEN = "spawn_and_swamp"
18
19
  ARENA_BLUE = "capture_the_flag"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: pyscreeps-arena
3
- Version: 0.4a7
3
+ Version: 0.4b0
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.4a7',
10
+ version='0.4b0',
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',