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