Back to Home

ESO Lua File v100019

ingame/lfg/zo_activityfinderroot_classes.lua

[◄ back to folders ]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
ZO_ACTIVITY_FINDER_GENERALIZED_ACTIVITY_DESCRIPTORS =
{
    [LFG_ACTIVITY_DUNGEON] = GetString(SI_DUNGEON_FINDER_GENERAL_ACTIVITY_DESCRIPTOR),
    [LFG_ACTIVITY_MASTER_DUNGEON] = GetString(SI_DUNGEON_FINDER_GENERAL_ACTIVITY_DESCRIPTOR),
    [LFG_ACTIVITY_BATTLE_GROUND_CHAMPION] = GetString(SI_BATTLEGROUND_FINDER_GENERAL_ACTIVITY_DESCRIPTOR),
    [LFG_ACTIVITY_BATTLE_GROUND_NON_CHAMPION] = GetString(SI_BATTLEGROUND_FINDER_GENERAL_ACTIVITY_DESCRIPTOR),
    [LFG_ACTIVITY_BATTLE_GROUND_LOW_LEVEL] = GetString(SI_BATTLEGROUND_FINDER_GENERAL_ACTIVITY_DESCRIPTOR),
}
----------
-- Base --
----------
ZO_ACTIVITY_FINDER_LOCATION_ENTRY_TYPE =
{
    SPECIFIC = 1,
    SET = 2,
    RANDOM = 3,
}
ZO_ActivityFinderLocation_Base = ZO_Object:Subclass()
function ZO_ActivityFinderLocation_Base:New(...)
    local object = ZO_Object.New(self)
    object:Initialize(...)
    return object
end
function ZO_ActivityFinderLocation_Base:Initialize(activityType, id, rawName, description, levelMin, levelMax, championPointsMin, championPointsMax, minGroupSize, maxGroupSize, sortOrder, descriptionTextureSmallKeyboard, descriptionTextureLargeKeyboard, descriptionTextureGamepad)
    self.activityType = activityType
    self.id = id
    self.rawName = rawName
    self.description = description
    self.levelMin = levelMin
    self.levelMax = levelMax
    self.championPointsMin = championPointsMin
    self.championPointsMax = championPointsMax
    self.minGroupSize = minGroupSize
    self.maxGroupSize = maxGroupSize
    self.sortOrder = sortOrder
    self.descriptionTextureSmallKeyboard = descriptionTextureSmallKeyboard
    self.descriptionTextureLargeKeyboard = descriptionTextureLargeKeyboard
    self.descriptionTextureGamepad = descriptionTextureGamepad
    self:InitializeFormattedNames()
end
function ZO_ActivityFinderLocation_Base:InitializeFormattedNames()
    local basicFormattedName =  zo_strformat(SI_LFG_ACTIVITY_NAME, self.rawName)
    self.nameKeyboard = basicFormattedName
    self.nameGamepad = basicFormattedName
end
function ZO_ActivityFinderLocation_Base:AddActivitySearchEntry()
    assert(false) -- Must be overriden
end
do
    local TEAM_BASED_ACTIVITY_TYPES =
    {
        [LFG_ACTIVITY_BATTLE_GROUND_CHAMPION] = true,
        [LFG_ACTIVITY_BATTLE_GROUND_NON_CHAMPION] = true,
        [LFG_ACTIVITY_BATTLE_GROUND_LOW_LEVEL] = true,
    }
    function ZO_ActivityFinderLocation_Base:SetGroupSizeRangeText(labelControl, groupIconFormat)
        local minGroupSize, maxGroupSize = self:GetGroupSizeRange()
        if TEAM_BASED_ACTIVITY_TYPES[self.activityType] then
            labelControl:SetText(zo_strformat(SI_ACTIVITY_FINDER_GROUP_SIZE_TEAM_FORMAT, maxGroupSize, groupIconFormat))
        elseif minGroupSize ~= maxGroupSize then
            labelControl:SetText(zo_strformat(SI_ACTIVITY_FINDER_GROUP_SIZE_RANGE_FORMAT, minGroupSize, maxGroupSize, groupIconFormat))
        else
            labelControl:SetText(zo_strformat(SI_ACTIVITY_FINDER_GROUP_SIZE_SIMPLE_FORMAT, minGroupSize, groupIconFormat))
        end
    end
