コード例 #1
0
 internal void InitMailData(List <MailInfo> mailList)
 {
     foreach (var mail in mailList)
     {
         if (mail.m_Module == ModuleMailTypeEnum.GowModule || mail.m_Module == ModuleMailTypeEnum.ArenaModule)
         {
             ModuleMailInfo moduleMail = new ModuleMailInfo();
             moduleMail.m_MailGuid   = mail.m_MailGuid;
             moduleMail.m_Module     = mail.m_Module;
             moduleMail.m_SendTime   = mail.m_SendTime;
             moduleMail.m_ExpiryDate = mail.m_ExpiryDate;
             m_ModuleMails.Add(moduleMail);
         }
         else
         {
             if (mail.m_Receiver == 0)
             {
                 m_WholeMails.Add(mail);
             }
             else
             {
                 List <MailInfo> userMailList = null;
                 if (!m_UserMails.TryGetValue(mail.m_Receiver, out userMailList))
                 {
                     userMailList = new List <MailInfo>();
                     m_UserMails.Add(mail.m_Receiver, userMailList);
                 }
                 userMailList.Add(mail);
             }
         }
     }
     m_IsDataLoaded = true;
 }
コード例 #2
0
        public MailInfo GetMail(ModuleMailInfo moduleMailInfo, UserInfo user, bool onlyAttachment)
        {
            DateTime         day   = moduleMailInfo.m_SendTime;
            ArenaPrizeConfig prize = GetDayPrize(user.Guid, day);

            if (prize == null)
            {
                //LogSys.Log(LOG_TYPE.DEBUG, "not find player {0} date {1} prize!", user.Guid, day);
                return(null);
            }
            MailInfo mail = moduleMailInfo.NewDerivedMailInfo();

            if (!onlyAttachment)
            {
                mail.m_Title  = "$1111$";
                mail.m_Text   = "$1112$";
                mail.m_Sender = "$1113$";
            }
            mail.m_Gold  = prize.Gold;
            mail.m_Money = prize.Money;
            foreach (PrizeItemConfig item_config in prize.Items)
            {
                MailItem mail_item = new MailItem();
                mail_item.m_ItemId  = item_config.ItemId;
                mail_item.m_ItemNum = item_config.ItemNum;
                mail.m_Items.Add(mail_item);
            }
            //LogSys.Log(LOG_TYPE.DEBUG, "player {0} got arena day {1} prize {2} isOnlyAttachment {3}", user.Guid, day, prize.Gold, onlyAttachment);
            return(mail);
        }
コード例 #3
0
        internal void Tick()
        {
            var ds_thread = LobbyServer.Instance.DataStoreThread;

            if (ds_thread.DataStoreAvailable)
            {
                if (!m_IsDataLoaded)
                {
                    return;
                }
            }
            long curTime = ArkCrossEngine.TimeUtility.GetServerMilliseconds();

            if (m_LastTickTime + c_TickInterval < curTime)
            {
                m_LastTickTime = curTime;
                //清理过期邮件
                int ct = m_WholeMails.Count;
                for (int index = ct - 1; index >= 0; --index)
                {
                    MailInfo mailInfo = m_WholeMails[index];
                    if (null != mailInfo)
                    {
                        if (mailInfo.m_ExpiryDate < DateTime.Now)
                        {
                            m_WholeMails.RemoveAt(index);
                        }
                    }
                }
                int count = m_ModuleMails.Count;
                for (int index = count - 1; index >= 0; --index)
                {
                    ModuleMailInfo moduleMail = m_ModuleMails[index];
                    if (null != moduleMail)
                    {
                        if (moduleMail.m_ExpiryDate < DateTime.Now)
                        {
                            m_ModuleMails.RemoveAt(index);
                        }
                    }
                }
                foreach (List <MailInfo> mails in m_UserMails.Values)
                {
                    int mailCt = mails.Count;
                    for (int index = mailCt - 1; index >= 0; --index)
                    {
                        MailInfo mailInfo = mails[index];
                        if (null != mailInfo)
                        {
                            if (mailInfo.m_ExpiryDate < DateTime.Now)
                            {
                                mails.RemoveAt(index);
                            }
                        }
                    }
                }
            }
        }
