war.py (10825B)
1 #Embedded file name: C:\BuildAgent\work\20d73f1b24eed06e\eve\release\V24.01\packages\notifications\common\formatters\war.py 2 from carbon.common.script.util.linkUtil import GetShowInfoLink 3 from eve.common.script.util.notificationUtil import ParamWarOwners, CreateItemInfoLink 4 from localization import GetByLabel 5 from notifications.common.formatters.baseFormatter import BaseNotificationFormatter 6 from carbon.common.script.util.format import FmtDate 7 8 class WarInvalidateMsg(BaseNotificationFormatter): 9 subjectLabel = 'Notifications/subjWarConcordInvalidates' 10 bodyLabel = 'Notifications/bodyWarConcordInvalidates' 11 bodyLabelNoStarted = 'Notifications/bodyWarConcordInvalidatesNotStarted' 12 13 def __init__(self, localizationImpl = None): 14 BaseNotificationFormatter.__init__(self, subjectLabel=self.subjectLabel, bodyLabel=self.bodyLabel) 15 16 def Format(self, notification): 17 data = ParamWarOwners(notification) 18 data.update(notification.data) 19 notification.subject = GetByLabel(self.subjectLabel, **data) 20 bodyLabel = self.bodyLabel 21 if data.get('timeStarted', None): 22 if notification.created < data['timeStarted']: 23 bodyLabel = self.bodyLabelNoStarted 24 notification.body = GetByLabel(bodyLabel, **data) 25 26 @staticmethod 27 def MakeSampleData(variant = 0): 28 return {'againstID': 98000001, 29 'declaredByID': 99000001} 30 31 32 class WarHQRemovedFromSpace(BaseNotificationFormatter): 33 subjectLabel = 'Notifications/subjWarHqRemoved' 34 bodyLabel = 'Notifications/bodyWarWarHqRemoved' 35 36 def __init__(self): 37 BaseNotificationFormatter.__init__(self, subjectLabel=self.subjectLabel, bodyLabel=self.bodyLabel) 38 39 def Format(self, notification): 40 data = ParamWarOwners(notification) 41 data['declaredDate'] = FmtDate(notification.data['timeDeclared']) 42 data['warHQ'] = notification.data['warHQ'] 43 notification.subject = GetByLabel(self.subjectLabel, **data) 44 notification.body = GetByLabel(self.bodyLabel, **data) 45 46 @staticmethod 47 def MakeSampleData(variant = 0): 48 return {'againstID': 98000001, 49 'declaredByID': 99000001, 50 'timeDeclared': 132023206828876106L, 51 'warHQ': 'A War HQ'} 52 53 54 class WarMutualWarInviteSent(BaseNotificationFormatter): 55 subjectLabel = 'Notifications/subjWarMutualWarInviteSent' 56 bodyLabel = 'Notifications/bodyWarMutualWarInviteSent' 57 58 def __init__(self): 59 BaseNotificationFormatter.__init__(self, subjectLabel=self.subjectLabel, bodyLabel=self.bodyLabel) 60 61 def Format(self, notification): 62 data = ParamWarOwners(notification) 63 expireTimeStamp = notification.data['expireTimeStamp'] 64 expireDate = FmtDate(expireTimeStamp, 'ln') 65 notification.subject = GetByLabel(self.subjectLabel, **data) 66 notification.body = GetByLabel(self.bodyLabel, expireDate=expireDate, **data) 67 68 @staticmethod 69 def MakeSampleData(variant = 0): 70 return {'againstID': 98000001, 71 'declaredByID': 99000001, 72 'expireTimeStamp': 132023206828876106L} 73 74 75 class WarMutualWarInviteRejected(BaseNotificationFormatter): 76 subjectLabel = 'Notifications/subjWarMutualWarInviteRejected' 77 bodyLabel = 'Notifications/bodyWarMutualWarInviteRejected' 78 79 def __init__(self): 80 BaseNotificationFormatter.__init__(self, subjectLabel=self.subjectLabel, bodyLabel=self.bodyLabel) 81 82 def Format(self, notification): 83 data = ParamWarOwners(notification) 84 notification.subject = GetByLabel(self.subjectLabel, **data) 85 notification.body = GetByLabel(self.bodyLabel, **data) 86 87 @staticmethod 88 def MakeSampleData(variant = 0): 89 return {'againstID': 98000001, 90 'declaredByID': 99000001} 91 92 93 class WarMutualWarInviteAccepted(BaseNotificationFormatter): 94 subjectLabel = 'Notifications/subjWarMutualWarInviteAccepted' 95 bodyLabel = 'Notifications/bodyWarMutualWarInviteAccepted' 96 97 def __init__(self): 98 BaseNotificationFormatter.__init__(self, subjectLabel=self.subjectLabel, bodyLabel=self.bodyLabel) 99 100 def Format(self, notification): 101 data = ParamWarOwners(notification) 102 data['time'] = notification.data['time'] 103 notification.subject = GetByLabel(self.subjectLabel, **data) 104 notification.body = GetByLabel(self.bodyLabel, **data) 105 106 @staticmethod 107 def MakeSampleData(variant = 0): 108 return {'againstID': 98000001, 109 'declaredByID': 99000001, 110 'time': 132023206828876106L} 111 112 113 class WarAdopted(BaseNotificationFormatter): 114 subjectLabel = 'Notifications/subjWarAdopted' 115 bodyLabel = 'Notifications/bodyWarAdopted' 116 allyText = 'Notifications/WarAdoptedAllyText' 117 118 def __init__(self): 119 BaseNotificationFormatter.__init__(self, subjectLabel=self.subjectLabel, bodyLabel=self.bodyLabel) 120 121 def Format(self, notification): 122 data = ParamWarOwners(notification) 123 data['allianceName'] = CreateItemInfoLink(notification.data['allianceID']) 124 notification.subject = GetByLabel(self.subjectLabel, **data) 125 notification.body = GetByLabel(self.bodyLabel, **data) 126 if notification.data.get('isAlly', False): 127 notification.body += '<br><br>%s' % GetByLabel('Notifications/WarAdoptedAllyText', **data) 128 129 @staticmethod 130 def MakeSampleData(variant = 0): 131 return {'againstID': 98000001, 132 'declaredByID': 99000001, 133 'allianceID': 99000002} 134 135 136 class MutualWarExpired(BaseNotificationFormatter): 137 subjectLabel = 'Notifications/subjMutualWarExpired' 138 bodyLabel = 'Notifications/bodyMutualWarExpired' 139 140 def __init__(self): 141 BaseNotificationFormatter.__init__(self, subjectLabel=self.subjectLabel, bodyLabel=self.bodyLabel) 142 143 def Format(self, notification): 144 data = ParamWarOwners(notification) 145 data['numDays'] = notification.data['numDays'] 146 notification.subject = GetByLabel(self.subjectLabel, **data) 147 notification.body = GetByLabel(self.bodyLabel, **data) 148 149 @staticmethod 150 def MakeSampleData(variant = 0): 151 return {'againstID': 98000001, 152 'declaredByID': 99000001, 153 'numDays': 5} 154 155 156 class WarInherited(BaseNotificationFormatter): 157 subjectLabel = 'Notifications/subjWarInherited' 158 bodyLabel = 'Notifications/bodyWarInherited' 159 160 def __init__(self): 161 BaseNotificationFormatter.__init__(self, subjectLabel=self.subjectLabel, bodyLabel=self.bodyLabel) 162 163 def Format(self, notification): 164 data = ParamWarOwners(notification) 165 data['allianceName'] = CreateItemInfoLink(notification.data['allianceID']) 166 data['quitterName'] = CreateItemInfoLink(notification.data['quitterID']) 167 data['opponentName'] = CreateItemInfoLink(notification.data['opponentID']) 168 data['allyText'] = notification.data.get('allyText') or '' 169 notification.subject = GetByLabel(self.subjectLabel, **data) 170 notification.body = GetByLabel(self.bodyLabel, **data) 171 172 @staticmethod 173 def MakeSampleData(variant = 0): 174 return {'againstID': 98000001, 175 'declaredByID': 99000001, 176 'allianceID': 99000002, 177 'quitterID': 98000003, 178 'opponentID': 98000004} 179 180 181 class WarAllyInherited(WarInherited): 182 allyText = 'Notifications/WarAllyInherited' 183 184 def Format(self, notification): 185 notification.data['allianceName'] = CreateItemInfoLink(notification.data['allianceID']) 186 notification.data['allyText'] = GetByLabel(self.allyText, **notification.data) 187 super(WarAllyInherited, self).Format(notification) 188 189 @staticmethod 190 def MakeSampleData(variant = 0): 191 return {'againstID': 98000001, 192 'declaredByID': 99000001, 193 'allianceID': 99000002, 194 'quitterID': 98000003, 195 'opponentID': 98000004} 196 197 198 class MutualWarRetracted(BaseNotificationFormatter): 199 subjectLabel = 'Notifications/subjWarRetracts' 200 bodyLabel = 'Notifications/bodyWarRetract' 201 202 def __init__(self): 203 BaseNotificationFormatter.__init__(self, subjectLabel=self.subjectLabel, bodyLabel=self.bodyLabel) 204 205 def Format(self, notification): 206 data = ParamWarOwners(notification) 207 notification.subject = GetByLabel(self.subjectLabel, **data) 208 notification.body = GetByLabel(self.bodyLabel, **data) 209 210 211 class ConcordRetractsWar(BaseNotificationFormatter): 212 subjectLabel = 'Notifications/subjWarConcordRetracts' 213 bodyLabel = 'Notifications/bodyWarConcordRetracts' 214 signOff = 'Notifications/bodyConcordSignOff' 215 216 def __init__(self): 217 BaseNotificationFormatter.__init__(self, subjectLabel=self.subjectLabel, bodyLabel=self.bodyLabel) 218 219 def Format(self, notification): 220 data = ParamWarOwners(notification) 221 data['endDate'] = notification.data['endDate'] 222 data['signOff'] = GetByLabel(self.signOff) 223 notification.subject = GetByLabel(self.subjectLabel, **data) 224 notification.body = GetByLabel(self.bodyLabel, **data) 225 226 227 class WarInvalid(BaseNotificationFormatter): 228 subjectLabel = 'Notifications/subjWarConcordRetracts' 229 bodyLabel = 'Notifications/bodyWarInvalid' 230 signOff = 'Notifications/bodyConcordSignOff' 231 232 def __init__(self): 233 BaseNotificationFormatter.__init__(self, subjectLabel=self.subjectLabel, bodyLabel=self.bodyLabel) 234 235 def Format(self, notification): 236 data = ParamWarOwners(notification) 237 data['endDate'] = notification.data['endDate'] 238 data['signOff'] = GetByLabel(self.signOff) 239 notification.subject = GetByLabel(self.subjectLabel, **data) 240 notification.body = GetByLabel(self.bodyLabel, **data) 241 242 243 class WarEndedHqSystemSecurityDropMsg(BaseNotificationFormatter): 244 subjectLabel = 'Notifications/subjWarEndedHqSystemSecurityDrop' 245 bodyLabel = 'Notifications/bodyWarEndedHqSystemSecurityDrop' 246 signOff = 'Notifications/bodyConcordSignOff' 247 248 def __init__(self, localizationImpl = None): 249 BaseNotificationFormatter.__init__(self, subjectLabel=self.subjectLabel, bodyLabel=self.bodyLabel) 250 251 def Format(self, notification): 252 data = ParamWarOwners(notification) 253 data.update(notification.data) 254 data['signOff'] = GetByLabel(self.signOff) 255 hqInfo = notification.data['warHQ_IdType'] 256 hqItemID, hqTypeID = hqInfo 257 hqItemName = notification.data['warHQ'] 258 notification.data['warHQ'] = GetShowInfoLink(hqTypeID, hqItemName, hqItemID) 259 notification.subject = GetByLabel(self.subjectLabel, **data) 260 notification.body = GetByLabel(self.bodyLabel, **data) 261 262 @staticmethod 263 def MakeSampleData(variant = 0): 264 return {'againstID': 98000001, 265 'declaredByID': 99000001, 266 'endDate': 132261482400000000L, 267 'warHQ': 'Edmalbrurdus - Montague War HQ', 268 'warHQ_IdType': (1000000157608L, 35832)}