end
do
    local ACTIVITY_QUEUE_COOLDOWN = { LFG_COOLDOWN_ACTIVITY_STARTED, }
    local BATTLEGROUND_LEAVER_COOLDOWN = { LFG_COOLDOWN_BATTLEGROUND_DESERTED, }
    local ACTIVITY_TYPE_APPLICABLE_COOLDOWN_TYPES =
    {
        [LFG_ACTIVITY_DUNGEON] = ACTIVITY_QUEUE_COOLDOWN,
        [LFG_ACTIVITY_MASTER_DUNGEON] = ACTIVITY_QUEUE_COOLDOWN,
        [LFG_ACTIVITY_BATTLE_GROUND_CHAMPION] = BATTLEGROUND_LEAVER_COOLDOWN,
        [LFG_ACTIVITY_BATTLE_GROUND_NON_CHAMPION] = BATTLEGROUND_LEAVER_COOLDOWN,
        [LFG_ACTIVITY_BATTLE_GROUND_LOW_LEVEL] = BATTLEGROUND_LEAVER_COOLDOWN,
    }
    function ZO_ActivityFinderLocation_Base:GetApplicableCooldownTypes()
        return ACTIVITY_TYPE_APPLICABLE_COOLDOWN_TYPES[self.activityType]
    end
end
-- Static data --
function ZO_ActivityFinderLocation_Base:GetActivityType()
    return self.activityType
end
function ZO_ActivityFinderLocation_Base:GetId()
    return self.id
end
function ZO_ActivityFinderLocation_Base:GetRawName()
    return self.rawName
end
function ZO_ActivityFinderLocation_Base:SetNameKeyboard(nameKeyboard)
    self.nameKeyboard = nameKeyboard
end
function ZO_ActivityFinderLocation_Base:GetNameKeyboard()
    return self.nameKeyboard
end
function ZO_ActivityFinderLocation_Base:SetNameGamepad(nameGamepad)
    self.nameGamepad = nameGamepad
end
function ZO_ActivityFinderLocation_Base:GetNameGamepad()
    return self.nameGamepad
end
function ZO_ActivityFinderLocation_Base:GetLevelMin()
    return self.levelMin
end
function ZO_ActivityFinderLocation_Base:GetLevelMax()
    return self.levelMax
end
function ZO_ActivityFinderLocation_Base:GetLevelRange()
    return self.levelMin, self.levelMax
end
function ZO_ActivityFinderLocation_Base:GetChampionPointsMin()
    return self.championPointsMin
end
function ZO_ActivityFinderLocation_Base:GetChampionPointsMax()
    return self.championPointsMax
end
function ZO_ActivityFinderLocation_Base:GetChampionPointsRange()
    return self.championPointsMin, self.championPointsMax
end
function ZO_ActivityFinderLocation_Base:GetMinGroupSize()
    return self.minGroupSize
end
function ZO_ActivityFinderLocation_Base:GetMaxGroupSize()
    return self.maxGroupSize
end
function ZO_ActivityFinderLocation_Base:GetGroupSizeRange()
    return self.minGroupSize, self.maxGroupSize
end
function ZO_ActivityFinderLocation_Base:GetDescription()
    return self.description
end
function ZO_ActivityFinderLocation_Base:GetSortOrder()
    return self.sortOrder
end
function ZO_ActivityFinderLocation_Base:GetDescriptionTextureSmallKeyboard()
    return self.descriptionTextureSmallKeyboard
end
function ZO_ActivityFinderLocation_Base:GetDescriptionTextureLargeKeyboard()
    return self.descriptionTextureLargeKeyboard
end
function ZO_ActivityFinderLocation_Base:GetDescriptionTextureGamepad()
    return self.descriptionTextureGamepad
end
function ZO_ActivityFinderLocation_Base:IsLockedByCollectible()
    assert(false) -- Must be overrideen
end
function ZO_ActivityFinderLocation_Base:GetFirstLockingCollectible()
    assert(false) -- Must be overrideen
end
function ZO_ActivityFinderLocation_Base:GetEntryType()
    assert(false) -- Must be overriden
end
-- Dynamic Data --
function ZO_ActivityFinderLocation_Base:SetSelected(isSelected)
    self.isSelected = isSelected
end
function ZO_ActivityFinderLocation_Base:IsSelected()
    return self.isSelected
end
function ZO_ActivityFinderLocation_Base:SetLocked(isLocked)
    self.isLocked = isLocked
end
function ZO_ActivityFinderLocation_Base:IsLocked()
    return self.isLocked
