public Trophy(long characterId, long accountId, int trophyId) { TrophyMetadata trophyMetadata = TrophyMetadataStorage.GetMetadata(trophyId); Id = trophyId; LastReward = 1; NextGrade = 1; Timestamps = new List <long>(); MaxGrade = trophyMetadata.Grades.Count; TrophyGradeMetadata trophyGradeMetadata = trophyMetadata.Grades.FirstOrDefault(x => x.Grade == NextGrade); Condition = trophyGradeMetadata.Condition; ConditionType = trophyGradeMetadata.ConditionType; ConditionCodes = trophyGradeMetadata.ConditionCodes; ConditionTargets = trophyGradeMetadata.ConditionTargets; Type = trophyMetadata.Categories[0]; if (trophyMetadata.AccountWide) { AccountId = accountId; } else { CharacterId = characterId; } Uid = DatabaseManager.Trophies.Insert(this); }
public Trophy(Player player, int trophyId, int grade = 1, int counter = 0, List <long> timestamps = null, bool isDone = false) { Id = trophyId; NextGrade = grade; Counter = counter; Timestamps = timestamps ?? new List <long>(); MaxGrade = TrophyMetadataStorage.GetNumGrades(Id); Condition = TrophyMetadataStorage.GetGrade(Id, NextGrade).Condition; Type = TrophyMetadataStorage.GetMetadata(Id).Categories[0]; IsDone = isDone; Player = player; Uid = DatabaseManager.AddTrophy(this); }
public void AddCounter(GameSession session, long amount) { if (IsDone) { return; } Counter += amount; if (Counter >= Condition) { ProvideReward(session); NextGrade++; // level up but not completed if (NextGrade <= MaxGrade) { Condition = TrophyMetadataStorage.GetGrade(Id, NextGrade).Condition; } // level up and completed else { IsDone = true; NextGrade--; string[] categories = TrophyMetadataStorage.GetMetadata(Id).Categories; foreach (string category in categories) { switch (category) { case string s when s.Contains("combat"): session.Player.TrophyCount[0] += 1; break; case string s when s.Contains("adventure"): session.Player.TrophyCount[1] += 1; break; case string s when s.Contains("lifestyle"): session.Player.TrophyCount[2] += 1; break; } } } Timestamps.Add(DateTimeOffset.UtcNow.ToUnixTimeSeconds()); } }
public Trophy(long uid, int trophyId, int nextGrade, long counter, bool isDone, byte lastReward, List <long> timestamps, long characterId, long accountId) { TrophyMetadata trophyMetadata = TrophyMetadataStorage.GetMetadata(trophyId); Uid = uid; Id = trophyId; NextGrade = nextGrade; MaxGrade = trophyMetadata.Grades.Count; GradeCondition = trophyMetadata.Grades.FirstOrDefault(x => x.Grade == NextGrade); Type = trophyMetadata.Categories?[0] ?? ""; Counter = counter; IsDone = isDone; LastReward = lastReward; Timestamps = timestamps; CharacterId = characterId; AccountId = accountId; }
private static void HandleClaimReward(GameSession session, PacketReader packet) { int id = packet.ReadInt(); if (!session.Player.TrophyData.TryGetValue(id, out Trophy trophy)) { return; } TrophyMetadata metadata = TrophyMetadataStorage.GetMetadata(trophy.Id); List <TrophyGradeMetadata> grades = metadata.Grades.Where(x => x.Grade <= trophy.LastReward).ToList(); foreach (TrophyGradeMetadata grade in grades) { if (grade.Grade >= trophy.LastReward) { ProvideReward(grade, session); trophy.LastReward++; } } session.Send(TrophyPacket.WriteUpdate(trophy)); DatabaseManager.Trophies.Update(trophy); }
public void AddCounter(Player player, long amount) { Counter += amount; if (IsDone) { return; } if (Counter < GradeCondition.Condition) { return; } if (!RewardTypeRequiresClaim(GradeCondition.RewardType) && LastReward == NextGrade) { // Add stat points and skill points switch (GradeCondition.RewardType) { case RewardType.statPoint: player.AddStatPoint(GradeCondition.RewardValue, OtherStatsIndex.Trophy); break; case RewardType.skillPoint: // TODO: Add skill points break; } LastReward++; } NextGrade++; Timestamps.Add(TimeInfo.Now()); // level up but not completed if (NextGrade <= MaxGrade) { // Update condition GradeCondition = TrophyMetadataStorage.GetMetadata(Id).Grades.FirstOrDefault(x => x.Grade == NextGrade); return; } // level up and completed IsDone = true; NextGrade--; string[] categories = TrophyMetadataStorage.GetMetadata(Id).Categories; foreach (string category in categories) { switch (category) { case string s when s.Contains("combat"): player.TrophyCount[0] += 1; break; case string s when s.Contains("adventure"): player.TrophyCount[1] += 1; break; case string s when s.Contains("lifestyle"): player.TrophyCount[2] += 1; break; } } }
public void AddCounter(GameSession session, long amount) { Counter += amount; if (IsDone) { return; } if (Counter < Condition) { return; } TrophyGradeMetadata grade = TrophyMetadataStorage.GetMetadata(Id).Grades.FirstOrDefault(x => x.Grade == NextGrade); if (!RewardTypeRequiresClaim(grade.RewardType) && LastReward == NextGrade) { // Add stat points and skill points switch (grade.RewardType) { case RewardType.statPoint: session.Player.AddStatPoint(grade.RewardValue, OtherStatsIndex.Trophy); break; case RewardType.skillPoint: // TODO: Add skill points break; } LastReward++; } NextGrade++; Timestamps.Add(DateTimeOffset.UtcNow.ToUnixTimeSeconds()); // level up but not completed if (NextGrade <= MaxGrade) { // Update condition TrophyGradeMetadata trophyGradeMetadata = TrophyMetadataStorage.GetMetadata(Id).Grades.FirstOrDefault(x => x.Grade == NextGrade); Condition = trophyGradeMetadata.Condition; ConditionType = trophyGradeMetadata.ConditionType; ConditionCodes = trophyGradeMetadata.ConditionCodes; return; } // level up and completed IsDone = true; NextGrade--; string[] categories = TrophyMetadataStorage.GetMetadata(Id).Categories; foreach (string category in categories) { switch (category) { case string s when s.Contains("combat"): session.Player.TrophyCount[0] += 1; break; case string s when s.Contains("adventure"): session.Player.TrophyCount[1] += 1; break; case string s when s.Contains("lifestyle"): session.Player.TrophyCount[2] += 1; break; } } }