pyscreeps-arena 0.3.3a0__tar.gz → 0.3.6__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.3.3a0 → pyscreeps-arena-0.3.6}/PKG-INFO +1 -1
  2. {pyscreeps-arena-0.3.3a0 → pyscreeps-arena-0.3.6}/pyscreeps_arena/compiler.py +44 -7
  3. {pyscreeps-arena-0.3.3a0 → pyscreeps-arena-0.3.6}/pyscreeps_arena/core/config.py +1 -0
  4. {pyscreeps-arena-0.3.3a0 → pyscreeps-arena-0.3.6}/pyscreeps_arena/core/const.py +1 -1
  5. pyscreeps-arena-0.3.6/pyscreeps_arena/project.7z +0 -0
  6. {pyscreeps-arena-0.3.3a0 → pyscreeps-arena-0.3.6}/pyscreeps_arena.egg-info/PKG-INFO +1 -1
  7. {pyscreeps-arena-0.3.3a0 → pyscreeps-arena-0.3.6}/setup.py +1 -1
  8. pyscreeps-arena-0.3.3a0/pyscreeps_arena/project.7z +0 -0
  9. {pyscreeps-arena-0.3.3a0 → pyscreeps-arena-0.3.6}/pyscreeps_arena/__init__.py +0 -0
  10. {pyscreeps-arena-0.3.3a0 → pyscreeps-arena-0.3.6}/pyscreeps_arena/build.py +0 -0
  11. {pyscreeps-arena-0.3.3a0 → pyscreeps-arena-0.3.6}/pyscreeps_arena/core/__init__.py +0 -0
  12. {pyscreeps-arena-0.3.3a0 → pyscreeps-arena-0.3.6}/pyscreeps_arena/core/basic.py +0 -0
  13. {pyscreeps-arena-0.3.3a0 → pyscreeps-arena-0.3.6}/pyscreeps_arena/core/core.py +0 -0
  14. {pyscreeps-arena-0.3.3a0 → pyscreeps-arena-0.3.6}/pyscreeps_arena/core/main.py +0 -0
  15. {pyscreeps-arena-0.3.3a0 → pyscreeps-arena-0.3.6}/pyscreeps_arena/core/utils.py +0 -0
  16. {pyscreeps-arena-0.3.3a0 → pyscreeps-arena-0.3.6}/pyscreeps_arena/localization.py +0 -0
  17. {pyscreeps-arena-0.3.3a0 → pyscreeps-arena-0.3.6}/pyscreeps_arena.egg-info/SOURCES.txt +0 -0
  18. {pyscreeps-arena-0.3.3a0 → pyscreeps-arena-0.3.6}/pyscreeps_arena.egg-info/dependency_links.txt +0 -0
  19. {pyscreeps-arena-0.3.3a0 → pyscreeps-arena-0.3.6}/pyscreeps_arena.egg-info/entry_points.txt +0 -0
  20. {pyscreeps-arena-0.3.3a0 → pyscreeps-arena-0.3.6}/pyscreeps_arena.egg-info/requires.txt +0 -0
  21. {pyscreeps-arena-0.3.3a0 → pyscreeps-arena-0.3.6}/pyscreeps_arena.egg-info/top_level.txt +0 -0
  22. {pyscreeps-arena-0.3.3a0 → pyscreeps-arena-0.3.6}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: pyscreeps-arena
3
- Version: 0.3.3a0
3
+ Version: 0.3.6
4
4
  Summary: Python api|interface to play game: Screeps: Arena.
5
5
  Author-email: 2229066748@qq.com
6
6
  Maintainer: Eagle'sBaby