end
function ZO_ActivityFinderLocation_Base:SetLockReasonText(lockReasonTextOrStringId)
    if type(lockReasonTextOrStringId) == "number" then
        self.lockReasonText = GetString(lockReasonTextOrStringId)
    else
        self.lockReasonText = lockReasonTextOrStringId
    end
end
function ZO_ActivityFinderLocation_Base:GetLockReasonText()
    return self.lockReasonText
end
function ZO_ActivityFinderLocation_Base:SetLockReasonTextOverride(lockReasonTextOverride)
    self.lockReasonTextOverride = lockReasonTextOverride
end
function ZO_ActivityFinderLocation_Base:GetLockReasonTextOverride()
    return self.lockReasonTextOverride
end
function ZO_ActivityFinderLocation_Base:SetCountsForAverageRoleTime(countsForAverageRoleTime)
    self.countsForAverageRoleTime = countsForAverageRoleTime
end
function ZO_ActivityFinderLocation_Base:CountsForAverageRoleTime()
    return self.countsForAverageRoleTime
end
function ZO_ActivityFinderLocation_Base:DoesPlayerMeetLevelRequirements()
    assert(false) -- Must be overriden
end
function ZO_ActivityFinderLocation_Base:DoesGroupMeetLevelRequirements()
    assert(false) -- Must be overriden
end
-----------------------
-- Specific Activity --
-----------------------
ZO_ActivityFinderLocation_Specific = ZO_ActivityFinderLocation_Base:Subclass()
function ZO_ActivityFinderLocation_Specific:New(...)
    return ZO_ActivityFinderLocation_Base.New(self, ...)
end
function ZO_ActivityFinderLocation_Specific:Initialize(activityType, index)
    local activityId = GetActivityIdByTypeAndIndex(activityType, index)
    local rawName, levelMin, levelMax, championPointsMin, championPointsMax, groupType, minGroupSize, description, sortOrder = GetActivityInfo(activityId)
    local maxGroupSize = GetGroupSizeFromLFGGroupType(groupType)
    local descriptionTextureSmallKeyboard, descriptionTextureLargeKeyboard = GetActivityKeyboardDescriptionTextures(activityId)
    local descriptionTextureGamepad = GetActivityGamepadDescriptionTexture(activityId)
    self.requiredCollectible = GetRequiredActivityCollectibleId(activityId)
    ZO_ActivityFinderLocation_Base.Initialize(self, activityType, activityId, rawName, description, levelMin, levelMax, championPointsMin, championPointsMax, minGroupSize, maxGroupSize, sortOrder, descriptionTextureSmallKeyboard, descriptionTextureLargeKeyboard, descriptionTextureGamepad)
end
function ZO_ActivityFinderLocation_Specific:InitializeFormattedNames()
    if self:GetActivityType() == LFG_ACTIVITY_MASTER_DUNGEON then
        self:SetNameKeyboard(zo_iconTextFormat(GetVeteranIcon(), "100%", "100%", self:GetRawName()))
        self:SetNameGamepad(zo_strformat(GetString(SI_GAMEPAD_ACTIVITY_FINDER_VETERAN_LOCATION_FORMAT), self:GetRawName()))
    else
        ZO_ActivityFinderLocation_Base.InitializeFormattedNames(self)
    end
end
function ZO_ActivityFinderLocation_Specific:AddActivitySearchEntry()
end
function ZO_ActivityFinderLocation_Specific:DoesPlayerMeetLevelRequirements()
end
function ZO_ActivityFinderLocation_Specific:DoesGroupMeetLevelRequirements()
end
function ZO_ActivityFinderLocation_Specific:IsLockedByCollectible()
    return self.requiredCollectible ~= 0 and not IsCollectibleUnlocked(self.requiredCollectible)
end
function ZO_ActivityFinderLocation_Specific:GetFirstLockingCollectible()
    if self:IsLockedByCollectible() then
        return self.requiredCollectible
    end
    return 0
end
function ZO_ActivityFinderLocation_Specific:GetEntryType()
    return ZO_ACTIVITY_FINDER_LOCATION_ENTRY_TYPE.SPECIFIC
end
------------------
-- Activity Set --
------------------
ZO_ActivityFinderLocation_Set = ZO_ActivityFinderLocation_Base:Subclass()
function ZO_ActivityFinderLocation_Set:New(...)
    return ZO_ActivityFinderLocation_Base.New(self, ...)
