示例#1
0
        public bool Recruit(MsgInformationEx MsgDTO, object[] param)
        {
            var castle = KindomCastle.Get(MsgDTO.FromGroup, MsgDTO.FromQQ);

            var soldierGroups = SoldierGroup.Get(MsgDTO.FromQQ);
            var curTotal      = soldierGroups.Sum(g => g.Count);

            var remain = Math.Max(castle.SoldierMaxVolume - curTotal, 0);
            var msg    = $"你当前共拥有士兵 {curTotal}人,还可招募 {remain}人";

            if (remain == 0)
            {
                msg += "\r\n无法招募新的士兵!";
                MsgSender.PushMsg(MsgDTO, msg, true);
                return(false);
            }

            var golds = castle.Golds;

            msg += $"\r\n你当前拥有金钱 {golds},最多招募等量的士兵";
            if (golds == 0)
            {
                msg += "\r\n无法招募新的士兵!";
                MsgSender.PushMsg(MsgDTO, msg, true);
                return(false);
            }

            var maxRecruit = Math.Min(remain, golds);
            var num        = WaiterSvc.WaitForNum(MsgDTO.FromGroup, MsgDTO.FromQQ, $"请输入招募士兵的数量!(1~{maxRecruit})", p => p >= 1 && p <= maxRecruit, MsgDTO.BindAi);

            if (num <= 0)
            {
                MsgSender.PushMsg(MsgDTO, "操作取消!");
                return(false);
            }

            var group = new SoldierGroup()
            {
                Owner = MsgDTO.FromQQ,
                Count = num,
                State = SoldierState.Working,
                Name  = $"第{GroupNamingRec.GetNextNo(MsgDTO.FromQQ)}军"
            };

            group.Insert();

            castle.Golds -= num;
            castle.Update();

            MsgSender.PushMsg(MsgDTO, "招募成功!");
            return(true);
        }
示例#2
0
        public bool MyCastle(MsgInformationEx MsgDTO, object[] param)
        {
            var castle = KindomCastle.Get(MsgDTO.FromGroup, MsgDTO.FromQQ);
            var groups = SoldierGroup.Get(MsgDTO.FromQQ);

            var session = new MsgSession(MsgDTO);

            session.Add(castle.CastleName);
            session.Add($"城堡等级:{Utility.LevelEmoji(castle.Level)}");
            session.Add($"金钱:{castle.Golds}");
            session.Add($"粮草:{castle.Commissariat}");
            session.Add($"建筑:{string.Join(",", castle.Buildings.Select(p => $"{p.Key}(lv.{p.Value})"))}");
            session.Add($"军队:{groups.Count}支");
            session.Add($"士兵:{groups.Sum(g => g.Count)}人");

            session.Send();
            return(true);
        }
示例#3
0
        public bool Supply(MsgInformationEx MsgDTO, object[] param)
        {
            var castle = KindomCastle.Get(MsgDTO.FromGroup, MsgDTO.FromQQ);

            var starvingGroups = SoldierGroup.StarvingGroups(MsgDTO.FromQQ);

            if (starvingGroups.IsNullOrEmpty())
            {
                MsgSender.PushMsg(MsgDTO, "你没有需要补给的军队!", true);
                return(false);
            }

            var totalConsume     = 0;
            var feededGroupCount = 0;

            foreach (var starvingGroup in starvingGroups)
            {
                if (castle.Commissariat < starvingGroup.Count)
                {
                    break;
                }

                castle.Commissariat -= starvingGroup.Count;
                starvingGroup.Feed();
                totalConsume += starvingGroup.Count;
                feededGroupCount++;
            }
            castle.Update();

            var session = new MsgSession(MsgDTO);

            session.Add("补给完成!");
            session.Add($"共补给 {feededGroupCount}支军队,共消耗粮草 {totalConsume}");
            session.Add($"当前剩余 {starvingGroups.Count - feededGroupCount}支军队尚未补给,当前剩余粮草 {castle.Commissariat}");

            session.Send();
            return(true);
        }