Ejemplo n.º 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);
        }
Ejemplo n.º 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);
        }