代码拉取完成,页面将自动刷新
"""成就系统"""
import pygame
import config
Species_dict = {
"PopularScenicSpots" : {}
}
Achievement: dict = {
"adventure": {
"levelup":{
"acquired":False,
"title":"升级",
"description":"成功升级至中等级别",
'title_color':(20, 255, 20),
"xp":False
},
"fullLevel":{
"acquired":False,
"title":"满级!",
"description":"成功升至满级",
'title_color':(20, 255, 20),
"xp":False
},
"sweetDream":{
"acquired":False,
"title":"甜蜜的梦",
"description":"成功度过一个夜晚",
'title_color':(20, 255, 20),
"xp":False
},
"impregnable":{
"acquired":False,
"title":"安如磐石",
"description":"在草丛中躲避一次攻击",
'title_color':(20, 255, 20),
"xp":False
},
"isThatLantern":{
"acquired":False,
"title":"那是灯笼吗?",
"description":"干掉一个发光鱼",
'title_color':(255, 20, 255),
"xp":True
},
"haveABreakfast":{
"acquired":False,
"title":"Have a breakfast!",
"description":"吃掉一条鱼",
"title_color":(20, 255, 20),
"xp":False
}
},
"survival":{
"survivalMaster":{
"acquired":False,
"title":"生存大师",
"description":"通关生存模式",
"title_color":(255, 20, 255),
"xp":True
}
},
"challenge":{
"effectiveHunters":{
"acquired":False,
"title":"捕猎能手",
"description":"在40sec内吃掉10条鱼",
"title_color":(255, 20, 255),
"xp":True
}
},
"custom":{
"PopularScenicSpots":{
"parent":"adventure",
"acquired":False,
"title":"热门景区",
"description":"到访所有生物群系",
'title_color':(255, 20, 255),
"xp":True
}
}
}
Parse_dict = {
1: ["adventure", "levelup"],
2: ["adventure", "fullLevel"],
3: ["adventure", "sweetDream"],
4: ["adventure", "impregnable"],
5: ["adventure", "isThatLantern"],
7: ["adventure", "haveABreakfast"],
8: ["survival", "survivalMaster"]
}
Parse_custom = {
6: "PopularScenicSpots"
}
for b in config.biome['allow']:
Species_dict["PopularScenicSpots"][b] = False
class adventure:
def __init__(self) -> None:
self.levelup = 1
self.fullLevel = 2
self.sweetDream = 3
self.impregnable = 4
self.isThatLantern = 5 # 2023-07-22
self.haveABreakFast = 7 # 2023-07-24
class survival:
def __init__(self) -> None:
self.survivalMaster = 8 # 2023-07-24
class CUStom:
def __init__(self) -> None:
self.PopularScenicSpots = 6 # 2023-07-23
class Achieve_Object:
def __init__(self) -> None:
self.adventure = adventure()
self.custom = CUStom()
self.survival = survival()
achieve_list = []
class achieve_box(object):
def __init__(self, title:str, description:str, title_color:tuple=(10, 60, 10)) -> None:
self.description_color:tuple=(10, 10, 10)
self.title:str = title
self.description:str=description
self.title_color = title_color
#self.Time = 100 # tps=20, 50time = 5sec
class achieve_box_toshow(object):
def __init__(self, pic:pygame.surface.Surface) -> None:
self.Time = 100
self.pic = pic
f = pygame.font.Font('C:/Windows/Fonts/simhei.ttf', 0x12)
F = pygame.font.Font('C:/Windows/Fonts/simhei.ttf', 0x0f)
def render_achieve_box(box:achieve_box):
sur = pygame.Surface((360, 186))
sur.fill((255, 255, 255))
pygame.draw.rect(sur, (255, 255, 10), (0, 0, 359, 185), 2)
tTitle = f.render(box.title, True, box.title_color)
tTitleRect = tTitle.get_rect()
tTitleRect.midleft = (10, 46)
sur.blit(tTitle, tTitleRect)
tDescription = F.render(box.description, True, box.description_color)
tDescriptionRect = tDescription.get_rect()
tDescriptionRect.midleft = (10, 140)
sur.blit(tDescription, tDescriptionRect)
sur.set_alpha(100)
achieve_list.append(achieve_box_toshow(sur))
def show_achieve_box():
if achieve_list == []:
return
x, y = 1270, 714# 1650 - 360 - 20, 920 - 186 - 20
for a in achieve_list:
# render
config.screen.blit(a.pic, (x, y))
y -= 188
def achieve_box_mov_tps():
global achieve_list
if achieve_list == []:
return
achieve_list_new = []
for a in achieve_list:
a.Time -= 1
if a.Time >= 0:
achieve_list_new.append(a)
achieve_list = achieve_list_new
achievement = Achieve_Object()
def ask(achieve_id: int):
if type(achieve_id) != int:
raise TypeError(f"Type of 'achievement_id' must be 'int', not '{type(achieve_id)}'")
elif achieve_id in Parse_dict.keys():
a, b = Parse_dict[achieve_id][0], Parse_dict[achieve_id][1]
if Achievement[a][b]['acquired'] == False:
# obtain achieve
render_achieve_box(achieve_box(Achievement[a][b]['title'], Achievement[a][b]['description'], Achievement[a][b]['title_color']))
Achievement[a][b]['acquired'] = True
if Achievement[a][b]['xp'] == True:
return True, Achievement[a][b]['title']
else:
return False, Achievement[a][b]['title']
else:
return None, None
else:
return None, None
def ask_custom(achieve_id: int, item: str):
if type(achieve_id) != int:
raise TypeError(f"Type of 'achievement_id' must be 'int', not '{type(achieve_id)}'")
elif achieve_id in Parse_custom.keys():
b = Parse_custom[achieve_id]
if Achievement['custom'][b]['acquired'] == False:
# check items
if Species_dict[b][item] == True:
return None, None
Species_dict[b][item] = True
if False in Species_dict[b].values():
return None, None
# obtain achieve
render_achieve_box(achieve_box(Achievement['custom'][b]['title'], Achievement['custom'][b]['description'], Achievement['custom'][b]['title_color']))
Achievement['custom'][b]['acquired'] = True
if Achievement['custom'][b]['xp'] == True:
return True, Achievement['custom'][b]['title']
else:
return False, Achievement['custom'][b]['title']
else:
return None, None
else:
return None, None
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。