pyscreeps-arena 0.3.6__py3-none-any.whl → 0.4a1__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/__init__.py +2 -1
- pyscreeps_arena/compiler.py +65 -25
- pyscreeps_arena/core/config.py +1 -1
- pyscreeps_arena/core/const.py +1 -1
- pyscreeps_arena/project.7z +0 -0
- {pyscreeps_arena-0.3.6.dist-info → pyscreeps_arena-0.4a1.dist-info}/METADATA +1 -1
- pyscreeps_arena-0.4a1.dist-info/RECORD +17 -0
- {pyscreeps_arena-0.3.6.dist-info → pyscreeps_arena-0.4a1.dist-info}/entry_points.txt +1 -0
- pyscreeps_arena-0.3.6.dist-info/RECORD +0 -17
- {pyscreeps_arena-0.3.6.dist-info → pyscreeps_arena-0.4a1.dist-info}/WHEEL +0 -0
- {pyscreeps_arena-0.3.6.dist-info → pyscreeps_arena-0.4a1.dist-info}/top_level.txt +0 -0
pyscreeps_arena/__init__.py
CHANGED
|
@@ -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):
|
pyscreeps_arena/compiler.py
CHANGED
|
@@ -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(
|
|
59
|
+
var monitor = Monitor(1);
|
|
60
60
|
know.now = 0;
|
|
61
61
|
|
|
62
|
-
|
|
63
|
-
|
|
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
|
-
|
|
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
|
-
|
|
75
|
-
|
|
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
|
|
130
|
+
class GameBodyPart{{
|
|
118
131
|
constructor(){{
|
|
119
132
|
}}
|
|
120
133
|
}};
|
|
121
|
-
|
|
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
|
|
125
|
-
|
|
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
|
|
159
|
+
class GameBodyPart{{
|
|
129
160
|
constructor(){{
|
|
130
161
|
}}
|
|
131
162
|
}};
|
|
132
|
-
|
|
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/
|
|
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
|
|
178
|
+
class GameBodyPart{{
|
|
140
179
|
constructor(){{
|
|
141
180
|
}}
|
|
142
181
|
}};
|
|
143
|
-
|
|
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
|
|
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)
|
pyscreeps_arena/core/config.py
CHANGED
|
@@ -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
|
|
pyscreeps_arena/core/const.py
CHANGED
pyscreeps_arena/project.7z
CHANGED
|
Binary file
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
pyscreeps_arena/__init__.py,sha256=aQvVULggzXzf3INx0Rrlozdk8Aoxe01lU7b5xytK678,862
|
|
2
|
+
pyscreeps_arena/build.py,sha256=DQeGLnID2FjpsWTbnqwt2cOp28olWK68U67bfbFJSOU,177
|
|
3
|
+
pyscreeps_arena/compiler.py,sha256=OihFaEmNtHYXLPwvm6rP9mP1OFWcAUvS16NxcuTuqyU,44760
|
|
4
|
+
pyscreeps_arena/localization.py,sha256=gBbrNybIJAHlkzeD6maF-ie6RKSwPBbnCNzg_1ge8-c,5656
|
|
5
|
+
pyscreeps_arena/project.7z,sha256=usYbo8Dhajy_ejzNzEuuk7WWiXdWoaVHcZoqhZg37z4,82498
|
|
6
|
+
pyscreeps_arena/core/__init__.py,sha256=qoP_rx1TpbDLJoTm5via4XPwEPaV1FXr1SYvoVoHGms,41
|
|
7
|
+
pyscreeps_arena/core/basic.py,sha256=DFvyDTsTXf2bQtnS9s254TrkshvRwajaHcvTyVvJyqw,2790
|
|
8
|
+
pyscreeps_arena/core/config.py,sha256=lVk9ynNBDKEkgFnCOsd93w4Q0JiyRPRhTEASLg1KHPw,592
|
|
9
|
+
pyscreeps_arena/core/const.py,sha256=P3UZB28ls6Z8bNxXfubpvoNVwXposm45oLIomFvx8Jw,552
|
|
10
|
+
pyscreeps_arena/core/core.py,sha256=3Nty8eLKPNgwnYk_sVNBPrWuKxBXI2od8nfEezsEAZQ,5157
|
|
11
|
+
pyscreeps_arena/core/main.py,sha256=-FNSOEjksNlDfCbUqsjtPSUW8vT3qxEdfzXqT5Tdsik,170
|
|
12
|
+
pyscreeps_arena/core/utils.py,sha256=N9OOkORvrqnJakayaFp9qyS0apWhB9lBK4xyyYkhFdo,215
|
|
13
|
+
pyscreeps_arena-0.4a1.dist-info/METADATA,sha256=ObJNmHfSGi_JbbqBFXQTxflu_kO-k5Udt0kESWuGuuU,2079
|
|
14
|
+
pyscreeps_arena-0.4a1.dist-info/WHEEL,sha256=oiQVh_5PnQM0E3gPdiz09WCNmwiHDMaGer_elqB3coM,92
|
|
15
|
+
pyscreeps_arena-0.4a1.dist-info/entry_points.txt,sha256=mLTkJAsgPBEmFkrxNoo3dvb0_dAzSn9jf4Wh09PjdVU,106
|
|
16
|
+
pyscreeps_arena-0.4a1.dist-info/top_level.txt,sha256=l4uLyMR2NOy41ngBMh795jOHTFk3tgYKy64-9cgjVng,16
|
|
17
|
+
pyscreeps_arena-0.4a1.dist-info/RECORD,,
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
pyscreeps_arena/__init__.py,sha256=3O7Oa_IofW8YQYsnrU88SGYNxn-CMR-PpmV8P2hhEhc,800
|
|
2
|
-
pyscreeps_arena/build.py,sha256=DQeGLnID2FjpsWTbnqwt2cOp28olWK68U67bfbFJSOU,177
|
|
3
|
-
pyscreeps_arena/compiler.py,sha256=4rmFo4ah6GZl12wB3RrKqac_pmn_IYcX37rEpOzwYac,43203
|
|
4
|
-
pyscreeps_arena/localization.py,sha256=gBbrNybIJAHlkzeD6maF-ie6RKSwPBbnCNzg_1ge8-c,5656
|
|
5
|
-
pyscreeps_arena/project.7z,sha256=WgobRTq_uG0C-k9kn5kji0ug5sXmLyY6RWr8gMbCMdY,86873
|
|
6
|
-
pyscreeps_arena/core/__init__.py,sha256=qoP_rx1TpbDLJoTm5via4XPwEPaV1FXr1SYvoVoHGms,41
|
|
7
|
-
pyscreeps_arena/core/basic.py,sha256=DFvyDTsTXf2bQtnS9s254TrkshvRwajaHcvTyVvJyqw,2790
|
|
8
|
-
pyscreeps_arena/core/config.py,sha256=U38Z-GiIXPSiAsPKKmOw52AS35Q_tP018H1VUSX6APU,535
|
|
9
|
-
pyscreeps_arena/core/const.py,sha256=vGLNcjVX8ydpK_-RPdTAhtyzOsBErd_idzfORQfh6rU,552
|
|
10
|
-
pyscreeps_arena/core/core.py,sha256=3Nty8eLKPNgwnYk_sVNBPrWuKxBXI2od8nfEezsEAZQ,5157
|
|
11
|
-
pyscreeps_arena/core/main.py,sha256=-FNSOEjksNlDfCbUqsjtPSUW8vT3qxEdfzXqT5Tdsik,170
|
|
12
|
-
pyscreeps_arena/core/utils.py,sha256=N9OOkORvrqnJakayaFp9qyS0apWhB9lBK4xyyYkhFdo,215
|
|
13
|
-
pyscreeps_arena-0.3.6.dist-info/METADATA,sha256=5Ja6mnFYo-VlmhkVf6JWH_yVDXWg-592FbkpykfmaL8,2079
|
|
14
|
-
pyscreeps_arena-0.3.6.dist-info/WHEEL,sha256=oiQVh_5PnQM0E3gPdiz09WCNmwiHDMaGer_elqB3coM,92
|
|
15
|
-
pyscreeps_arena-0.3.6.dist-info/entry_points.txt,sha256=dqhZN327jfcNypYjEaEJ2t-ABUZ0sVhtDDrD7GiJBfo,67
|
|
16
|
-
pyscreeps_arena-0.3.6.dist-info/top_level.txt,sha256=l4uLyMR2NOy41ngBMh795jOHTFk3tgYKy64-9cgjVng,16
|
|
17
|
-
pyscreeps_arena-0.3.6.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|