Exemplo n.º 1
0
    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));
    }
Exemplo n.º 2
0
 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]));
     }
 }
Exemplo n.º 3
0
 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]));
     }
 }
Exemplo n.º 4
0
    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);
        }
    }
Exemplo n.º 5
0
    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);
    }