Exemplo n.º 1
0
        private void Game_15Talk_Thread(object obj)
        {
            string tmp = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff");

            while (true)
            {
                if (!m_15AnnStop)
                {
                    string t_start = tmp;
                    //string t_end = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff");
                    string t_end = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
                    tmp = t_end;
                    //查询数据库
                    List <LogItemSearch> logList = CSGHelper.SearchLogItem(m_MaxAnn, t_start, t_end, m_AnnItemsList);
                    foreach (var item in logList)
                    {
                        bool send = true;
                        if (m_FilterList != null)
                        {
                            foreach (var name in m_FilterList)
                            {
                                if (name == item.from_name)
                                {
                                    send = false;
                                    break;
                                }
                            }
                        }

                        if (send)
                        {
                            string words = "";
                            if (item.type == "合成强化物品")
                            {
                                words = "贺!玩家 " + item.from_name + " 经千锤百炼,炼造出 " + item.item_name + "。";
                                SendWorldWords(words);
                                //日志
                                LogHelper.WriteLog("加持公共日志.txt", words);
                            }
                            else if (item.type == "怪物掉落")
                            {
                                words = "这是何等人品,玩家 " + item.from_name + " 在怪物掉落获得了 " + item.item_name + ",真是可喜可贺!";

                                SendWorldWords(words);
                                //日志
                                LogHelper.WriteLog("怪物掉落公共日志.txt", words);
                            }
                        }
                    }


                    Thread.Sleep(m_AnnSrchInterVal * 1000);
                }
                else
                {
                    m_15AnnARE.WaitOne();
                }
            }
        }
Exemplo n.º 2
0
        public void SendWarReward(string name, WarRewordConf conf)
        {
            uint xbCount1 = conf.count1;
            uint xbCount2 = conf.count2;
            uint xbCount3 = conf.count3;
            uint xbCount4 = conf.count4;
            uint xbCount5 = conf.count5;
            uint xbId1    = conf.id1;
            uint xbId2    = conf.id2;
            uint xbId3    = conf.id3;
            uint xbId4    = conf.id4;
            uint xbId5    = conf.id5;

            if (xbId1 == 0)
            {
                xbId1    = 1;
                xbCount1 = 0;
            }
            if (xbId2 == 0)
            {
                xbId2    = 1;
                xbCount2 = 0;
            }
            if (xbId3 == 0)
            {
                xbId3    = 1;
                xbCount3 = 0;
            }
            if (xbId4 == 0)
            {
                xbId4    = 1;
                xbCount4 = 0;
            }
            if (xbId5 == 0)
            {
                xbId5    = 1;
                xbCount5 = 0;
            }
            string cmd = "INSERT INTO " + "sanvt_hcsg" + @".dbo.vitem (Account,Disable,Card,Login_time,Get_time,SName,CharName,Type,"
                         + "DataID1,Number1,DataID2,Number2,DataID3,Number3,DataID4,Number4,DataID5,Number5)"
                         + "values ('" + CPlayerCtrl.GetAccByName(name) + "',0,CONVERT(varchar(100), GETDATE(), 21),getdate(),getdate(),0,0,0,"
                         + xbId1 + "," + xbCount1 + "," + xbId2 + "," + xbCount2 + "," + xbId3 + "," + xbCount3 + "," + xbId4 + "," + xbCount4 + "," + xbId5 + "," + xbCount5 + ")";
            string ret = CSGHelper.SqlCommand(cmd);
        }
Exemplo n.º 3
0
        public void SendWarReward(string name, WarRewordConf conf)
        {
            uint xbCount1 = conf.count1;
            uint xbCount2 = conf.count2;
            uint xbCount3 = conf.count3;
            uint xbCount4 = conf.count4;
            uint xbCount5 = conf.count5;
            uint xbId1    = conf.id1;
            uint xbId2    = conf.id2;
            uint xbId3    = conf.id3;
            uint xbId4    = conf.id4;
            uint xbId5    = conf.id5;

            if (xbId1 == 0)
            {
                xbId1    = 1;
                xbCount1 = 0;
            }
            if (xbId2 == 0)
            {
                xbId2    = 1;
                xbCount2 = 0;
            }
            if (xbId3 == 0)
            {
                xbId3    = 1;
                xbCount3 = 0;
            }
            if (xbId4 == 0)
            {
                xbId4    = 1;
                xbCount4 = 0;
            }
            if (xbId5 == 0)
            {
                xbId5    = 1;
                xbCount5 = 0;
            }

            CSGHelper.InsertSanvtItem(CPlayerCtrl.GetAccByName(name)
                                      , (uint)xbId1, (uint)xbCount1, (uint)xbId2, (uint)xbCount2, (uint)xbId3, (uint)xbCount3
                                      , (uint)xbId4, (uint)xbCount4, (uint)xbId5, (uint)xbCount5);
        }
