public override void Execute(GameCommandTrigger trigger) { Player player = trigger.Session.Player; int trophyId = trigger.Get <int>("trophyId"); int amount = trigger.Get <int>("amount"); if (trophyId == 0) { trigger.Session.Send(NoticePacket.Notice("Type an trophy id!", NoticeType.Chat)); return; } if (!player.TrophyData.ContainsKey(trophyId)) { player.TrophyData[trophyId] = new(player.CharacterId, player.AccountId, trophyId); } player.TrophyData[trophyId].AddCounter(trigger.Session.Player, amount); player.TrophyData.TryGetValue(trophyId, out Trophy trophy); trigger.Session.Send(TrophyPacket.WriteUpdate(trophy)); DatabaseManager.Trophies.Update(trophy); trigger.Session.Send(NoticePacket.Notice("Done!", NoticeType.Chat)); }
public void TrophyUpdate(int trophyId, long addAmount, int sendUpdateInterval = 1) { if (!TrophyData.ContainsKey(trophyId)) { TrophyData[trophyId] = new Trophy(trophyId); } TrophyData[trophyId].AddCounter(Session, addAmount); if (TrophyData[trophyId].Counter % sendUpdateInterval == 0) { Session.Send(TrophyPacket.WriteUpdate(TrophyData[trophyId])); } }
public void TrophyUpdate(int trophyId, long addAmount, int sendUpdateInterval = 1) { if (!TrophyData.ContainsKey(trophyId)) { TrophyData[trophyId] = new Trophy(CharacterId, AccountId, trophyId); } TrophyData[trophyId].AddCounter(Session, addAmount); if (TrophyData[trophyId].Counter % sendUpdateInterval == 0) { DatabaseManager.Trophies.Update(TrophyData[trophyId]); Session.Send(TrophyPacket.WriteUpdate(TrophyData[trophyId])); } }
private static void UpdateMatchingTrophies(Player player, IEnumerable <TrophyMetadata> trophies, int progress) { IEnumerable <int> trophyIds = trophies.Select(t => t.Id); foreach (int trophyId in trophyIds) { if (!player.TrophyData.ContainsKey(trophyId)) { player.TrophyData[trophyId] = new(player.CharacterId, player.AccountId, trophyId); } player.TrophyData[trophyId].AddCounter(player, progress); player.TrophyData.TryGetValue(trophyId, out Trophy trophy); player.Session?.Send(TrophyPacket.WriteUpdate(trophy)); DatabaseManager.Trophies.Update(trophy); } }
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); }