@@ -57,19 +57,19 @@ def player_hit(self, hits=0, tag=1): #tag是个辅助参数,以免
5757class Infoimage :
5858 def __init__ (self , surface ): #绘制怪物信息概览的小玩意
5959 self .screen = surface
60- self .mob_rect = pygame .image .load (r' asset\ mob_back.png' ).convert ()
60+ self .mob_rect = pygame .image .load (os . path . join ( " asset" , " mob_back.png" ) ).convert ()
6161 self .hp_rect = None
6262 self .hp_slot = MySprite ()
63- self .hp_slot .load (r' asset\ hp_slot.png' , 0 , 0 , 72 , 500 , 3 )
64- self .exp_slot = pygame .image .load (r' asset\ exp_slot.png' ).convert_alpha ()
63+ self .hp_slot .load (os . path . join ( " asset" , " hp_slot.png" ) , 0 , 0 , 72 , 500 , 3 )
64+ self .exp_slot = pygame .image .load (os . path . join ( " asset" , " exp_slot.png" ) ).convert_alpha ()
6565 self .item = MySprite ()
66- self .item .load (r' asset\ process1.png' , 0 , 0 , 32 , 32 , 16 )
66+ self .item .load (os . path . join ( " asset" , " process1.png" ) , 0 , 0 , 32 , 32 , 16 )
6767 self .item_detail = MySprite ()
68- self .item_detail .load (r' equipment\ process.png' , 0 , 0 , 128 , 128 , 16 )
68+ self .item_detail .load (os . path . join ( " equipment" , " process.png" ) , 0 , 0 , 128 , 128 , 16 )
6969 self .mob_detail = MySprite ()
70- self .mob_detail .load (r' asset\ mob_demo.png' , 0 , 0 , 128 , 128 , 10 )
70+ self .mob_detail .load (os . path . join ( " asset" , " mob_demo.png" ) , 0 , 0 , 128 , 128 , 10 )
7171 self .stats = MySprite () #状态显示
72- self .stats .load (r' asset\ stat.png' , 0 , 0 , 48 , 48 , 6 )
72+ self .stats .load (os . path . join ( " asset" , " stat.png" ) , 0 , 0 , 48 , 48 , 6 )
7373 self .ptr = None
7474 self .po , self .inf = None , None
7575 self .origin_hp = 0
@@ -218,85 +218,49 @@ def getDetail(self, item):
218218 if item .enchant_lvl == 6 : text = self .bigf .render (t , True , (148 ,0 ,211 )) #relic需要紫色的名字
219219 else : text = self .bigf .render (t , True , (0 ,0 ,0 ))
220220 else : text = self .bigf .render (t , True , (0 ,0 ,0 ))
221- self .texts .append (text )
222- t = item .describe
223- text = self .font3 .render (t , True , (0 ,0 ,0 ))
224- self .texts .append (text )
225- t = 'Attack: ' + str (item .atk )
226- text = self .font3 .render (t , True , (0 ,0 ,0 ))
227- self .texts .append (text )
228- t = 'Defence: ' + str (item .defc )
229- text = self .font3 .render (t , True , (0 ,0 ,0 ))
230- self .texts .append (text )
231- t = 'Magic: ' + str (item .magic )
232- text = self .font3 .render (t , True , (0 ,0 ,0 ))
233- self .texts .append (text )
234- t = 'Speed: ' + str (item .speed )
235- text = self .font3 .render (t , True , (0 ,0 ,0 ))
236- self .texts .append (text )
237- t = 'Weight: ' + str (item .weight )+ ' Price: ' + str (item .price )+ ' g'
238- text = self .font3 .render (t , True , (0 ,0 ,0 ))
239- self .texts .append (text )
240- lvl = item .lvl
241- if lvl != - 1 :
242- t = 'Level: ' + str (lvl )
243- else :
244- t = 'Level: NaN'
245- text = self .font3 .render (t , True , (0 ,0 ,0 ))
246- self .texts .append (text )
247- t = 'Generating Level: ' + str (item .gnrt_lvl )
248- text = self .font3 .render (t , True , (0 ,0 ,0 ))
249- self .texts .append (text )
221+ self .texts .extend ([
222+ text ,
223+ self .font3 .render (item .describe , True , (0 ,0 ,0 )),
224+ self .font3 .render (f'Attack: { item .atk } ' , True , (0 ,0 ,0 )),
225+ self .font3 .render (f'Defence: { item .defc } ' , True , (0 ,0 ,0 )),
226+ self .font3 .render (f'Magic: { item .magic } ' , True , (0 ,0 ,0 )),
227+ self .font3 .render (f'Speed: { item .speed } ' , True , (0 ,0 ,0 )),
228+ self .font3 .render (f'Weight: { item .weight } Price: { item .price } g' , True , (0 ,0 ,0 )),
229+ self .font3 .render (f'Level: { item .lvl if item .lvl != - 1 else "NaN" } ' , True , (0 ,0 ,0 )),
230+ self .font3 .render (f'Generating Level: { item .gnrt_lvl } ' , True , (0 ,0 ,0 ))
231+ ])
250232 if item .energy :
251- t = 'Energy: ' + str ( item .energy ) + ' Number of amount: ' + str ( item .count )
233+ t = f 'Energy: { item .energy } Number of amount: { item .count } '
252234 else :
253- t = 'Item has no Energy /Number of amount: ' + str (item .count )
254- text = self .font3 .render (t , True , (0 ,0 ,0 ))
255- self .texts .append (text )
235+ t = f'Item has no Energy /Number of amount: { item .count } '
236+ self .texts .append (self .font3 .render (t , True , (0 ,0 ,0 )))
256237 for i in item .form_desc [:- 1 - item .form_desc [- 1 ]]: #准备普通装备描述
257- text = self .font3 .render (i , True , (0 ,0 ,0 ))
258- self .texts .append (text )
238+ self .texts .append (self .font3 .render (i , True , (0 ,0 ,0 )))
259239 for i in item .form_desc [- item .form_desc [- 1 ] - 1 :- 1 ]: # 准备lv6装备的攻击属性描述
260- text = self .font2 .render (i , True , (148 , 0 , 211 ))
261- self .texts .append (text )
240+ self .texts .append (self .font2 .render (i , True , (148 , 0 , 211 )))
262241 self .texts .append (item .form_desc [- 1 ])
263242 else :
264243 ID = item .ID
265244 img = self .mob_detail .getImage (ID )
266245 self .texts .append (img )
267- t = item .name
268- text = self .bigf .render (t , True , (0 ,0 ,0 ))
269- self .texts .append (text )
270- with open (r'data\mob_desc.json' , 'r' ) as read :
246+ self .texts .append (self .bigf .render (item .name , True , (0 ,0 ,0 )))
247+ with open (os .path .join ("data" , "mob_desc.json" ), 'r' ) as read :
271248 desc = json .load (read )[str (ID )]
272249 for i in desc :
273- text = self .font3 .render (i , True , (0 ,0 ,0 ))
274- self .texts .append (text )
275- t = 'HP: %2d/%2d' % (item .hp , item .origin_hp )
276- text = self .font3 .render (t , True , (0 ,0 ,0 ))
277- self .texts .append (text )
278- t = 'Attack: ' + str (item .attack )
279- text = self .font3 .render (t , True , (0 ,0 ,0 ))
280- self .texts .append (text )
281- t = 'Defence: ' + str (item .defence )
282- text = self .font3 .render (t , True , (0 ,0 ,0 ))
283- self .texts .append (text )
284- t = 'Magic: ' + str (item .magic )
285- text = self .font3 .render (t , True , (0 ,0 ,0 ))
286- self .texts .append (text )
287- t = 'Speed: ' + str (item .speed )
288- text = self .font3 .render (t , True , (0 ,0 ,0 ))
289- self .texts .append (text )
290- self .texts += self .mobDetail (item )
250+ self .texts .append (self .font3 .render (i , True , (0 ,0 ,0 )))
251+ self .texts .extend ([
252+ self .font3 .render (f'HP: { item .hp :2d} /{ item .origin_hp :2d} ' , True , (0 ,0 ,0 )),
253+ self .font3 .render (f'Attack: { item .attack } ' , True , (0 ,0 ,0 )),
254+ self .font3 .render (f'Defence: { item .defence } ' , True , (0 ,0 ,0 )),
255+ self .font3 .render (f'Magic: { item .magic } ' , True , (0 ,0 ,0 )),
256+ self .font3 .render (f'Speed: { item .speed } ' , True , (0 ,0 ,0 ))
257+ ])
258+ self .texts .extend (self .mobDetail (item ))
291259
292260 def mobDetail (self , mob ):
293261 extra = []
294- if mob .servant :
295- t = "Friendly"
296- text = self .bigf .render (t , True , (0 , 100 , 0 ))
297- else :
298- t = "Hostile"
299- text = self .bigf .render (t , True , (100 , 0 , 0 ))
262+ text = self .bigf .render ("Friendly" , True , (0 , 100 , 0 )) if mob .servant else \
263+ self .bigf .render ("Hostile" , True , (100 , 0 , 0 ))
300264 extra .append (text )
301265 text = self .font3 .render (self .mobIntel [mob .intelligent ], True , (0 , 0 , 0 )) #获取怪物能力信息
302266 extra .append (text )
0 commit comments