Ejemplo n.º 1
0
        public void GameStart(long groupNum, long firstPlayer, long secondPlayer, int CaveNo, string BindAi)
        {
            var players = new[] { AdvPlayer.GetPlayer(firstPlayer), AdvPlayer.GetPlayer(secondPlayer) };

            players = Rander.RandSort(players);

            var engine = new AdvGameEngine(players, groupNum, CaveNo, BindAi);

            Engines.Add(engine);
            engine.GameStart();

            Engines.Remove(engine);
        }
Ejemplo n.º 2
0
        private void CheckWinner()
        {
            for (var i = 0; i < players.Length; i++)
            {
                if (players[i].HP > 0)
                {
                    continue;
                }

                Winner = players[(i + 1) % players.Length];
                return;
            }
        }
Ejemplo n.º 3
0
        private void Settlement()
        {
            var msg = $"对决结束!{CodeApi.Code_At(Winner.QQNum)}获取了胜利!";

            if (Bonus > 0)
            {
                msg += $"\r\n获得了全部赏金 {Bonus}金币!";
                var osPerson = OSPerson.GetPerson(Winner.QQNum);
                osPerson.Golds += Bonus;
                osPerson.Update();
            }
            MsgSender.PushMsg(GroupNum, 0, msg, BindAi);

            foreach (var player in players)
            {
                var p = AdvPlayer.GetPlayer(player.QQNum);
                p.BattleRecord(p.QQNum == Winner.QQNum);
                p.Update();
                if (p.QQNum != Winner.QQNum)
                {
                    var osPerson = OSPerson.GetPerson(p.QQNum);
                    osPerson.Golds -= 100;
                    osPerson.Update();
                    MsgSender.PushMsg(GroupNum, p.QQNum, $"你不幸输掉了对决,扣除100金币,你剩余金币为 {osPerson.Golds}", BindAi);
                    continue;
                }

                if (p.WinTotal % 10 != 0)
                {
                    continue;
                }

                var items = HonorSvc.CurMonthLimitItems();
                var item  = items.RandElement();
                MsgSender.PushMsg(GroupNum, p.QQNum, $"你已经累计赢得 {p.WinTotal}场对决,获取额外奖励 {item.Name}*1", BindAi);

                var record   = ItemCollectionRecord.Get(p.QQNum);
                var honorMsg = record.ItemIncome(item.Name);
                if (!string.IsNullOrEmpty(honorMsg))
                {
                    MsgSender.PushMsg(GroupNum, 0, honorMsg, BindAi);
                }
            }
        }
Ejemplo n.º 4
0
        public static AdvPlayer GetPlayer(long QQNum)
        {
            var player = MongoService <AdvPlayer> .GetOnly(p => p.QQNum == QQNum);

            if (player != null)
            {
                return(player);
            }

            player = new AdvPlayer()
            {
                QQNum  = QQNum,
                MinAtk = 0,
                MaxAtk = 10,
                Level  = 1,
                HP     = 10
            };
            MongoService <AdvPlayer> .Insert(player);

            return(player);
        }