Esempio n. 1
0
        /*
         * Value1 = Syn Actual Points or Player Actual Points
         */
        public void AwardPoints(Character pSender, uint dwPoints)
        {
            if (pSender.Syndicate == null || dwPoints == 0)
            {
                return;
            }

            DbDynamicRankRecord pDyna;

            if (!m_pSynPoints.TryGetValue(pSender.SyndicateIdentity, out pDyna))
            {
                pDyna = new DbDynamicRankRecord
                {
                    ObjectIdentity = pSender.SyndicateIdentity,
                    ObjectName     = pSender.SyndicateName,
                    PlayerIdentity = 0,
                    PlayerName     = "",
                    RankType       = _RANK_TYPE_U
                };
                m_pRepo.SaveOrUpdate(pDyna);
                m_pSynPoints.TryAdd(pDyna.ObjectIdentity, pDyna);
            }
            pDyna.Value1 += dwPoints;

            if (!m_pUserPoints.TryGetValue(pSender.Identity, out pDyna))
            {
                pDyna = new DbDynamicRankRecord
                {
                    ObjectIdentity = pSender.SyndicateIdentity,
                    ObjectName     = pSender.SyndicateName,
                    PlayerIdentity = pSender.Identity,
                    PlayerName     = pSender.Name,
                    RankType       = _RANK_TYPE_U
                };
                m_pRepo.SaveOrUpdate(pDyna);
                m_pUserPoints.TryAdd(pDyna.PlayerIdentity, pDyna);
            }
            else if (pDyna.ObjectIdentity != pSender.SyndicateIdentity)
            {
                pDyna.ObjectIdentity = pSender.SyndicateIdentity;
                pDyna.ObjectName     = pSender.SyndicateName;
                pDyna.Value1         = 0;
            }
            pDyna.Value1 += dwPoints;
        }
Esempio n. 2
0
        public void OnTimer()
        {
            int weekday = (int)(DateTime.Now.DayOfWeek) % 7 == 0 ? 7 : (int)(DateTime.Now.DayOfWeek);
            int now     = int.Parse(DateTime.Now.ToString("HHmmss")) + weekday * 1000000;

            if (m_pState == EventState.IDLE && now >= _STARTUP_TIME && now < _END_TIME)
            {
                GenerateFlags();

                foreach (var rank in m_pRanking.Values)
                {
                    rank.Value1 = 0;
                    rank.Value3 = 0;
                    m_pRepo.SaveOrUpdate(rank);
                }
                foreach (var rank in m_pUserRank.Values)
                {
                    rank.Value1 = 0;
                    rank.Value3 = 0;
                    m_pRepo.SaveOrUpdate(rank);
                }

                m_pState = EventState.RUNNING;
            }
            else if (m_pState == EventState.RUNNING)
            {
                if (m_tFlagGen.ToNextTime())
                {
                    GenerateFlags();
                }

                if (m_tRankSend.ToNextTime())
                {
                    // todo send ctf rank
                    List <string> pRank = new List <string>(9);
                    pRank.Add("Capture The Flag");
                    int count = 0;
                    foreach (var rnk in m_pRanking.Values.OrderByDescending(x => x.Value1))
                    {
                        if (rnk.Value1 > 0)
                        {
                            if (count++ < 8)
                            {
                                pRank.Add(string.Format("Nº{0}. {1} - {2}", count, rnk.ObjectName.PadRight(16),
                                                        rnk.Value1));
                            }
                            else
                            {
                                break;
                            }
                        }
                    }
                    foreach (var player in m_pMap.Players.Values.ToList())
                    {
                        player.Send(pRank[0], ChatTone.EVENT_RANKING);
                        for (int i = 1; i < pRank.Count; i++)
                        {
                            player.Send(pRank[i], ChatTone.EVENT_RANKING_NEXT);
                        }
                    }
                }

                if (now < _STARTUP_TIME || now >= _END_TIME)
                {
                    Finish();
                    DeliveRewards();
                    m_pState = EventState.IDLE;
                }
            }
            // if not, nothing will be done, event not loaded
        }