@@ -48,7 +48,7 @@ import { ATTACK, ATTACK_POWER, BODYPART_COST, BODYPART_HITS, BOTTOM, BOTTOM_LEFT
48
48
 
49
49
  import {arenaInfo} from "game";
50
50
  import {Visual} from "game/visual"
51
- import {searchPath} from "game/path-finder"
51
+ import {searchPath, CostMatrix} from "game/path-finder"
52
52
  """
53
53
 
54
54
  TOTAL_INSERT_BEFORE_MAIN = """
@@ -56,16 +56,24 @@ import {searchPath} from "game/path-finder"
56
56
 
57
57
  TOTAL_APPEND_ATEND = """
58
58
  export var sch = Scheduler();
59
- var monitor = EngineMonitor();
59
+ var monitor = Monitor(2);
60
60
  know.now = 0;
61
+
62
+ _SchedulerMeta.__types__ = []; // 清空js首次构造时引入的数据
63
+ _StageMachineMeta.__recursive__ = []; // 清空js首次构造时引入的数据
64
+ __init_my_exists_creep_before_k__();
61
65
  export var loop = function () {
62
66
  know.now = get.ticks ();
67
+ know.handle();
63
68
  if (know.now === 1) {
69
+ std.show_welcome();
64
70
  init (know);
65
71
  }
66
72
 
67
- know.update_(know);
68
73
  monitor.handle();
74
+ for (const creep of know._creeps){
75
+ creep.motion.handle();
76
+ }
69
77
  step (know);
70
78
  sch.handle();
71
79
  std.show_usage ();
@@ -91,7 +99,7 @@ export var loop = function () {
91
99
 
92
100
  JS_VM = "org.transcrypt.__runtime__.js"
93
101
 
94
- BUILTIN_TRANS = ["engine.js"]
102
+ BUILTIN_TRANS = ["engine.js", "stage.js"] # 记录buildin中会被transcrypt的文件
95
103
  OTHER_IGNORE_WITH = "./builtin"
96
104
 
97
105
  JS_IMPORT_PAT = re.compile(r'from\s+[\'\"]([^\']+)[\'\"]')
@@ -106,7 +114,10 @@ export var loop = function () {
106
114
 
107
115
  ARENA_IMPORTS_GETTER = {
108
116
  const.ARENA_GREEN: lambda: f"""
109
- const BodyPart = {{type:MOVE}};
117
+ class BodyPart{{
118
+ constructor(){{
119
+ }}
120
+ }};
110
121
  const ScoreCollector = StructureSpawn;
111
122
  """,
112
123
  const.ARENA_BLUE: lambda: f"""
@@ -114,7 +125,10 @@ const ScoreCollector = StructureSpawn;
114
125
  import {{ Flag, BodyPart}} from 'arena/season_{config.season}/capture_the_flag/basic';
115
126
  """,
116
127
  const.ARENA_RED: lambda: f"""
117
- const BodyPart = {{type:MOVE}};
128
+ class BodyPart{{
129
+ constructor(){{
130
+ }}
131
+ }};
118
132
  import {{ RESOURCE_SCORE, ScoreCollector, AreaEffect, EFFECT_DAMAGE, EFFECT_FREEZE }} from 'arena/season_{config.season}/collect_and_control/basic';
119
133
 
120
134
  import ("arena/season_{config.season}/collect_and_control/basic")
@@ -122,7 +136,10 @@ import ("arena/season_{config.season}/collect_and_control/basic")
122
136
  .catch((error) => {{ }});
123
137
  """,
124
138
  const.ARENA_GRAY: lambda: f"""
125
- const BodyPart = {{type:MOVE}};
139
+ class BodyPart{{
140
+ constructor(){{
141
+ }}
142
+ }};
126
143
  const ScoreCollector = StructureSpawn;
127
144
  import("game/prototypes")
128
145
  .then((module) => {{ const Flag = module.Flag; }})
@@ -340,6 +357,18 @@ class Compiler_Utils(Compiler_Const):
340
357
  jsimps.append('./' + '.'.join(rel_path_nodes) + '.js')
341
358
  return jsimps
342
359
 
360
+ # ---------- 自定义函数 ---------- #
361
+ @staticmethod
362
+ def stage_recursive_replace(content:str) -> str:
363
+ """
364
+ 替换'@recursive'为'@recursive(<fname>)', 其中<fname>为被装饰器标记的函数名 |
365
+ Replace '@recursive' with '@recursive(<fname>)', where <fname> is the name of the decorated function.
366
+
367
+ @\s*recursive\s+def\s+([^\s\(]+)
368
+ """
369
+ return re.sub(r'@\s*recursive(\s+def\s+)([^\s\(]+)', r'@recursive("\2")\1\2', content)
370
+
371
+
343
372
 
344
373
  class CompilerBase(Compiler_Utils):
345
374
 
@@ -550,6 +579,14 @@ class Compiler(CompilerBase):
550
579
  with open(fpath, 'w', encoding='utf-8') as f:
551
580
  f.write(new_content)
552
581
 
582
+ # ------------------------------------ 自定义 ------------------------------------ #
583
+ # 调用stage_recursive_replace
584
+ for fpath in py_fpath:
585
+ content = self.auto_read(fpath)
586
+ content = self.stage_recursive_replace(content)
587
+ with open(fpath, 'w', encoding='utf-8') as f:
588
+ f.write(content)
589
+
553
590
  core.lprint(GREEN.format('[2/6]'), LOC_DONE, " ", LOC_PREPROCESSING_FINISH, sep="", head="\r", ln=config.language)
554
591
  return _imports, _js_imports, _pre_sort_, _pre_define_, _js_replace_
555
592
 
@@ -10,6 +10,7 @@
10
10
  import os
11
11
  from pyscreeps_arena.core import const
12
12
  arena = "green"
13
+ level = "basic"
13
14
  season = "beta"
14
15
  language = 'cn'
15
16
  # 默认路径: 用户 + ScreepsArena + beta-spawn_and_swamp + main.mjs
@@ -9,7 +9,7 @@
9
9
  #
10
10
  import re
11
11
 
12
- VERSION = "0.3.2a1"
12
+ VERSION = "0.3.6"
13
13
  AUTHOR = "我阅读理解一直可以的"
14
14
  STEAM_ID = "1029562896"
15
15
  GITHUB_NAME = "EagleBaby"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: pyscreeps-arena
3
- Version: 0.3.3a0
3
+ Version: 0.3.6
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.3.3a0',
10
+ version='0.3.6',
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',