pyscreeps-arena 0.3.6__py3-none-any.whl → 0.4a0__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 +48 -22
- pyscreeps_arena/core/const.py +1 -1
- pyscreeps_arena/project.7z +0 -0
- {pyscreeps_arena-0.3.6.dist-info → pyscreeps_arena-0.4a0.dist-info}/METADATA +1 -1
- {pyscreeps_arena-0.3.6.dist-info → pyscreeps_arena-0.4a0.dist-info}/RECORD +9 -9
- {pyscreeps_arena-0.3.6.dist-info → pyscreeps_arena-0.4a0.dist-info}/entry_points.txt +1 -0
- {pyscreeps_arena-0.3.6.dist-info → pyscreeps_arena-0.4a0.dist-info}/WHEEL +0 -0
- {pyscreeps_arena-0.3.6.dist-info → pyscreeps_arena-0.4a0.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";
|
|
@@ -59,24 +59,36 @@ export var sch = Scheduler();
|
|
|
59
59
|
var monitor = Monitor(2);
|
|
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);
|
|
71
78
|
}
|
|
72
79
|
|
|
80
|
+
timeLine = get.cpu_us();
|
|
73
81
|
monitor.handle();
|
|
74
|
-
|
|
75
|
-
|
|
82
|
+
monitorCost = get.cpu_us() - timeLine;
|
|
83
|
+
for (const creep of get.creeps()){
|
|
84
|
+
creep.handle();
|
|
76
85
|
}
|
|
77
86
|
step (know);
|
|
87
|
+
timeLine = get.cpu_us();
|
|
78
88
|
sch.handle();
|
|
89
|
+
stepCost = get.cpu_us() - timeLine;
|
|
79
90
|
std.show_usage ();
|
|
91
|
+
print("knowCost:", knowCost, "monitorCost:", monitorCost, "stepCost:", stepCost);
|
|
80
92
|
};
|
|
81
93
|
"""
|
|
82
94
|
|
|
@@ -114,42 +126,58 @@ export var loop = function () {
|
|
|
114
126
|
|
|
115
127
|
ARENA_IMPORTS_GETTER = {
|
|
116
128
|
const.ARENA_GREEN: lambda: f"""
|
|
117
|
-
class
|
|
129
|
+
class GameBodyPart{{
|
|
118
130
|
constructor(){{
|
|
119
131
|
}}
|
|
120
132
|
}};
|
|
121
|
-
|
|
133
|
+
class GameAreaEffect{{
|
|
134
|
+
constructor(){{
|
|
135
|
+
}}
|
|
136
|
+
}};
|
|
137
|
+
class GameFlag{{
|
|
138
|
+
constructor(){{
|
|
139
|
+
}}
|
|
140
|
+
}};
|
|
141
|
+
const GameScoreCollector = GameStructureSpawn;
|
|
122
142
|
""",
|
|
123
143
|
const.ARENA_BLUE: lambda: f"""
|
|
124
|
-
const
|
|
125
|
-
|
|
144
|
+
const GameScoreCollector = GameStructureSpawn;
|
|
145
|
+
class GameAreaEffect{{
|
|
146
|
+
constructor(){{
|
|
147
|
+
}}
|
|
148
|
+
}};
|
|
149
|
+
import {{ Flag as GameFlag, BodyPart as GameBodyPart}} from 'arena/season_{config.season}/capture_the_flag/basic';
|
|
126
150
|
""",
|
|
127
151
|
const.ARENA_RED: lambda: f"""
|
|
128
|
-
class
|
|
152
|
+
class GameBodyPart{{
|
|
129
153
|
constructor(){{
|
|
130
154
|
}}
|
|
131
155
|
}};
|
|
132
|
-
|
|
156
|
+
class GameFlag{{
|
|
157
|
+
constructor(){{
|
|
158
|
+
}}
|
|
159
|
+
}};
|
|
160
|
+
import {{ RESOURCE_SCORE, ScoreCollector as GameScoreCollector, AreaEffect as GameAreaEffect, EFFECT_DAMAGE, EFFECT_FREEZE }} from 'arena/season_{config.season}/collect_and_control/basic';
|
|
133
161
|
|
|
134
162
|
import ("arena/season_{config.season}/collect_and_control/basic")
|
|
135
163
|
.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
164
|
.catch((error) => {{ }});
|
|
137
165
|
""",
|
|
138
166
|
const.ARENA_GRAY: lambda: f"""
|
|
139
|
-
class
|
|
167
|
+
class GameBodyPart{{
|
|
140
168
|
constructor(){{
|
|
141
169
|
}}
|
|
142
170
|
}};
|
|
143
|
-
|
|
171
|
+
class GameAreaEffect{{
|
|
172
|
+
constructor(){{
|
|
173
|
+
}}
|
|
174
|
+
}};
|
|
175
|
+
const GameScoreCollector = GameStructureSpawn;
|
|
144
176
|
import("game/prototypes")
|
|
145
|
-
.then((module) => {{ const
|
|
146
|
-
.catch((error) => {{ }});
|
|
177
|
+
.then((module) => {{ const GameFlag = module.Flag; }})
|
|
178
|
+
.catch((error) => {{ const GameFlag = undefined; }});
|
|
147
179
|
""",
|
|
148
180
|
}
|
|
149
|
-
ARENA_IMPORTS_NOT_BLUE = ""
|
|
150
|
-
ARENA_IMPORTS_NOT_BLUE1 = """
|
|
151
|
-
import { StructureTower } from 'game/prototypes'
|
|
152
|
-
"""
|
|
153
181
|
|
|
154
182
|
|
|
155
183
|
class Compiler_Utils(Compiler_Const):
|
|
@@ -721,8 +749,6 @@ class Compiler(CompilerBase):
|
|
|
721
749
|
"""
|
|
722
750
|
arena_name = const.ARENA_NAMES.get(config.arena, const.ARENA_NAMES['green']) # like green -> spawn_and_swamp
|
|
723
751
|
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
752
|
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
753
|
|
|
728
754
|
core.lprint(WAIT, LOC_GENERATING_TOTAL_MAIN_JS, end="", ln=config.language)
|
pyscreeps_arena/core/const.py
CHANGED
pyscreeps_arena/project.7z
CHANGED
|
Binary file
|
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
pyscreeps_arena/__init__.py,sha256=
|
|
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=FakYyCZuGGxwarF_K700u9pVreZzdw-p72-m8uypzps,44042
|
|
4
4
|
pyscreeps_arena/localization.py,sha256=gBbrNybIJAHlkzeD6maF-ie6RKSwPBbnCNzg_1ge8-c,5656
|
|
5
|
-
pyscreeps_arena/project.7z,sha256=
|
|
5
|
+
pyscreeps_arena/project.7z,sha256=crcLRbbeGLjgy0wQul1vvwfKoy0Chz3lew5m0f8hgz8,80026
|
|
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=U38Z-GiIXPSiAsPKKmOw52AS35Q_tP018H1VUSX6APU,535
|
|
9
|
-
pyscreeps_arena/core/const.py,sha256=
|
|
9
|
+
pyscreeps_arena/core/const.py,sha256=nky-fIzQcWWIT3ccRg-9aviCBNiC2BygaYyyw5GqPMY,552
|
|
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.4a0.dist-info/METADATA,sha256=gdIKdN3rM9OAVBGud5q_MENg6ffGiyhdBa9Nlj--LkI,2079
|
|
14
|
+
pyscreeps_arena-0.4a0.dist-info/WHEEL,sha256=oiQVh_5PnQM0E3gPdiz09WCNmwiHDMaGer_elqB3coM,92
|
|
15
|
+
pyscreeps_arena-0.4a0.dist-info/entry_points.txt,sha256=mLTkJAsgPBEmFkrxNoo3dvb0_dAzSn9jf4Wh09PjdVU,106
|
|
16
|
+
pyscreeps_arena-0.4a0.dist-info/top_level.txt,sha256=l4uLyMR2NOy41ngBMh795jOHTFk3tgYKy64-9cgjVng,16
|
|
17
|
+
pyscreeps_arena-0.4a0.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|