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.
- {pyscreeps-arena-0.4a8 → pyscreeps-arena-0.4.1}/PKG-INFO +1 -1
- {pyscreeps-arena-0.4a8 → pyscreeps-arena-0.4.1}/pyscreeps_arena/compiler.py +62 -8
- {pyscreeps-arena-0.4a8 → pyscreeps-arena-0.4.1}/pyscreeps_arena/core/const.py +3 -2
- pyscreeps-arena-0.4.1/pyscreeps_arena/project.7z +0 -0
- {pyscreeps-arena-0.4a8 → pyscreeps-arena-0.4.1}/pyscreeps_arena.egg-info/PKG-INFO +1 -1
- {pyscreeps-arena-0.4a8 → pyscreeps-arena-0.4.1}/setup.py +1 -1
- pyscreeps-arena-0.4a8/pyscreeps_arena/project.7z +0 -0
- {pyscreeps-arena-0.4a8 → pyscreeps-arena-0.4.1}/pyscreeps_arena/__init__.py +0 -0
- {pyscreeps-arena-0.4a8 → pyscreeps-arena-0.4.1}/pyscreeps_arena/build.py +0 -0
- {pyscreeps-arena-0.4a8 → pyscreeps-arena-0.4.1}/pyscreeps_arena/core/__init__.py +0 -0
- {pyscreeps-arena-0.4a8 → pyscreeps-arena-0.4.1}/pyscreeps_arena/core/basic.py +0 -0
- {pyscreeps-arena-0.4a8 → pyscreeps-arena-0.4.1}/pyscreeps_arena/core/config.py +0 -0
- {pyscreeps-arena-0.4a8 → pyscreeps-arena-0.4.1}/pyscreeps_arena/core/core.py +0 -0
- {pyscreeps-arena-0.4a8 → pyscreeps-arena-0.4.1}/pyscreeps_arena/core/main.py +0 -0
- {pyscreeps-arena-0.4a8 → pyscreeps-arena-0.4.1}/pyscreeps_arena/core/utils.py +0 -0
- {pyscreeps-arena-0.4a8 → pyscreeps-arena-0.4.1}/pyscreeps_arena/localization.py +0 -0
- {pyscreeps-arena-0.4a8 → pyscreeps-arena-0.4.1}/pyscreeps_arena.egg-info/SOURCES.txt +0 -0
- {pyscreeps-arena-0.4a8 → pyscreeps-arena-0.4.1}/pyscreeps_arena.egg-info/dependency_links.txt +0 -0
- {pyscreeps-arena-0.4a8 → pyscreeps-arena-0.4.1}/pyscreeps_arena.egg-info/entry_points.txt +0 -0
- {pyscreeps-arena-0.4a8 → pyscreeps-arena-0.4.1}/pyscreeps_arena.egg-info/requires.txt +0 -0
- {pyscreeps-arena-0.4a8 → pyscreeps-arena-0.4.1}/pyscreeps_arena.egg-info/top_level.txt +0 -0
- {pyscreeps-arena-0.4a8 → pyscreeps-arena-0.4.1}/setup.cfg +0 -0
|
@@ -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) => {{
|
|
190
|
-
.catch((error) => {{
|
|
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__ = '
|
|
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.
|
|
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"
|
|
Binary file
|
|
@@ -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.
|
|
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',
|
|
Binary file
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{pyscreeps-arena-0.4a8 → pyscreeps-arena-0.4.1}/pyscreeps_arena.egg-info/dependency_links.txt
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|