Exemple #1
0
 def __init__(self, clan, string: str=''):
     from my_coding import my_encode, my_decode
     """
     
     :type string: str
     :param string:str to initialize a history item instance
     """
     self.clan = clan
     if string:
         str_list = string.split('\n')
         self.date = str_list[0]
         self.name = str_list[1]
         self.kuni = str_list[2]
         self.ninsuu = int(str_list[3])
         temp = str_list[4].split(' ')
         self.kekka = (int(temp[0]), int(temp[1]))
         self.percent = (int(temp[2]), int(temp[3])) if len(temp) == 4 else (0, 0)
         self.mikata = []
         self.teki = []
         for i in range(self.ninsuu):
             temp = str_list[5 + i]
             self.mikata.append(clan[temp[0:-2]])
             self.mikata[i].hslv[self.date]= my_decode(temp[-2])
             self.teki.append(my_decode(temp[-1]))
         self.rekishi = []
         for temp in str_list[5+self.ninsuu:-1]:
             item = HistoryUnit(temp[0],
                                my_decode(temp[1]),
                                my_decode(temp[2]),
                                int(temp[3]),
                                int(temp[4:]),
                                self.ninsuu)
             self.rekishi.append(item)
     else: self.clear()
Exemple #2
0
    def __init__(self, clan, string: str=''):
        from my_coding import my_encode, my_decode
        """


        :type string: str 
        :param string: string to initial a donate item instance
        """
        self.donateList = []
        self.clan = clan
        if string:
            str_list = string.split('\n')
            self.date = str_list[0]
            for temp0 in str_list[1:-1]:
                temp1 = temp0.split(' ')
                unit = DonateUnit(temp1[0], int(temp1[1]))
                if len(temp1[2]):
                    temp2 = temp1[2].split('|')
                    if len(temp2[0]):
                        attack = filter(None, temp2[0].split('+'))
                        for item in attack:
                            percent, donate = item[5:].split('-')
                            unit.attack.append(DonateAD(my_decode(item[0]),
                                                        my_decode(item[1]),
                                                        my_decode(item[2]),
                                                        my_decode(item[3]),
                                                        int(item[4]),
                                                        int(percent),
                                                        int(donate)))
                    if len(temp2[1]):
                        defend = filter(None, temp2[1].split('+'))
                        for item in defend:
                            percent, donate = item[5:].split('-')
                            unit.defend.append(DonateAD(my_decode(item[0]),
                                                        my_decode(item[1]),
                                                        my_decode(item[2]),
                                                        my_decode(item[3]),
                                                        int(item[4]),
                                                        int(percent),
                                                        int(donate)))
                self.donateList.append(unit)