这个问题我也排查了很久
发现不同对象之间的itemlist的列表又出现混淆,才发现是他们引用了同一个列表
采用 deep.copy 解决这个问题
class fighter():
def __init__(self, EIOD=100,FTR = "",ALIVE=1,SEX='男',MPAI='',TITLE='',QMD=0,ELEM=[],ATK=20,DEF=5,FL=10,MZ=20, SB=5, HP_MAX=30, MP_MAX=30,TL_MAX=50,FABAO_list=[],WQ='',FJ='',JEWEL1='',JEWEL2='',ITEMLIST=[[],[],[],[],[],[],[]],GOLD=100,skill_set=[],book=[], pic_sprite="", sprite_pos=[500,500]) :
self.FTR = FTR
self.EIOD = EIOD
self.ALIVE=ALIVE
self.SEX=SEX
self.MPAI=MPAI
self.TITLE=TITLE
self.QMD=QMD
self.ELEM = copy.deepcopy(ELEM)
self.ATK=ATK
self.ATK_TMP=ATK
self.DEF=DEF
self.DEF_TMP=DEF
self.FL=FL
self.FL_TMP = FL
self.MZ=MZ
self.MZ_TMP=MZ
self.SB=SB
self.SB_TMP=SB
self.HP_MAX=HP_MAX
self.HP=HP_MAX
self.HP_TMPMAX=HP_MAX
self.MP_MAX=MP_MAX
self.MP=MP_MAX
self.MP_TMPMAX=MP_MAX
self.TL=TL_MAX
self.TL_MAX=TL_MAX
self.TL_TMPMAX=TL_MAX
self.FABAO_list=copy.deepcopy(FABAO_list)
self.FJ=FJ
self.WQ=WQ
self.JEWEL1=JEWEL1
self.JEWEL2=JEWEL2
self.ITEMLIST=copy.deepcopy(ITEMLIST)
self.GOLD=GOLD
self.skill_set =copy.deepcopy(skill_set)
self.book=copy.deepcopy(book)
self.pic_sprite = pic_sprite
self.sprite_pos = copy.deepcopy(sprite_pos)
而不是用原来的?? ? ? ? ? ? self.ITEMLIST=ITEMLIST? 的构造方式。
|