checklist.py (1450B)
1 #Embedded file name: C:\BuildAgent\work\20d73f1b24eed06e\eve\release\V24.01\packages\achievement_system\client\model\state\checklist.py 2 from eveProto.generated.eve_public.achievement.contribution.contribution_pb2 import ChecklistProgress as ProtoChecklist 3 if False: 4 from typing import List, Dict 5 6 class Checklist(object): 7 8 def __init__(self, values): 9 self._values = values 10 11 @property 12 def values(self): 13 return self._values 14 15 def get_progress_value(self): 16 total_values = 0 17 for value_type, values in self.values.items(): 18 total_values += len(values) 19 20 return total_values 21 22 @classmethod 23 def from_proto(cls, payload): 24 return Checklist(values={x.value_type:x.values for x in payload.values}) 25 26 @classmethod 27 def to_proto(cls, instance): 28 value_entries = [] 29 for value_type, values in instance.values.items(): 30 value_entries.append(ProtoChecklist.ValueEntry(value_type=value_type, values=values)) 31 32 return ProtoChecklist(values=value_entries) 33 34 def __str__(self): 35 output = '' 36 for k, v in self.values.items(): 37 output += '%s: %s\n' % (k, ', '.join(v)) 38 39 return output 40 41 def __eq__(self, other): 42 if other is None or not isinstance(other, Checklist): 43 return False 44 return self._values == other._values 45 46 def __ne__(self, other): 47 return not self.__eq__(other)