end
function ZO_ActivityFinderLocation_Set:Initialize(activityType, index)
    self.activities = {}
    self.requiredCollectibles = {}
    local activitySetId = GetActivitySetIdByTypeAndIndex(activityType, index)
    local minGroupSize, maxGroupSize
    local levelMin, levelMax
    local championPointsMin, championPointsMax
    for activityIndex = 1, GetNumActivitySetActivities(activitySetId) do
        local activityId = GetActivitySetActivityIdByIndex(activitySetId, activityIndex)
        local _, locationLevelMin, locationLevelMax, locationChampionPointsMin, locationChampionPointsMax, groupType, locationMinGroupSize = GetActivityInfo(activityId)
        local locationMaxGroupSize = GetGroupSizeFromLFGGroupType(groupType)
        if not minGroupSize or minGroupSize > locationMinGroupSize then
            minGroupSize = locationMinGroupSize
        end
        if not maxGroupSize or maxGroupSize < locationMaxGroupSize then
            maxGroupSize = locationMaxGroupSize
        end
        if not levelMin or levelMin > locationLevelMin then
            levelMin = locationLevelMin
        end
        if not levelMax or levelMax < locationLevelMax then
            levelMax = locationLevelMax
        end
        if not championPointsMin or championPointsMin > locationChampionPointsMin then
            championPointsMin = locationChampionPointsMin
        end
        if not championPointsMax or championPointsMax < locationChampionPointsMax then
            championPointsMax = locationChampionPointsMax
        end
        local collectibleId = GetRequiredActivityCollectibleId(activityId)
        if collectibleId ~= 0 then
            table.insert(self.requiredCollectibles, collectibleId)
        end
        table.insert(self.activities, activityId)
    end
    local rawName, description, sortOrder = GetActivitySetInfo(activitySetId)
    local descriptionTextureSmallKeyboard, descriptionTextureLargeKeyboard = GetActivitySetKeyboardDescriptionTextures(activitySetId)
    local descriptionTextureGamepad = GetActivitySetGamepadDescriptionTexture(activitySetId)
    self.icon = GetActivitySetIcon(activitySetId)
    ZO_ActivityFinderLocation_Base.Initialize(self, activityType, activitySetId, rawName, description, levelMin, levelMax, championPointsMin, championPointsMax, minGroupSize, maxGroupSize, sortOrder, descriptionTextureSmallKeyboard, descriptionTextureLargeKeyboard, descriptionTextureGamepad)
end
function ZO_ActivityFinderLocation_Set:InitializeFormattedNames()
    if self:GetActivityType() == LFG_ACTIVITY_BATTLE_GROUND_CHAMPION then
        self:SetNameKeyboard(zo_iconTextFormat(GetChampionPointsIcon(), "100%", "100%", self:GetRawName()))
        self:SetNameGamepad(zo_iconTextFormat(GetGamepadChampionPointsIcon(), "100%", "100%", self:GetRawName()))
    else
        ZO_ActivityFinderLocation_Base.InitializeFormattedNames(self)
    end
end
function ZO_ActivityFinderLocation_Set:AddActivitySearchEntry()
end
function ZO_ActivityFinderLocation_Set:DoesPlayerMeetLevelRequirements()
    for _, activityId in ipairs(self.activities) do
        if DoesPlayerMeetActivityLevelRequirements(activityId) then
            return true
        end
    end
    return false
end
function ZO_ActivityFinderLocation_Set:DoesGroupMeetLevelRequirements()
    for _, activityId in ipairs(self.activities) do
        if DoesGroupMeetActivityLevelRequirements(activityId) then
            return true
        end
    end
    return false
end
function ZO_ActivityFinderLocation_Set:IsLockedByCollectible()
    for _, collectibleId in ipairs(self.requiredCollectibles) do
        if IsCollectibleUnlocked(collectibleId) then
            -- Any unlocked collectible is enough to queue with a set
            return false
        end
    end
    return #self.requiredCollectibles ~= 0
end
function ZO_ActivityFinderLocation_Set:GetFirstLockingCollectible()
    for _, collectibleId in ipairs(self.requiredCollectibles) do
        if not IsCollectibleUnlocked(collectibleId) then
            return collectibleId
        end
    end
    return 0
end
function ZO_ActivityFinderLocation_Set:GetEntryType()
    return ZO_ACTIVITY_FINDER_LOCATION_ENTRY_TYPE.SET
end
function ZO_ActivityFinderLocation_Set:GetActivities()
    return self.activities