コード例 #4
0
ファイル: GowSystem.cs プロジェクト: myl2232/ArkCrossEngine
 public bool HaveMail(ModuleMailInfo moduleMailInfo, UserInfo user)
 {
     if (user.GowInfo.GowElo > 100)
     {
         return(true);
     }
     else
     {
         return(false);
     }
 }
コード例 #5
0
 internal void Tick()
 {
     if (DateTime.Now > m_NextPrizeDate)
     {
         m_NextPrizeDate = ArenaSystem.GetNextExcuteDate(m_PrizePresentTime);
         ModuleMailInfo module_mail = new ModuleMailInfo();
         module_mail.m_Module = ModuleMailTypeEnum.ArenaModule;
         if (m_MailSystem != null)
         {
             m_MailSystem.SendModuleMail(module_mail, ArenaSystem.PRIZE_RETAIN_DAYS);
         }
     }
 }
コード例 #6
0
        internal void SendModuleMail(ModuleMailInfo moduleMail, int validityPeriod)
        {
            moduleMail.m_MailGuid   = GenMailGuid();
            moduleMail.m_SendTime   = DateTime.Now;
            moduleMail.m_ExpiryDate = moduleMail.m_SendTime.AddDays(validityPeriod);
            m_ModuleMails.Add(moduleMail);
            JsonMessageNotifyNewMail newMailMsg  = new JsonMessageNotifyNewMail();
            DataProcessScheduler     dataProcess = LobbyServer.Instance.DataProcessScheduler;

            dataProcess.VisitUsers((UserInfo userInfo) =>
            {
                newMailMsg.m_Guid = userInfo.Guid;
                JsonMessageDispatcher.SendDcoreMessage(userInfo.NodeName, newMailMsg);
            });
        }
コード例 #7
0
        internal void ReadMail(ulong userGuid, ulong mailGuid)
        {
            DataProcessScheduler dataProcess = LobbyServer.Instance.DataProcessScheduler;
            UserInfo             user        = dataProcess.GetUserInfo(userGuid);

            if (null != user)
            {
                List <MailInfo> mails;
                if (m_UserMails.TryGetValue(userGuid, out mails))
                {
                    if (null != mails)
                    {
                        int ct    = mails.Count;
                        int index = 0;
                        for (; index < ct; ++index)
                        {
                            if (mails[index].m_MailGuid == mailGuid)
                            {
                                MailInfo info = mails[index];
                                info.m_AlreadyRead = true;
                                break;
                            }
                        }
                    }
                }
                MailStateInfo mailStateInfo = user.MailStateInfo;
                int           wholeCt       = m_WholeMails.Count;
                for (int index = 0; index < wholeCt; ++index)
                {
                    MailInfo info = m_WholeMails[index];
                    if (info.m_MailGuid == mailGuid)
                    {
                        mailStateInfo.ReadMail(mailGuid);
                        break;
                    }
                }
                int moduleCt = m_ModuleMails.Count;
                for (int index = 0; index < moduleCt; ++index)
                {
                    ModuleMailInfo mailInfo = m_ModuleMails[index];
                    if (mailInfo.m_MailGuid == mailGuid)
                    {
                        mailStateInfo.ReadMail(mailGuid);
                        break;
                    }
                }
            }
        }
コード例 #8
0
        public bool HaveMail(ModuleMailInfo moduleMailInfo, UserInfo user)
        {
            DateTime  day        = moduleMailInfo.m_SendTime;
            ArenaInfo arena_info = m_Rank.GetRankEntityById(user.Guid);

            if (arena_info == null)
            {
                return(false);
            }
            int day_rank           = arena_info.GetDaysRank(day);
            ArenaPrizeConfig prize = GetFitPrize(day_rank);

            if (prize == null)
            {
                return(false);
            }
            return(true);
        }
