pyscreeps-arena 0.3.6__tar.gz → 0.4a1__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.6 → pyscreeps-arena-0.4a1}/PKG-INFO +1 -1
  2. {pyscreeps-arena-0.3.6 → pyscreeps-arena-0.4a1}/pyscreeps_arena/__init__.py +2 -1
  3. {pyscreeps-arena-0.3.6 → pyscreeps-arena-0.4a1}/pyscreeps_arena/compiler.py +65 -25
  4. {pyscreeps-arena-0.3.6 → pyscreeps-arena-0.4a1}/pyscreeps_arena/core/config.py +1 -1
  5. {pyscreeps-arena-0.3.6 → pyscreeps-arena-0.4a1}/pyscreeps_arena/core/const.py +1 -1
  6. pyscreeps-arena-0.4a1/pyscreeps_arena/project.7z +0 -0
  7. {pyscreeps-arena-0.3.6 → pyscreeps-arena-0.4a1}/pyscreeps_arena.egg-info/PKG-INFO +1 -1
  8. {pyscreeps-arena-0.3.6 → pyscreeps-arena-0.4a1}/pyscreeps_arena.egg-info/entry_points.txt +1 -0
  9. {pyscreeps-arena-0.3.6 → pyscreeps-arena-0.4a1}/setup.py +2 -1
  10. pyscreeps-arena-0.3.6/pyscreeps_arena/project.7z +0 -0
  11. {pyscreeps-arena-0.3.6 → pyscreeps-arena-0.4a1}/pyscreeps_arena/build.py +0 -0
  12. {pyscreeps-arena-0.3.6 → pyscreeps-arena-0.4a1}/pyscreeps_arena/core/__init__.py +0 -0
  13. {pyscreeps-arena-0.3.6 → pyscreeps-arena-0.4a1}/pyscreeps_arena/core/basic.py +0 -0
  14. {pyscreeps-arena-0.3.6 → pyscreeps-arena-0.4a1}/pyscreeps_arena/core/core.py +0 -0
  15. {pyscreeps-arena-0.3.6 → pyscreeps-arena-0.4a1}/pyscreeps_arena/core/main.py +0 -0
  16. {pyscreeps-arena-0.3.6 → pyscreeps-arena-0.4a1}/pyscreeps_arena/core/utils.py +0 -0
  17. {pyscreeps-arena-0.3.6 → pyscreeps-arena-0.4a1}/pyscreeps_arena/localization.py +0 -0
  18. {pyscreeps-arena-0.3.6 → pyscreeps-arena-0.4a1}/pyscreeps_arena.egg-info/SOURCES.txt +0 -0
  19. {pyscreeps-arena-0.3.6 → pyscreeps-arena-0.4a1}/pyscreeps_arena.egg-info/dependency_links.txt +0 -0
  20. {pyscreeps-arena-0.3.6 → pyscreeps-arena-0.4a1}/pyscreeps_arena.egg-info/requires.txt +0 -0
  21. {pyscreeps-arena-0.3.6 → pyscreeps-arena-0.4a1}/pyscreeps_arena.egg-info/top_level.txt +0 -0
  22. {pyscreeps-arena-0.3.6 → pyscreeps-arena-0.4a1}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: pyscreeps-arena
3
- Version: 0.3.6
3
+ Version: 0.4a1
4
4
  Summary: Python api|interface to play game: Screeps: Arena.
5
5
  Author-email: 2229066748@qq.com
6
6
  Maintainer: Eagle'sBaby
@@ -7,6 +7,7 @@ def CMD_NewProject():
7
7
  """
8
8
  cmd:
9
9
  pyscreeps-arena [project_path]
10
+ arena [project_path]
10
11
 
11
12
  * 复制"src" "game" "build.py" 到指定目录
12
13
 
@@ -14,7 +15,7 @@ def CMD_NewProject():
14
15
 
15
16
  """
16
17
  if len(sys.argv) < 2:
17
- print("Usage: pyarena new [project_path]")
18
+ print("Usage: pyarena new [project_path]\n# or\narena new [project_path]")
18
19
  return
19
20
  project_path = sys.argv[1]
20
21
  if not os.path.exists(project_path):
@@ -43,7 +43,7 @@ class Compiler_Const:
43
43
 
