Skip to content
Merged
94 changes: 49 additions & 45 deletions apps/backend/Helpers/UserUploadCharacterProcessor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,6 @@ public async Task<UserUploadCharacterProcessorResult> Process(int? guildId)
HandleProfessionCooldowns();
HandleProfessionTraits();
HandleQuests();
HandleReputations();
// HandleTransmog();
HandleWeekly();

Expand Down Expand Up @@ -549,11 +548,60 @@ private void HandleAddonData()
}
}

// Reputations
if (_characterData.ReputationsV2 != null &&
_characterData.ScanTimes.TryGetValue("reputations", out int reputationsTimestamp))
{
var scanTime = reputationsTimestamp.AsUtcDateTime();
if (scanTime > _character.AddonData.ReputationsScannedAt)
{
_character.AddonData.ReputationsScannedAt = scanTime;

_character.AddonData.Reputations = new();
foreach (string repString in _characterData.ReputationsV2.EmptyIfNull())
{
string[] parts = repString.Split(":");
if (parts.Length == 2 &&
int.TryParse(parts[0], out int factionId) &&
int.TryParse(parts[1], out int value) &&
value != 0)
{
_character.AddonData.Reputations[factionId] = value;
}
}

_character.AddonData.Paragons = new();
foreach (var (paragonId, paragonString) in _characterData.Paragons.EmptyIfNull())
{
var parts = paragonString.Split(":");
if (parts.Length != 3)
{
_logger.Warning("Invalid paragon string: {String}", paragonString);
continue;
}

var total = int.Parse(parts[0]);
var max = int.Parse(parts[1]);
var rewardAvailable = parts[2] == "1";

_character.AddonData.Paragons[paragonId] = new PlayerCharacterAddonDataParagon
{
Current = total % max,
Max = max,
Received = total / max,
RewardAvailable = rewardAvailable,
};
}
}
}

// Change detection for this is obnoxious, just update it
var entry = _context.Entry(_character.AddonData);
entry.Property(ad => ad.Garrisons).IsModified = true;
entry.Property(ad => ad.MythicPlusSeasons).IsModified = true;
entry.Property(ad => ad.MythicPlusWeeks).IsModified = true;
entry.Property(ad => ad.Paragons).IsModified = true;
entry.Property(ad => ad.Reputations).IsModified = true;
}

private void HandleAchievements()
Expand Down Expand Up @@ -1332,50 +1380,6 @@ private void HandleQuestsWorld()
}
}

private void HandleReputations()
{
if (_character.Reputations == null)
{
return;
}

_character.Reputations.ExtraReputationIds = new();
_character.Reputations.ExtraReputationValues = new();

var reputations = _characterData.Reputations
.EmptyIfNull()
.OrderBy(kvp => kvp.Key)
.ToList();
foreach (var (id, value) in reputations)
{
_character.Reputations.ExtraReputationIds.Add(id);
_character.Reputations.ExtraReputationValues.Add(value);
}

_character.Reputations.Paragons = new();
foreach (var (paragonId, paragonString) in _characterData.Paragons.EmptyIfNull())
{
var parts = paragonString.Split(":");
if (parts.Length != 3)
{
_logger.Warning("Invalid paragon string: {String}", paragonString);
continue;
}

var total = int.Parse(parts[0]);
var max = int.Parse(parts[1]);
var rewardAvailable = parts[2] == "1";

_character.Reputations.Paragons[paragonId] = new PlayerCharacterReputationsParagon
{
Current = total % max,
Max = max,
Received = total / max,
RewardAvailable = rewardAvailable,
};
}
}