コード例 #9
0
ファイル: GowSystem.cs プロジェクト: myl2232/ArkCrossEngine
        public MailInfo GetMail(ModuleMailInfo moduleMailInfo, UserInfo user, bool onlyAttachment)
        {
            MailInfo mailInfo = null;

            mailInfo = moduleMailInfo.NewDerivedMailInfo();
            if (!onlyAttachment)
            {
                mailInfo.m_Title  = "$1$";
                mailInfo.m_Text   = "$2$";
                mailInfo.m_Sender = "$3$";
            }
            int      gowElo   = 0;
            DateTime sendDate = mailInfo.m_SendTime.Date;
            DateTime sendTime = new DateTime(sendDate.Year, sendDate.Month, sendDate.Day, m_PrizeTime.m_Hour, m_PrizeTime.m_Minute, m_PrizeTime.m_Second);
            long     key      = sendTime.ToBinary();
            SortedList <long, int> history = user.GowInfo.HistoryGowElos;

            foreach (long key0 in history.Keys)
            {
                if (key >= key0)
                {
                    gowElo = history[key0];
                    break;
                }
            }
            if (gowElo > 0)
            {
                GowPrizeConfig cfg = GowConfigProvider.Instance.FindGowPrizeConfig(user.GowInfo.RankId);
                if (null != cfg)
                {
                    mailInfo.m_Money = cfg.Money;
                    mailInfo.m_Gold  = cfg.Gold;
                    foreach (GowPrizeItem item_config in cfg.Items)
                    {
                        MailItem mail_item = new MailItem();
                        mail_item.m_ItemId  = item_config.ItemId;
                        mail_item.m_ItemNum = item_config.ItemNum;
                        mailInfo.m_Items.Add(mail_item);
                    }
                    return(mailInfo);
                }
            }
            return(null);
        }
コード例 #10
0
        internal bool HaveMail(ulong userGuid)
        {
            bool ret = false;
            DataProcessScheduler dataProcess = LobbyServer.Instance.DataProcessScheduler;
            UserInfo             user        = dataProcess.GetUserInfo(userGuid);

            if (null != user)
            {
                List <MailInfo> userMails;
                if (m_UserMails.TryGetValue(userGuid, out userMails) && userMails.Count > 0)
                {
                    ret = true;
                }
                MailStateInfo mailStateInfo = user.MailStateInfo;
                int           wholeMailCt   = m_WholeMails.Count;
                for (int ix = 0; ix < wholeMailCt; ++ix)
                {
                    MailInfo mailInfo = m_WholeMails[ix];
                    if (mailInfo.m_LevelDemand <= user.Level && mailInfo.m_SendTime >= user.CreateTime && mailInfo.m_ExpiryDate >= DateTime.Now && !mailStateInfo.IsAlreadyReceived(mailInfo.m_MailGuid))
                    {
                        ret = true;
                        break;
                    }
                }
                int moduleMailCt = m_ModuleMails.Count;
                for (int ix = 0; ix < moduleMailCt; ++ix)
                {
                    ModuleMailInfo     mailInfo = m_ModuleMails[ix];
                    IModuleMailHandler handler  = GetModuleMailHandler(mailInfo.m_Module);
                    if (null != handler)
                    {
                        if (handler.HaveMail(mailInfo, user))
                        {
                            ret = true;
                            break;
                        }
                    }
                }
            }
            return(ret);
        }
コード例 #11
0
        internal void ReceiveMail(ulong userGuid, ulong mailGuid)
        {
            DataProcessScheduler dataProcess = LobbyServer.Instance.DataProcessScheduler;
            UserInfo             user        = dataProcess.GetUserInfo(userGuid);

            if (null != user)
            {
                List <MailInfo> mails;
                if (m_UserMails.TryGetValue(userGuid, out mails))
                {
                    if (null != mails)
                    {
                        MailInfo info  = null;
                        int      ct    = mails.Count;
                        int      index = 0;
                        for (; index < ct; ++index)
                        {
                            if (mails[index].m_MailGuid == mailGuid)
                            {
                                info = mails[index];
                                break;
                            }
                        }
                        if (null != info)
                        {
                            mails.RemoveAt(index);
                            ExtractMailAttachment(info, userGuid);
                        }
                    }
                }
                MailStateInfo mailStateInfo = user.MailStateInfo;
                if (!mailStateInfo.IsAlreadyReceived(mailGuid))
                {
                    int wholeCt = m_WholeMails.Count;
                    for (int index = 0; index < wholeCt; ++index)
                    {
                        MailInfo info = m_WholeMails[index];
                        if (info.m_MailGuid == mailGuid)
                        {
                            mailStateInfo.ReceiveMail(mailGuid);
                            if (info.m_LevelDemand <= user.Level && info.m_SendTime >= user.CreateTime && info.m_ExpiryDate >= DateTime.Now)
                            {
                                ExtractMailAttachment(info, userGuid);
                            }
                        }
                    }
                    int moduleCt = m_ModuleMails.Count;
                    for (int index = 0; index < moduleCt; ++index)
                    {
                        ModuleMailInfo mailInfo = m_ModuleMails[index];
                        if (mailInfo.m_MailGuid == mailGuid)
                        {
                            mailStateInfo.ReceiveMail(mailGuid);
                            if (mailInfo.m_SendTime >= user.CreateTime && mailInfo.m_ExpiryDate >= DateTime.Now)
                            {
                                IModuleMailHandler handler = GetModuleMailHandler(mailInfo.m_Module);
                                if (null != handler)
                                {
                                    MailInfo info = handler.GetMail(mailInfo, user, true);
                                    if (null != info)
                                    {
                                        ExtractMailAttachment(info, userGuid);
                                    }
                                }
                            }
                            break;
                        }
                    }
                }
            }
        }
