简化测试关卡

This commit is contained in:
星外之神 2022-08-05 14:23:36 +08:00
parent 95b4d789e5
commit 0493ec70d5
2 changed files with 14 additions and 16 deletions

View File

@ -366,7 +366,7 @@ LITTLE_GAME_MAP_DATA = (
c.SHOVEL: 0, c.SHOVEL: 0,
c.SPAWN_ZOMBIES:c.SPAWN_ZOMBIES_AUTO, c.SPAWN_ZOMBIES:c.SPAWN_ZOMBIES_AUTO,
c.INCLUDED_ZOMBIES: ( c.POLE_VAULTING_ZOMBIE,), c.INCLUDED_ZOMBIES: ( c.POLE_VAULTING_ZOMBIE,),
c.NUM_FLAGS:3, c.NUM_FLAGS:1,
c.CARD_POOL: { c.WALLNUTBOWLING: 0, c.CARD_POOL: { c.WALLNUTBOWLING: 0,
c.REDWALLNUTBOWLING: 0, c.REDWALLNUTBOWLING: 0,
c.GIANTWALLNUT:100,} c.GIANTWALLNUT:100,}

View File

@ -110,39 +110,37 @@ class Level(tool.State):
self.num_flags = num_flags self.num_flags = num_flags
# 权重值 # 权重值c.CREATE_ZOMBIE_DICT[zombie][1]即为对应的权重
weights = [] weights = [c.CREATE_ZOMBIE_DICT[zombie][1] for zombie in useable_zombies]
for zombie in useable_zombies:
weights.append(c.CREATE_ZOMBIE_DICT[zombie][1])
# 按照原版pvz设计的僵尸容量函数是从无尽解析的但是普通关卡也可以遵循 # 按照原版pvz设计的僵尸容量函数是从无尽解析的但是普通关卡也可以遵循
for wave in range(1, 10 * num_flags + 1): for wave in range(1, 10 * num_flags + 1):
volume = int(int((wave + survival_rounds*20)*0.8)/2) + 1 zombie_volume = int(int((wave + survival_rounds*20)*0.8)/2) + 1
zombie_list = [] zombie_list = []
# 大波僵尸情况 # 大波僵尸情况
if wave % 10 == 0: if wave % 10 == 0:
# 容量增大至2.5倍 # 容量增大至2.5倍
volume = int(volume*2.5) zombie_volume = int(zombie_volume*2.5)
# 先生成旗帜僵尸 # 先生成旗帜僵尸
zombie_list.append(c.FLAG_ZOMBIE) zombie_list.append(c.FLAG_ZOMBIE)
volume -= c.CREATE_ZOMBIE_DICT[c.FLAG_ZOMBIE][0] zombie_volume -= c.CREATE_ZOMBIE_DICT[c.FLAG_ZOMBIE][0]
# 传送带模式应当增大僵尸容量 # 传送带模式应当增大僵尸容量
if (self.bar_type != c.CHOOSEBAR_STATIC): if (self.bar_type != c.CHOOSEBAR_STATIC):
volume += 2 zombie_volume += 2
if inevitable_zombie_dict and (wave in inevitable_zombie_dict): if inevitable_zombie_dict and (wave in inevitable_zombie_dict):
for new_zombie in inevitable_zombie_dict[wave]: for new_zombie in inevitable_zombie_dict[wave]:
zombie_list.append(new_zombie) zombie_list.append(new_zombie)
volume -= c.CREATE_ZOMBIE_DICT[new_zombie][0] zombie_volume -= c.CREATE_ZOMBIE_DICT[new_zombie][0]
if volume < 0: if zombie_volume < 0:
logger.warning(f"{wave}波中手动设置的僵尸级别总数超过上限!") logger.warning(f"{wave}波中手动设置的僵尸级别总数超过上限!")
# 防止因为僵尸最小等级过大,使得总容量无法完全利用,造成死循环的检查机制 # 防止因为僵尸最小等级过大,使得总容量无法完全利用,造成死循环的检查机制
min_cost = c.CREATE_ZOMBIE_DICT[min(useable_zombies, key=lambda x:c.CREATE_ZOMBIE_DICT[x][0])][0] min_cost = c.CREATE_ZOMBIE_DICT[min(useable_zombies, key=lambda x:c.CREATE_ZOMBIE_DICT[x][0])][0]
while (volume >= min_cost) and (len(zombie_list) < 50): while (zombie_volume >= min_cost) and (len(zombie_list) < 50):
new_zombie = random.choices(useable_zombies, weights)[0] new_zombie = random.choices(useable_zombies, weights)[0]
# 普通僵尸、路障僵尸、铁桶僵尸有概率生成水中变种 # 普通僵尸、路障僵尸、铁桶僵尸有概率生成水中变种
if self.background_type in c.POOL_EQUIPPED_BACKGROUNDS: if self.background_type in c.POOL_EQUIPPED_BACKGROUNDS:
@ -157,9 +155,9 @@ class Level(tool.State):
# 首先几轮不出水生僵尸 # 首先几轮不出水生僵尸
elif new_zombie in c.WATER_ZOMBIE: elif new_zombie in c.WATER_ZOMBIE:
continue continue
if c.CREATE_ZOMBIE_DICT[new_zombie][0] <= volume: if c.CREATE_ZOMBIE_DICT[new_zombie][0] <= zombie_volume:
zombie_list.append(new_zombie) zombie_list.append(new_zombie)
volume -= c.CREATE_ZOMBIE_DICT[new_zombie][0] zombie_volume -= c.CREATE_ZOMBIE_DICT[new_zombie][0]
waves.append(zombie_list) waves.append(zombie_list)
# print(wave, zombie_list, len(zombie_list)) # print(wave, zombie_list, len(zombie_list))
@ -1504,9 +1502,9 @@ class Level(tool.State):
# 填充的进度条信息 # 填充的进度条信息
# 常数为拟合值 # 常数为拟合值
filledBarRect = (self.level_progress_zombie_head_image_rect.x + 3, self.level_progress_bar_image_rect.y + 6, int((150 * self.wave_num) / (self.map_data[c.NUM_FLAGS] * 10)) + 5, 9) filled_bar_rect = (self.level_progress_zombie_head_image_rect.x + 3, self.level_progress_bar_image_rect.y + 6, int((150 * self.wave_num) / (self.map_data[c.NUM_FLAGS] * 10)) + 5, 9)
# 画填充的进度条 # 画填充的进度条
pg.draw.rect(surface, c.YELLOWGREEN, filledBarRect) pg.draw.rect(surface, c.YELLOWGREEN, filled_bar_rect)
# 画旗帜 # 画旗帜
for i in range(self.num_flags): for i in range(self.num_flags):