44
44
  TOTAL_INSERT_AT_HEAD = """
45
45
  import { createConstructionSite, findClosestByPath, findClosestByRange, findInRange, findPath, getCpuTime, getDirection, getHeapStatistics, getObjectById, getObjects, getObjectsByPrototype, getRange, getTerrainAt, getTicks,} from 'game/utils';
46
- import { ConstructionSite, Creep, GameObject, OwnedStructure, Resource, Source, Structure, StructureContainer, StructureExtension, StructureRampart, StructureRoad, StructureSpawn, StructureWall, StructureTower} from 'game/prototypes';
46
+ import { ConstructionSite as GameConstructionSite, Creep as GameCreep, GameObject as GameObjectProto, OwnedStructure, Resource as GameResource, Source as GameSource, Structure as GameStructure, StructureContainer as GameStructureContainer, StructureExtension as GameStructureExtension, StructureRampart as GameStructureRampart, StructureRoad as GameStructureRoad, StructureSpawn as GameStructureSpawn, StructureWall as GameStructureWall, StructureTower as GameStructureTower} from 'game/prototypes';
47
47
  import { ATTACK, ATTACK_POWER, BODYPART_COST, BODYPART_HITS, BOTTOM, BOTTOM_LEFT, BOTTOM_RIGHT, BUILD_POWER, CARRY, CARRY_CAPACITY, CONSTRUCTION_COST, CONSTRUCTION_COST_ROAD_SWAMP_RATIO, CONSTRUCTION_COST_ROAD_WALL_RATIO, CONTAINER_CAPACITY, CONTAINER_HITS, CREEP_SPAWN_TIME, DISMANTLE_COST, DISMANTLE_POWER, ERR_BUSY, ERR_FULL, ERR_INVALID_ARGS, ERR_INVALID_TARGET, ERR_NAME_EXISTS, ERR_NOT_ENOUGH_ENERGY, ERR_NOT_ENOUGH_EXTENSIONS, ERR_NOT_ENOUGH_RESOURCES, ERR_NOT_FOUND, ERR_NOT_IN_RANGE, ERR_NOT_OWNER, ERR_NO_BODYPART, ERR_NO_PATH, ERR_TIRED, EXTENSION_ENERGY_CAPACITY, EXTENSION_HITS, HARVEST_POWER, HEAL, HEAL_POWER, LEFT, MAX_CONSTRUCTION_SITES, MAX_CREEP_SIZE, MOVE, OBSTACLE_OBJECT_TYPES, OK, RAMPART_HITS, RAMPART_HITS_MAX, RANGED_ATTACK, RANGED_ATTACK_DISTANCE_RATE, RANGED_ATTACK_POWER, RANGED_HEAL_POWER, REPAIR_COST, REPAIR_POWER, RESOURCES_ALL, RESOURCE_DECAY, RESOURCE_ENERGY, RIGHT, ROAD_HITS, ROAD_WEAROUT, SOURCE_ENERGY_REGEN, SPAWN_ENERGY_CAPACITY, SPAWN_HITS, STRUCTURE_PROTOTYPES, TERRAIN_PLAIN, TERRAIN_SWAMP, TERRAIN_WALL, TOP, TOP_LEFT, TOP_RIGHT, TOUGH, TOWER_CAPACITY, TOWER_COOLDOWN, TOWER_ENERGY_COST, TOWER_FALLOFF, TOWER_FALLOFF_RANGE, TOWER_HITS, TOWER_OPTIMAL_RANGE, TOWER_POWER_ATTACK, TOWER_POWER_HEAL, TOWER_POWER_REPAIR, TOWER_RANGE, WALL_HITS, WALL_HITS_MAX, WORK} from 'game/constants';
48
48
 
49
49
  import {arenaInfo} from "game";
@@ -56,27 +56,40 @@ import {searchPath, CostMatrix} from "game/path-finder"
56
56
 
57
57
  TOTAL_APPEND_ATEND = """
58
58
  export var sch = Scheduler();
59
- var monitor = Monitor(2);
59
+ var monitor = Monitor(1);
60
60
  know.now = 0;
61
61
 
62
- _SchedulerMeta.__types__ = []; // 清空js首次构造时引入的数据
63
- _StageMachineMeta.__recursive__ = []; // 清空js首次构造时引入的数据
62
+ StageMachineLogicMeta.__types__ = []; // 清空js首次构造时引入的数据
63
+ StageMachineLogicMeta.__recursive__ = []; // 清空js首次构造时引入的数据
64
64
  __init_my_exists_creep_before_k__();
