pyscreeps-arena 0.4a7__py3-none-any.whl → 0.4b0__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.
- pyscreeps_arena/compiler.py +61 -8
- pyscreeps_arena/core/const.py +3 -2
- pyscreeps_arena/project.7z +0 -0
- {pyscreeps_arena-0.4a7.dist-info → pyscreeps_arena-0.4b0.dist-info}/METADATA +1 -1
- {pyscreeps_arena-0.4a7.dist-info → pyscreeps_arena-0.4b0.dist-info}/RECORD +8 -8
- {pyscreeps_arena-0.4a7.dist-info → pyscreeps_arena-0.4b0.dist-info}/WHEEL +0 -0
- {pyscreeps_arena-0.4a7.dist-info → pyscreeps_arena-0.4b0.dist-info}/entry_points.txt +0 -0
- {pyscreeps_arena-0.4a7.dist-info → pyscreeps_arena-0.4b0.dist-info}/top_level.txt +0 -0
pyscreeps_arena/compiler.py
CHANGED
|
@@ -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) => {{
|
|
190
|
-
.catch((error) => {{
|
|
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__ = '
|
|
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
|
|
pyscreeps_arena/core/const.py
CHANGED
|
@@ -9,10 +9,11 @@
|
|
|
9
9
|
#
|
|
10
10
|
import re
|
|
11
11
|
|
|
12
|
-
VERSION = "0.
|
|
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"
|
pyscreeps_arena/project.7z
CHANGED
|
Binary file
|
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
pyscreeps_arena/__init__.py,sha256=aQvVULggzXzf3INx0Rrlozdk8Aoxe01lU7b5xytK678,862
|
|
2
2
|
pyscreeps_arena/build.py,sha256=DQeGLnID2FjpsWTbnqwt2cOp28olWK68U67bfbFJSOU,177
|
|
3
|
-
pyscreeps_arena/compiler.py,sha256=
|
|
3
|
+
pyscreeps_arena/compiler.py,sha256=jpJp85rDhu3I0yN5w04VYwd9S4jx9Nsmedvhexwixu4,51725
|
|
4
4
|
pyscreeps_arena/localization.py,sha256=gBbrNybIJAHlkzeD6maF-ie6RKSwPBbnCNzg_1ge8-c,5656
|
|
5
|
-
pyscreeps_arena/project.7z,sha256=
|
|
5
|
+
pyscreeps_arena/project.7z,sha256=OxTuu8bvh2K2YmdrgK3xIB_n_nECdgHoIBTTVrt6jLE,105667
|
|
6
6
|
pyscreeps_arena/core/__init__.py,sha256=qoP_rx1TpbDLJoTm5via4XPwEPaV1FXr1SYvoVoHGms,41
|
|
7
7
|
pyscreeps_arena/core/basic.py,sha256=DFvyDTsTXf2bQtnS9s254TrkshvRwajaHcvTyVvJyqw,2790
|
|
8
8
|
pyscreeps_arena/core/config.py,sha256=lVk9ynNBDKEkgFnCOsd93w4Q0JiyRPRhTEASLg1KHPw,592
|
|
9
|
-
pyscreeps_arena/core/const.py,sha256=
|
|
9
|
+
pyscreeps_arena/core/const.py,sha256=IMYQNBxV8TTAT5n_aO6SKrFE4ybxKl4te3dOza2oGoM,587
|
|
10
10
|
pyscreeps_arena/core/core.py,sha256=3Nty8eLKPNgwnYk_sVNBPrWuKxBXI2od8nfEezsEAZQ,5157
|
|
11
11
|
pyscreeps_arena/core/main.py,sha256=-FNSOEjksNlDfCbUqsjtPSUW8vT3qxEdfzXqT5Tdsik,170
|
|
12
12
|
pyscreeps_arena/core/utils.py,sha256=N9OOkORvrqnJakayaFp9qyS0apWhB9lBK4xyyYkhFdo,215
|
|
13
|
-
pyscreeps_arena-0.
|
|
14
|
-
pyscreeps_arena-0.
|
|
15
|
-
pyscreeps_arena-0.
|
|
16
|
-
pyscreeps_arena-0.
|
|
17
|
-
pyscreeps_arena-0.
|
|
13
|
+
pyscreeps_arena-0.4b0.dist-info/METADATA,sha256=Yb1X_tK4NOKqr0RijBeL5n-IF_FCgyAeLPNUm-mRStQ,2079
|
|
14
|
+
pyscreeps_arena-0.4b0.dist-info/WHEEL,sha256=yQN5g4mg4AybRjkgi-9yy4iQEFibGQmlz78Pik5Or-A,92
|
|
15
|
+
pyscreeps_arena-0.4b0.dist-info/entry_points.txt,sha256=mLTkJAsgPBEmFkrxNoo3dvb0_dAzSn9jf4Wh09PjdVU,106
|
|
16
|
+
pyscreeps_arena-0.4b0.dist-info/top_level.txt,sha256=l4uLyMR2NOy41ngBMh795jOHTFk3tgYKy64-9cgjVng,16
|
|
17
|
+
pyscreeps_arena-0.4b0.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|