end
do
    local g_battlegroundTypes = {}
    local g_battlegroundTypeNames = {}
    local function GetBattlegroundSetTypesListText(setData)
        local activities = setData:GetActivities()
        ZO_ClearTable(g_battlegroundTypes)
        ZO_ClearNumericallyIndexedTable(g_battlegroundTypeNames)
        for _, activityId in ipairs(activities) do
            local battlegroundId = GetActivityBattlegroundId(activityId)
            if battlegroundId ~= 0 then
                local battlegroundGameType = GetBattlegroundGameType(battlegroundId)
                if battlegroundGameType ~= BATTLEGROUND_GAME_TYPE_NONE then
                    if not g_battlegroundTypes[battlegroundGameType] then
                        g_battlegroundTypes[battlegroundGameType] = true
                        table.insert(g_battlegroundTypeNames, GetString("SI_BATTLEGROUNDGAMETYPE", battlegroundGameType))
                    end
                end
            end
        end
        return ZO_GenerateCommaSeparatedListWithoutAnd(g_battlegroundTypeNames)
    end
    local ACTIVITY_SET_TYPES_HEADERS =
    {
        [LFG_ACTIVITY_BATTLE_GROUND_CHAMPION] = GetString(SI_BATTLEGROUND_FINDER_SET_TYPES_HEADER),
        [LFG_ACTIVITY_BATTLE_GROUND_NON_CHAMPION] = GetString(SI_BATTLEGROUND_FINDER_SET_TYPES_HEADER),
        [LFG_ACTIVITY_BATTLE_GROUND_LOW_LEVEL] = GetString(SI_BATTLEGROUND_FINDER_SET_TYPES_HEADER),
    }
    local ACTIVITY_SET_TYPES_LIST_BUILDERS =
    {
        [LFG_ACTIVITY_BATTLE_GROUND_CHAMPION] = GetBattlegroundSetTypesListText,
        [LFG_ACTIVITY_BATTLE_GROUND_NON_CHAMPION] = GetBattlegroundSetTypesListText,
        [LFG_ACTIVITY_BATTLE_GROUND_LOW_LEVEL] = GetBattlegroundSetTypesListText,
    }
    function ZO_ActivityFinderLocation_Set:GetSetTypesHeaderText()
        return ACTIVITY_SET_TYPES_HEADERS[self:GetActivityType()] or ""
    end
    function ZO_ActivityFinderLocation_Set:GetSetTypesListText()
        local builderFunction = ACTIVITY_SET_TYPES_LIST_BUILDERS[self:GetActivityType()]
        return builderFunction and builderFunction(self) or ""
    end
end
---------------------
-- Random Activity --
---------------------
ZO_ActivityFinderLocation_Random = ZO_ActivityFinderLocation_Base:Subclass()
function ZO_ActivityFinderLocation_Random:New(...)
    return ZO_ActivityFinderLocation_Base.New(self, ...)
end
do
    local NO_ID = nil
    local NO_LEVEL_INFO = nil
    local SORT_ORDER = 0
    function ZO_ActivityFinderLocation_Random:Initialize(activityType, randomInfo)
        local rawName = zo_strformat(SI_ACTIVITY_FINDER_RANDOM_TITLE_FORMAT, GetString("SI_LFGACTIVITY", activityType), ZO_ACTIVITY_FINDER_GENERALIZED_ACTIVITY_DESCRIPTORS[activityType])
        local minGroupSize, maxGroupSize = ZO_ACTIVITY_FINDER_ROOT_MANAGER:GetGroupSizeRangeForActivityType(activityType)
        ZO_ActivityFinderLocation_Base.Initialize(self, activityType, NO_ID, rawName, randomInfo.description, NO_LEVEL_INFO, NO_LEVEL_INFO, NO_LEVEL_INFO, NO_LEVEL_INFO, minGroupSize, maxGroupSize, SORT_ORDER, randomInfo.keyboardBackground, randomInfo.keyboardBackground, randomInfo.gamepadBackground)
    end
end
function ZO_ActivityFinderLocation_Random:InitializeFormattedNames()
    local rawName = self:GetRawName()
    self:SetNameKeyboard(rawName)
    self:SetNameGamepad(rawName)
end
function ZO_ActivityFinderLocation_Random:GetEntryType()
    return ZO_ACTIVITY_FINDER_LOCATION_ENTRY_TYPE.RANDOM
end