Exemplo n.º 4
0
        private void Game_QA_Thread(object obj)
        {
            while (true)
            {
                if (!m_QAStop)
                {
                    //check time
                    if (IsTaskTime())
                    {
                        answerResult.Clear();
                        while (m_QACount < m_MaxQuesNum)
                        {
                            if (m_QACount == 0)
                            {
                                SendWorldWords("三国知识竞答即将开始!请各位玩家做好答题准备,找个安静的地图或者关闭不需要的频道");
                                Thread.Sleep(10 * 1000);
                                SendWorldWords("最先给出正确答案者获得积分,答题需在军团或者军团互通中,发送且仅发送正确选项,否则答题将会被认为无效而过滤。");
                                Thread.Sleep(20 * 1000);
                                SendWorldWords("答题开始!");
                                Thread.Sleep(2 * 1000);
                            }
                            SingleAQHandle(1, m_PlayerDat);
                        }

                        //遍历参与者列表排名
                        answerResult.Sort(new Comparison <AnswerResult_S>(AnswerResultCompare));
                        if (answerResult.Count <= 0)
                        {
                            string msg = "很遗憾,本次答题无人优胜!";
                            LogHelper.WriteLog(DateTime.Now.ToString("yyyy-MM-dd") + @"答题日志.txt", msg);
                            SendWorldWords(msg);
                        }
                        else
                        {
                            int num = 0;
                            List <AnswerResult_S> ff  = new List <AnswerResult_S>();
                            AnswerResult_S        tmp = new AnswerResult_S();
                            tmp.score = 0;
                            for (int i = 0; i < answerResult.Count; i++)
                            {
                                if (tmp.score == answerResult[i].score)
                                {
                                    tmp.name   += "," + answerResult[i].name;
                                    ff[num - 1] = tmp;
                                }
                                else
                                {
                                    tmp = answerResult[i];
                                    ff.Add(tmp);
                                    num++;
                                }
                            }

                            int best = ff.Count > 3 ? 3 : ff.Count;
                            for (int i = 0; i < best; i++)
                            {
                                string msg = "第" + (i + 1) + "名 总得分:" + ff[i].score + " 玩家 " + ff[i].name + "。";
                                LogHelper.WriteLog(DateTime.Now.ToString("yyyy-MM-dd") + @"答题日志.txt", msg);

                                //公告
                                SendWorldWords(msg);
                            }
                            for (int i = 0; i < best; i++)
                            {
                                //发放虚宝
                                CPlayerCtrl.PlayersAttrListClear();
                                CPlayerCtrl.LoadPlayerInfos(m_PlayerDat, true);
                                var players = ff[i].name.Split(',');
                                foreach (var player in players)
                                {
                                    if (!string.IsNullOrEmpty(player))
                                    {
                                        string account = CPlayerCtrl.GetAccByName(player);
                                        if (m_TaskRewardString.Count > 0)
                                        {
                                            int      vtid1    = 0;
                                            int      vtid2    = 0;
                                            int      vtid3    = 0;
                                            int      vtid4    = 0;
                                            int      vtid5    = 0;
                                            int      vtcount1 = 0;
                                            int      vtcount2 = 0;
                                            int      vtcount3 = 0;
                                            int      vtcount4 = 0;
                                            int      vtcount5 = 0;
                                            string[] rewards  = m_TaskRewardString[i].Split(';'); //1,木剑,1
                                            for (int ii = 0; ii <= rewards.Length; ii++)
                                            {
                                                var detials = rewards[ii].Split(',');
                                                if (ii == 0)
                                                {
                                                    vtid1    = int.Parse(detials[0]);
                                                    vtcount1 = int.Parse(detials[2]);
                                                }
                                                else if (ii == 1)
                                                {
                                                    vtid2    = int.Parse(detials[0]);
                                                    vtcount2 = int.Parse(detials[2]);
                                                }
                                                else if (ii == 2)
                                                {
                                                    vtid3    = int.Parse(detials[0]);
                                                    vtcount3 = int.Parse(detials[2]);
                                                }
                                                else if (ii == 3)
                                                {
                                                    vtid4    = int.Parse(detials[0]);
                                                    vtcount4 = int.Parse(detials[2]);
                                                }
                                                else if (ii == 4)
                                                {
                                                    vtid5    = int.Parse(detials[0]);
                                                    vtcount5 = int.Parse(detials[2]);
                                                }
                                            }

                                            if (vtid1 != 0 || vtid2 != 0 || vtid3 != 0 || vtid4 != 0 || vtid5 != 0)
                                            {
                                                bool vtret = CSGHelper.InsertSanvtItem(account
                                                                                       , (uint)vtid1, (uint)vtcount1, (uint)vtid2, (uint)vtcount2, (uint)vtid3, (uint)vtcount3, (uint)vtid4, (uint)vtcount4, (uint)vtid5, (uint)vtcount5);
                                                if (vtret)
                                                {
                                                    string answerEx = "角色:" + player + " 答题奖励已经发放,请注意查收(虚宝)!";
                                                    //日志
                                                    LogHelper.WriteLog(DateTime.Now.ToString("yyyy-MM-dd") + "答题日志.txt", answerEx);
                                                }
                                            }
                                        }
                                        else
                                        {
                                            //发放虚宝
                                            bool vtret = CSGHelper.InsertSanvtItem(account, (uint)m_AnswerVtId, 1, 0, 0, 0, 0, 0, 0, 0, 0);
                                            if (vtret)
                                            {
                                                string answerEx = "角色:" + player + " 答题奖励已经发放,请注意查收(虚宝)!";
                                                //日志
                                                LogHelper.WriteLog(DateTime.Now.ToString("yyyy-MM-dd") + "答题日志.txt", answerEx);
                                            }
                                        }
                                    }
                                }
                            }
                            //公告
                            SendWorldWords("排名奖励已经发放,请注意查收(虚宝)!");

                            answerResult.Clear();
                        }
                    }
                    else
                    {
                        if (m_SleepCount >= m_AskNormalInterval)//60 *
                        {
                            m_SleepCount = 0;
                            SingleAQHandle(0, m_PlayerDat);
                        }
                        Thread.Sleep(1000);
                        m_SleepCount++;
                    }
                }
                else
                {
                    m_QAARE.WaitOne();
                }
            }
        }