private void HandleTransmog()
{
List<int> transmog;
Expand Down
47 changes: 46 additions & 1 deletion apps/backend/Jobs/User/UserUploadJob.cs
Original file line number Diff line number Diff line change
Expand Up @@ -440,6 +440,16 @@ private async Task Process(string luaData) {
_resetQuestCache = true;
}

// Reputations
try
{
await HandleAccountReputations(accountAddonData, parsed.ScanTimes.EmptyIfNull(), parsed.Reputations);
}
catch (Exception ex)
{
Logger.Error(ex, "HandleAccountReputations failed!");
}

// Toys
// var accountToys = await Context.PlayerAccountToys.FindAsync(accountId);
// if (accountToys == null)
Expand Down Expand Up @@ -694,6 +704,42 @@ private async Task HandleBattlePets(int accountId, Dictionary<long, string> pars
await JobRepository.ReleaseLockAsync(lockKey, lockValue);
}

private async Task HandleAccountReputations(
PlayerAccountAddonData accountAddonData,
Dictionary<string, int> globalScanTimes,
List<string> reputations
) {
var localContext = Context;

if (globalScanTimes.TryGetValue("reputations", out int reputationsTimestamp))
{
var reputationsScannedAt = reputationsTimestamp.AsUtcDateTime();
if (reputationsScannedAt > accountAddonData.ReputationsScannedAt)
{
accountAddonData.ReputationsScannedAt = reputationsScannedAt;
accountAddonData.Reputations ??= new();

foreach (string repString in reputations)
{
string[] parts = repString.Split(":");
if (parts.Length == 2 &&
int.TryParse(parts[0], out int factionId) &&
int.TryParse(parts[1], out int value))
{
accountAddonData.Reputations[factionId] = value;
}
}

// Change detection for this is obnoxious, just update it
localContext.Entry(accountAddonData)
.Property(aad => aad.Reputations)
.IsModified = true;

await localContext.SaveChangesAsync(CancellationToken);
}
}
}

private async Task HandleDecor(PlayerAccountAddonData accountAddonData, Dictionary<string, int> globalScanTimes, Dictionary<int, string> decorData)
{
var localContext = Context;
Expand Down Expand Up @@ -729,7 +775,6 @@ private async Task HandleDecor(PlayerAccountAddonData accountAddonData, Dictiona
}
}


private async Task HandleGuildItems(WowDbContext localContext, PlayerGuild guild, UploadGuild guildData)
{
var guildItems = guild.Items.EmptyIfNull();
Expand Down
1 change: 1 addition & 0 deletions apps/backend/Models/Uploads/Upload.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ public class Upload
public List<int> Illusions { get; set; }
public List<int> Quests { get; set; }
public Dictionary<int, int> QuestsV2 { get; set; }
public List<string> Reputations { get; set; }
public Dictionary<string, int> ScanTimes { get; set; }
public List<int> Toys { get; set; }

Expand Down
2 changes: 1 addition & 1 deletion apps/backend/Models/Uploads/UploadCharacter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public class UploadCharacter
public List<string> ProfessionCooldowns { get; set; }
public List<string> ProfessionOrders { get; set; }
public List<string> ProfessionTraits { get; set; }
public Dictionary<int, int> Reputations { get; set; }
public List<string> ReputationsV2 { get; set; }
public Dictionary<string, int> ScanTimes { get; set; }
public string Transmog { get; set; }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,13 +97,15 @@
{#if current}
{#each fields as field (field)}
{#if field === 'concentration' && showConcentration}
<Currency
{character}
currency={concCurrency}
fullIsBad={settingsState.value.professions.fullConcentrationIsBad}
useIconOverride={false}
useStatusClass={true}
/>
<span class:faded={currentSkill < 50}>
<Currency
{character}
currency={concCurrency}
fullIsBad={settingsState.value.professions.fullConcentrationIsBad}
useIconOverride={false}
useStatusClass={true}
/>
</span>
{:else if field === 'moxie' && showMoxie}
<Currency {character} currency={moxieCurrency} useIconOverride={false} />
{/if}
Expand Down
2 changes: 1 addition & 1 deletion apps/frontend/components/tooltips/reputation/hacks.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
export function nazjatarHack(levelString: string): number {
const level = parseInt(levelString.split(' ')[1]);
return level === 30 ? 1 : 7 - Math.max(1, Math.floor(level / 5));
return level === 30 ? 0 : 6 - Math.max(0, Math.floor(level / 5));
}

export function brannHack(levelString: string): number {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@
112: 'Normal Prey',
115: 'Hard Prey',
116: 'Nightmare Prey',
157: 'Ritual Site',
};

function getRunCount(index: number): number {
Expand Down
2 changes: 2 additions & 0 deletions apps/frontend/data/achievements.ts
Original file line number Diff line number Diff line change
Expand Up @@ -502,6 +502,8 @@ export const extraCategories: ExtraAchievementCategory[] = [
},
null,
{ targetSlug: 'expansion-features/prey', nameType: 2 },
{ targetSlug: 'expansion-features/ritual-sites', nameType: 2 },
{ targetSlug: 'expansion-features/void-assaults', nameType: 2 },
],
},
{
Expand Down
4 changes: 1 addition & 3 deletions apps/frontend/data/currencies.ts
Original file line number Diff line number Diff line change
Expand Up @@ -461,9 +461,7 @@ export const currencyItems: Record<number, number[]> = {
242241, // Latent Arcana
246951, // Stormarion Core
null,
262636, // Anguish-Scribed Rune [hunts, uncommon]
262637, // Anguish-Infused Rune [hunts, rare]
262638, // Anguish-Permeated Rune [hunts, epic]
267051, // Dark Particle
],
// Midnight - Season 1
126411: [
Expand Down
4 changes: 3 additions & 1 deletion apps/frontend/data/dungeon.ts
Original file line number Diff line number Diff line change
Expand Up @@ -144,9 +144,11 @@ export const raidVaultItemLevel: Record<number, Array<number>> = {
};

export const worldVaultItemLevel: Array<Array<number>> = [
[13, 272, 4], // Hero 5 (ritual 5?)
[12, 263, 4], // Hero 2 (ritual 4?)
[8, 259, 4], // Hero 1
[7, 256, 3], // Champion 4
[6, 253, 3], // Champion 3?
[6, 253, 3], // Champion 3
[5, 246, 3], // Champion 1
[4, 243, 2], // Veteran 4
[3, 240, 2], // Veteran 3
Expand Down
2 changes: 1 addition & 1 deletion apps/frontend/data/tasks/11-midnight/delves.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,14 +81,14 @@ export const midDelves: Task = {
name: 'Gilded Stash',
icon: iconLibrary.gameCutDiamond,
minimumLevel: 90,
alwaysStarted: true,
questReset: DbResetType.Weekly,
questResetForced: true,
showQuestName: true,
subChores: [
{
key: 'stashes',
name: '{currency:3290}',
alwaysStarted: true,
progressFunc: (char) => ({
have: char.weekly?.delveGilded || 0,
need: 4,
Expand Down
1 change: 1 addition & 0 deletions apps/frontend/types/user-data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ export interface UserData {
heirlooms: Record<number, number>;
illusionIds: number[];
raiderIoScoreTiers: Record<number, UserDataRaiderIoScoreTiers>;
reputations: Record<number, number>;
warbankItems: WarbankItem[];

honorCurrent: number;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,8 @@
{@const {
characterParagon,
characterRep,
dataRep,
cls,
dataRep,
renownCurrent,
renownMax,
repTier,
Expand Down Expand Up @@ -117,7 +117,7 @@
</div>
</div>

{#if characterParagon}
{#if renownMax && renownCurrent === renownMax && characterParagon}
<ProgressBar
title="Paragon"
have={characterParagon.current}
Expand Down
14 changes: 11 additions & 3 deletions apps/frontend/user-home/components/reputations/TableCell.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
let dataRep: StaticDataReputation;
let paragon: CharacterReputationParagon;
let repTier: ReputationTier;
let skipPercent: boolean;

// characterRep={character.reputationData[slug].sets[reputationsIndex][reputationSetsIndex]}

Expand Down Expand Up @@ -85,6 +86,13 @@
) {
const hack = nazjatarHack(repTier.name);
cls = `reputation${hack}`;
// 30 => 1, 20 => 11, 10 => 11
if (repTier.maxValue > 0) {
const completedTiers = 30 - repTier.tier + 1;
const tierPercent = Math.floor((repTier.value / repTier.maxValue) * 10);
repTier.percent = `${completedTiers}.${tierPercent}`;
skipPercent = true;
}
} else {
cls = `reputation${repTier.tier}`;
}
Expand All @@ -109,13 +117,13 @@
class={cls}
use:componentTooltip={{
component: TooltipReputation,
props: {
propsFunc: () => ({
characterRep: characterRep.value,
character,
dataRep,
paragon,
reputation,
},
}),
}}
>
{#if paragon}
Expand All @@ -125,7 +133,7 @@
{repTier.percent}%
{/if}
{:else}
{repTier.percent}%
{repTier.percent}{skipPercent ? '' : '%'}
{/if}
</td>
{:else}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,13 @@
class:status-fail={characterParagon?.rewardAvailable}
use:componentTooltip={{
component: Tooltip,
props: {
propsFunc: () => ({
characterRep: characterRep.value,
character,
characterParagon,
dataRep,
reputation,
},
}),
}}
>
{renownLevel}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,10 @@ export function getRenownData({

ret.characterRep =
actualCharacter.reputationData[slug].sets[reputationsIndex][reputationSetsIndex];
const repValue = ret.characterRep.value === -1 ? 0 : ret.characterRep.value;
const repValue =
(ret.dataRep.accountWide
? userState.general.reputations[ret.dataRep.id]
: ret.characterRep.value) || 0;
if (ret.dataRep.renownCurrencyId > 0) {
const currency = wowthingData.static.currencyById.get(ret.dataRep.renownCurrencyId);
ret.renownMax = currency.maxTotal;
Expand Down
Loading
Loading