65
+ let knowCost = 0;
66
+ let monitorCost = 0;
67
+ let stepCost = 0;
68
+ let timeLine = 0;
65
69
  export var loop = function () {
66
- know.now = get.ticks ();
70
+ get.handle();
71
+ know.now = get.now;
72
+ timeLine = get.cpu_us();
67
73
  know.handle();
74
+ knowCost = get.cpu_us() - timeLine;
68
75
  if (know.now === 1) {
69
76
  std.show_welcome();
70
77
  init (know);
78
+
71
79
  }
72
80
 
81
+ timeLine = get.cpu_us();
73
82
  monitor.handle();
74
- for (const creep of know._creeps){
75
- creep.motion.handle();
83
+ monitorCost = get.cpu_us() - timeLine;
84
+ for (const creep of get.creeps()){
85
+ creep.handle();
76
86
  }
77
87
  step (know);
88
+ timeLine = get.cpu_us();
78
89
  sch.handle();
90
+ stepCost = get.cpu_us() - timeLine;
79
91
  std.show_usage ();
92
+ print("knowCost:", knowCost, "monitorCost:", monitorCost, "stepCost:", stepCost);
80
93
  };
81
94
  """
82
95
 
@@ -114,42 +127,71 @@ export var loop = function () {
114
127
 
115
128
  ARENA_IMPORTS_GETTER = {
116
129
  const.ARENA_GREEN: lambda: f"""
117
- class BodyPart{{
130
+ class GameBodyPart{{
118
131
  constructor(){{
119
132
  }}
120
133
  }};
121
- const ScoreCollector = StructureSpawn;
134
+ class GameAreaEffect{{
135
+ constructor(){{
136
+ }}
137
+ }};
138
+ class GameFlag{{
139
+ constructor(){{
140
+ }}
141
+ }};
142
+ const GameScoreCollector = GameStructureSpawn;
143
+ const RESOURCE_SCORE_X = "undefined";
144
+ const RESOURCE_SCORE_Y = "undefined";
145
+ const RESOURCE_SCORE_Z = "undefined";
122
146
  """,
123
147
  const.ARENA_BLUE: lambda: f"""
124
- const ScoreCollector = StructureSpawn;
125
- import {{ Flag, BodyPart}} from 'arena/season_{config.season}/capture_the_flag/basic';
148
+ const GameScoreCollector = GameStructureSpawn;
149
+ class GameAreaEffect{{
150
+ constructor(){{
151
+ }}
152
+ }};
153
+ const RESOURCE_SCORE_X = "undefined";
154
+ const RESOURCE_SCORE_Y = "undefined";
155
+ const RESOURCE_SCORE_Z = "undefined";
156
+ import {{ Flag as GameFlag, BodyPart as GameBodyPart}} from 'arena/season_{config.season}/capture_the_flag/{"advanced" if config.level in ["advance", "advanced"] else "basic"}';
126
157
  """,
127
158
  const.ARENA_RED: lambda: f"""
128
- class BodyPart{{
159
+ class GameBodyPart{{
129
160
  constructor(){{
130
161
  }}
131
162
  }};
132
- import {{ RESOURCE_SCORE, ScoreCollector, AreaEffect, EFFECT_DAMAGE, EFFECT_FREEZE }} from 'arena/season_{config.season}/collect_and_control/basic';
163
+ class GameFlag{{
164
+ constructor(){{
165
+ }}
166
+ }};
167
+ import {{ RESOURCE_SCORE, ScoreCollector as GameScoreCollector, AreaEffect as GameAreaEffect, EFFECT_DAMAGE, EFFECT_FREEZE }} from 'arena/season_{config.season}/collect_and_control/basic';
133
168
 
134
- import ("arena/season_{config.season}/collect_and_control/basic")
169
+ {'''import ("arena/season_{config.season}/collect_and_control/advanced")
135
170
  .then((module) => {{ const RESOURCE_SCORE_X = module.RESOURCE_SCORE_X; const RESOURCE_SCORE_Y = module.RESOURCE_SCORE_Y; const RESOURCE_SCORE_Z = module.RESOURCE_SCORE_Z; }})
136
- .catch((error) => {{ }});
171
+ .catch((error) => {{ const RESOURCE_SCORE_X = "undefined"; const RESOURCE_SCORE_Y = "undefined"; const RESOURCE_SCORE_Z = "undefined"; }});''' if config.level in ['advanced', 'advanced'] else '''
172
+ const RESOURCE_SCORE_X = "undefined";
173
+ const RESOURCE_SCORE_Y = "undefined";
174
+ const RESOURCE_SCORE_Z = "undefined";
175
+ '''}
137
176
  """,
138
177
  const.ARENA_GRAY: lambda: f"""
139
- class BodyPart{{
178
+ class GameBodyPart{{
140
179
  constructor(){{
141
180
  }}
142
181
  }};
143
- const ScoreCollector = StructureSpawn;
182
+ class GameAreaEffect{{
183
+ constructor(){{
184
+ }}
185
+ }};
186
+ const GameScoreCollector = GameStructureSpawn;
187
+ const RESOURCE_SCORE_X = "undefined";
188
+ const RESOURCE_SCORE_Y = "undefined";
189
+ const RESOURCE_SCORE_Z = "undefined";
144
190
  import("game/prototypes")
145
- .then((module) => {{ const Flag = module.Flag; }})
146
- .catch((error) => {{ }});
191
+ .then((module) => {{ const GameFlag = module.Flag; }})
192
+ .catch((error) => {{ const GameFlag = undefined; }});
147
193
  """,
148
194
  }
149
- ARENA_IMPORTS_NOT_BLUE = ""
150
- ARENA_IMPORTS_NOT_BLUE1 = """
151
- import { StructureTower } from 'game/prototypes'
152
- """
153
195
 
154
196
 
155
197
  class Compiler_Utils(Compiler_Const):
@@ -721,8 +763,6 @@ class Compiler(CompilerBase):
721
763
  """
722
764
  arena_name = const.ARENA_NAMES.get(config.arena, const.ARENA_NAMES['green']) # like green -> spawn_and_swamp
723
765
  self.TOTAL_INSERT_AT_HEAD += self.ARENA_IMPORTS_GETTER[arena_name]() # add arena imports
724
- if config.arena != "blue":
725
- self.TOTAL_INSERT_AT_HEAD += self.ARENA_IMPORTS_NOT_BLUE
726
766
  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"
727
767
 
728
768
  core.lprint(WAIT, LOC_GENERATING_TOTAL_MAIN_JS, end="", ln=config.language)
@@ -15,5 +15,5 @@ season = "beta"
15
15
  language = 'cn'
16
16
  # 默认路径: 用户 + ScreepsArena + beta-spawn_and_swamp + main.mjs
17
17
  target = None
18
- TARGET_GETTER = lambda: os.path.join(os.path.expanduser('~'), 'ScreepsArena', f'{season}-{const.ARENA_NAMES.get(arena, "spawn_and_swamp")}', 'main.mjs')
18
+ TARGET_GETTER = lambda: os.path.join(os.path.expanduser('~'), 'ScreepsArena', f'{season}-{const.ARENA_NAMES.get(arena, "spawn_and_swamp")}{"-advanced" if level in ["advance", "advanced"] else ""}', 'main.mjs')
19
19
 
@@ -9,7 +9,7 @@
9
9
  #
10
10
  import re
11
11
 
12
- VERSION = "0.3.6"
12
+ VERSION = "0.4a1"
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.6
3
+ Version: 0.4a1
4
4
  Summary: Python api|interface to play game: Screeps: Arena.
5
5
  Author-email: 2229066748@qq.com
6
6
  Maintainer: Eagle'sBaby
@@ -1,2 +1,3 @@
1
1
  [console_scripts]
2
+ arena = pyscreeps_arena:CMD_NewProject
2
3
  pyscreeps-arena = pyscreeps_arena:CMD_NewProject
@@ -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.6',
10
+ version='0.4a1',
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',
@@ -26,6 +26,7 @@ setup(
26
26
  entry_points={
27
27
  'console_scripts': [
28
28
  'pyscreeps-arena=pyscreeps_arena:CMD_NewProject',
29
+ 'arena=pyscreeps_arena:CMD_NewProject',
29
30
  ]
30
31
  },
31
32
  keywords=['python', 'screeps:arena', 'screeps'],