コード例 #12
0
        internal void GetMailList(ulong userGuid)
        {
            DataProcessScheduler dataProcess = LobbyServer.Instance.DataProcessScheduler;
            UserInfo             user        = dataProcess.GetUserInfo(userGuid);

            if (null != user)
            {
                List <MailInfoForMessage> mailList = new List <MailInfoForMessage>();
                List <MailInfo>           mails;
                if (m_UserMails.TryGetValue(userGuid, out mails))
                {
                    int ct = mails.Count;
                    for (int ix = 0; ix < ct; ++ix)
                    {
                        MailInfo mailInfo = mails[ix];
                        if (mailInfo.m_ExpiryDate >= DateTime.Now)
                        {
                            MailInfoForMessage mailInfoForMsg = new MailInfoForMessage();
                            mailInfoForMsg.m_AlreadyRead = mailInfo.m_AlreadyRead;
                            mailInfoForMsg.m_MailGuid    = mailInfo.m_MailGuid;
                            mailInfoForMsg.m_Module      = (int)mailInfo.m_Module;
                            mailInfoForMsg.m_Title       = mailInfo.m_Title;
                            mailInfoForMsg.m_Sender      = mailInfo.m_Sender;
                            mailInfoForMsg.m_SendTime    = mailInfo.m_SendTime;
                            mailInfoForMsg.m_Text        = mailInfo.m_Text;
                            mailInfoForMsg.m_Money       = mailInfo.m_Money;
                            mailInfoForMsg.m_Gold        = mailInfo.m_Gold;
                            mailInfoForMsg.m_Stamina     = mailInfo.m_Stamina;
                            int itemCt = mailInfo.m_Items.Count;
                            if (itemCt > 0)
                            {
                                mailInfoForMsg.m_Items = new MailItemForMessage[itemCt];
                                for (int index = 0; index < itemCt; ++index)
                                {
                                    MailItemForMessage mailItem = new MailItemForMessage();
                                    mailItem.m_ItemId             = mailInfo.m_Items[index].m_ItemId;
                                    mailItem.m_ItemNum            = mailInfo.m_Items[index].m_ItemNum;
                                    mailInfoForMsg.m_Items[index] = mailItem;
                                }
                            }
                            mailList.Add(mailInfoForMsg);
                        }
                    }
                }
                MailStateInfo mailStateInfo = user.MailStateInfo;
                //这里不对用户数据加锁,因为用户的邮件状态的改变都在这个线程完成(除上线时的数据加载)
                int wholeMailCt = m_WholeMails.Count;
                for (int ix = 0; ix < wholeMailCt; ++ix)
                {
                    MailInfo mailInfo = m_WholeMails[ix];
                    if (mailInfo.m_LevelDemand <= user.Level && mailInfo.m_SendTime >= user.CreateTime && mailInfo.m_ExpiryDate >= DateTime.Now && !mailStateInfo.IsAlreadyReceived(mailInfo.m_MailGuid))
                    {
                        if (!mailStateInfo.HaveMail(mailInfo.m_MailGuid))
                        {
                            mailStateInfo.AddMail(mailInfo.m_MailGuid, mailInfo.m_ExpiryDate);
                        }
                        MailInfoForMessage mailInfoForMsg = new MailInfoForMessage();
                        mailInfoForMsg.m_AlreadyRead = mailStateInfo.IsAlreadyRead(mailInfo.m_MailGuid);
                        mailInfoForMsg.m_MailGuid    = mailInfo.m_MailGuid;
                        mailInfoForMsg.m_Module      = (int)mailInfo.m_Module;
                        mailInfoForMsg.m_Title       = mailInfo.m_Title;
                        mailInfoForMsg.m_Sender      = mailInfo.m_Sender;
                        mailInfoForMsg.m_SendTime    = mailInfo.m_SendTime;
                        mailInfoForMsg.m_Text        = mailInfo.m_Text;
                        mailInfoForMsg.m_Money       = mailInfo.m_Money;
                        mailInfoForMsg.m_Gold        = mailInfo.m_Gold;
                        mailInfoForMsg.m_Stamina     = mailInfo.m_Stamina;
                        int itemCt = mailInfo.m_Items.Count;
                        if (itemCt > 0)
                        {
                            mailInfoForMsg.m_Items = new MailItemForMessage[itemCt];
                            for (int index = 0; index < itemCt; ++index)
                            {
                                MailItemForMessage mailItem = new MailItemForMessage();
                                mailItem.m_ItemId             = mailInfo.m_Items[index].m_ItemId;
                                mailItem.m_ItemNum            = mailInfo.m_Items[index].m_ItemNum;
                                mailInfoForMsg.m_Items[index] = mailItem;
                            }
                        }
                        mailList.Add(mailInfoForMsg);
                    }
                }
                int moduleMailCt = m_ModuleMails.Count;
                for (int ix = 0; ix < moduleMailCt; ++ix)
                {
                    ModuleMailInfo moduleMailInfo = m_ModuleMails[ix];
                    if (moduleMailInfo.m_SendTime >= user.CreateTime && moduleMailInfo.m_ExpiryDate >= DateTime.Now && !mailStateInfo.IsAlreadyReceived(moduleMailInfo.m_MailGuid))
                    {
                        if (!mailStateInfo.HaveMail(moduleMailInfo.m_MailGuid))
                        {
                            mailStateInfo.AddMail(moduleMailInfo.m_MailGuid, moduleMailInfo.m_ExpiryDate);
                        }
                        IModuleMailHandler handler = GetModuleMailHandler(moduleMailInfo.m_Module);
                        if (null != handler)
                        {
                            MailInfo mailInfo = handler.GetMail(moduleMailInfo, user, false);
                            if (null != mailInfo)
                            {
                                MailInfoForMessage mailInfoForMsg = new MailInfoForMessage();
                                mailInfoForMsg.m_AlreadyRead = mailStateInfo.IsAlreadyRead(moduleMailInfo.m_MailGuid);
                                mailInfoForMsg.m_MailGuid    = mailInfo.m_MailGuid;
                                mailInfoForMsg.m_Module      = (int)mailInfo.m_Module;
                                mailInfoForMsg.m_Title       = mailInfo.m_Title;
                                mailInfoForMsg.m_Sender      = mailInfo.m_Sender;
                                mailInfoForMsg.m_SendTime    = mailInfo.m_SendTime;
                                mailInfoForMsg.m_Text        = mailInfo.m_Text;
                                mailInfoForMsg.m_Money       = mailInfo.m_Money;
                                mailInfoForMsg.m_Gold        = mailInfo.m_Gold;
                                mailInfoForMsg.m_Stamina     = mailInfo.m_Stamina;
                                int itemCt = mailInfo.m_Items.Count;
                                if (itemCt > 0)
                                {
                                    mailInfoForMsg.m_Items = new MailItemForMessage[itemCt];
                                    for (int index = 0; index < itemCt; ++index)
                                    {
                                        MailItemForMessage mailItem = new MailItemForMessage();
                                        mailItem.m_ItemId             = mailInfo.m_Items[index].m_ItemId;
                                        mailItem.m_ItemNum            = mailInfo.m_Items[index].m_ItemNum;
                                        mailInfoForMsg.m_Items[index] = mailItem;
                                    }
                                }
                                mailList.Add(mailInfoForMsg);
                            }
                        }
                    }
                }
                JsonMessageSyncMailList syncMailListMsg = new JsonMessageSyncMailList();
                syncMailListMsg.m_Guid  = userGuid;
                syncMailListMsg.m_Mails = mailList.ToArray();
                JsonMessageDispatcher.SendDcoreMessage(user.NodeName, syncMailListMsg);
            }
        }
コード例 #13
0
 internal void SendModuleMail(ModuleMailInfo moduleMail, int validityPeriod)
 {
     m_MailSystem.SendModuleMail(moduleMail, validityPeriod);
 }