Пример #1
0
        private BattleUser GetUser(MessageContent client)
        {
            string id = client.FromGroup.Group.Id + "_" + client.FromQQ.Id;

            if (Users.ContainsKey(id))
            {
                return(Users[id]);
            }

            Users[id] = new BattleUser()
            {
                QQId   = client.FromQQ.Id,
                QQName = client.FromQQ.GetNick(client.FromGroup.RobotQQ),
                EcUser = CommandSystem.GetModule(typeof(EcommerceCommand)).GetPlugInter("get").Invoke(client),
                Group  = client.FromGroup
            };

            return(Users[id]);
        }
Пример #2
0
        private BattleUser GetUserByGroupMember(GroupMember member, MessageContent client)
        {
            string id = client.FromGroup.Group.Id + "_" + member.QQ;

            if (Users.ContainsKey(id))
            {
                Users[id].QQName = !string.IsNullOrEmpty(member.GroupNickName) ? member.GroupNickName : member.NickName;
                return(Users[id]);
            }

            Users[id] = new BattleUser()
            {
                QQId   = member.QQ,
                QQName = string.IsNullOrEmpty(member.GroupNickName)? member.GroupNickName:member.NickName,
                EcUser = CommandSystem.GetModule(typeof(EcommerceCommand)).GetPlugInter("get").Invoke(client),
                Group  = client.FromGroup
            };

            return(Users[id]);
        }
Пример #3
0
        private BattleResult ProcessBattle(BattleUser source, BattleUser target)
        {
            string       sName       = source.QQName;
            string       tName       = target.QQName;
            BattleResult result      = new BattleResult();
            int          sourceLevel = LevelCalc(source);
            int          targetLevel = LevelCalc(target);

            int damage = DamageCalc(sourceLevel, targetLevel);

            result.TargetDamage = damage;
            //如果攻击对象等级比自己高,自己受到反伤
            if (sourceLevel < targetLevel)
            {
                result.SourceDamage = Convert.ToInt32(damage / 2);
            }

            //处理角色
            target.Hp -= result.TargetDamage;
            source.Hp -= result.SourceDamage;
            if (source.Hp < 0)
            {
                SendMessage(source.Group, $"{sName}已进入濒危状态,请输入#买活 复活,费用100G", "Battle System");
            }
            if (target.Hp < 0)
            {
                SendMessage(target.Group, $"{tName}已进入濒危状态,请输入#买活 复活,费用100G", "Battle System");
                SendMessage(source.Group, $"{sName}成功击破了[{tName}] 获得200G,30EXP", "Battle System");
                source.EcUser.Gold += 200;
                source.Exp         += 30;

                int newLevel = LevelCalc(source);
                if (newLevel > sourceLevel)
                {
                    SendMessage(source.Group, $"恭喜{sName}升级,当前等级{newLevel},您的HP已全部回复", "Battle System");
                    source.Hp = 500;
                }
            }
            return(result);
        }
Пример #4
0
 private int LevelCalc(BattleUser user)
 {
     return(Convert.ToInt32(Math.Floor(user.Exp / 100f)));
 }