Exemplo n.º 5
0
        private bool SingleAQHandle(int flag, string player_dat)
        {
            long            tick = DateTime.Now.Ticks;
            Random          ran  = new Random((int)(tick & 0xffffffffL) | (int)(tick >> 32));
            List <BankItem> list = bankHandle.GetBankItemList();

            int n = ran.Next(0, bankHandle.GetBankItemCount());

            BankItem item;
            bool     ret = bankHandle.GetItem(n, out item);

            string tmp      = "";
            string nextQues = "";

            if (flag == 0)//普通
            {
                tmp      = "在线问答题:";
                nextQues = " 约" + m_AskNormalInterval / 60 + "分钟后开始下一题,请关注公屏提问!";
            }
            else //系列
            {
                m_QACount++;
                tmp      = "第" + m_QACount + "题:";
                nextQues = " 十秒后开始下一题,请做好准备!";
            }

            string t_start, t_end;

            SendWorldWords(tmp + item.question);
            //记录发题时间 //2017-01-02 13:01:47.000 System.DateTime.Now.ToString("f"); //2008-4-24 16:30:15
            t_start = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
            Thread.Sleep(m_QuesInterval * 1000);
            //记录结尾时间
            t_end = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
            //查询数据库
            List <LogSearch> logList = CSGHelper.SearchLogMsg(item.answer, t_start, t_end);

            string answerEx = "";

            if (logList.Count > 0)
            {
                LogSearch firtItem = logList[0];
                answerEx = "恭喜 " + firtItem.name + " 抢答成功";

                if (flag == 0)
                {
                    CPlayerCtrl.PlayersAttrListClear();
                    CPlayerCtrl.LoadPlayerInfos(player_dat, true);
                    string account = CPlayerCtrl.GetAccByName(firtItem.name);
                    //发放虚宝

                    if (m_NormalRewardItems.Count() > 0)
                    {
                        int    rewardIdex   = ran.Next(0, m_NormalRewardItems.Count());
                        int    AnswerVtId   = int.Parse(m_NormalRewardItems[rewardIdex].id);
                        string AnswerVtName = m_NormalRewardItems[rewardIdex].name;
                        bool   vtret        = CSGHelper.InsertSanvtItem(account, (uint)AnswerVtId, 1, 0, 0, 0, 0, 0, 0, 0, 0);
                        if (vtret)
                        {
                            answerEx += " 答题奖励 " + AnswerVtName + " 已经发放,请注意查收(虚宝)!";
                        }
                        //日志
                        LogHelper.WriteLog(DateTime.Now.ToString("yyyy-MM-dd") + "答题日志.txt", answerEx);
                    }
                    else
                    {
                        int    AnswerVtId   = m_AnswerVtId;
                        string AnswerVtName = m_AnswerVtName;
                        bool   vtret        = CSGHelper.InsertSanvtItem(account, (uint)AnswerVtId, 1, 0, 0, 0, 0, 0, 0, 0, 0);
                        if (vtret)
                        {
                            answerEx += " 答题奖励 " + AnswerVtName + " 已经发放,请注意查收(虚宝)!";
                        }
                        //日志
                        LogHelper.WriteLog(DateTime.Now.ToString("yyyy-MM-dd") + "答题日志.txt", answerEx);
                    }
                }
                else
                {
                    //日志
                    LogHelper.WriteLog(DateTime.Now.ToString("yyyy-MM-dd") + "答题日志.txt", answerEx);

                    //遍历参与者列表
                    AnswerResult_S newNode;
                    bool           found = false;

                    for (int i = 0; i < answerResult.Count; i++)
                    {
                        if (answerResult[i].name == firtItem.name)
                        {
                            newNode = answerResult[i];
                            newNode.score++;
                            answerResult[i] = newNode;
                            found           = true;
                            break;
                        }
                    }
                    if (!found)//未找到
                    {
                        //add
                        newNode.name  = firtItem.name;
                        newNode.score = 1;
                        answerResult.Add(newNode);
                    }
                }
            }
            else
            {
                answerEx = "很遗憾,无人能正确答对此题";
            }

            SendWorldWords("答案是:" + item.answer + " " + answerEx + nextQues);
            Thread.Sleep(10 * 1000);

            return(true);
        }