Example #1
0
        /// <summary>
        /// 竞技场宠物疲劳值增加
        /// </summary>
        /// <param name="model"></param>
        /// <param name="user">角色</param>
        /// <param name="type">0表示负,1胜,2平</param>
        public static void AddFatigue(ArenaBase model, PlayerBusiness user, int type)
        {
            GameConfig gc = GameConfigAccess.Instance.FindOneById(model.ArenaID);
            if (gc == null)
                return;

            Variant t = gc.Value;
            Variant petLevel = t.GetValueOrDefault<Variant>("PetLevel").GetValueOrDefault<Variant>(model.PetMin + "-" + model.PetMax);
            if (petLevel == null)
                return;

            int addFatigue = 0;//战斗增加疲劳值
            switch (type)
            {
                case 0:
                    addFatigue = petLevel.GetIntOrDefault("Lose");
                    break;
                case 1:
                    addFatigue = petLevel.GetIntOrDefault("Win");
                    break;
                case 2:
                    addFatigue = petLevel.GetIntOrDefault("Ping");
                    break;
            }

            if (user.ID == model.PlayerID)
            {
                addFatigue = Convert.ToInt32(addFatigue * (1 - petLevel.GetDoubleOrDefault("FarmLv")));
            }

            foreach (Pet p in model.Pets.Values)
            {
                if (p.PlayerID != user.ID)
                    continue;
                Variant v = p.Value;
                //取得宠物最大疲劳值
                int max = PetAccess.Instance.MaxFatigue(v.GetIntOrDefault("PetsLevel"));

                if (p.PlayerID == user.ID)
                {
                    if (v.GetIntOrDefault("Fatigue") + addFatigue >= max)
                    {
                        v["Fatigue"] = max;
                    }
                    else
                    {
                        v["Fatigue"] = v.GetIntOrDefault("Fatigue") + addFatigue;
                    }

                    p.SaveFatigue();

                    Variant tmp = new Variant();
                    tmp.Add("ID",p.ID);
                    tmp.Add("Fatigue", v.GetIntOrDefault("Fatigue"));
                    user.Call(PetsCommand.UpdatePetR, true, tmp);
                    //Console.WriteLine("宠物名称:" + p.Name + ",当前疲劳值:" + v.GetIntOrDefault("Fatigue") + ",增加量:" + addFatigue + ",输赢:" + type);
                }
            }
        }
Example #2
0
        /// <summary>
        /// 创建竞技场
        /// </summary>
        /// <param name="playerid">角色</param>        
        /// <param name="model"></param>        
        /// <returns>0表示创建成功,1该竞技场已经存在,2你已经创建有竞技场</returns>
        public int CreateArenaBase(string playerid, ArenaBase model)
        {
            if (IsAreneBase(playerid))
                return 2;

            if (!m_doc.TryAdd(model.SoleID, model))
            {
                return 1;
            }
            return 0;
        }
Example #3
0
        /// <summary>
        /// 补充宠物的HP/MP
        /// </summary>
        /// <param name="v"></param>
        /// <returns></returns>
        private static bool SupplyPet(Variant v, Pet m_pet, ArenaBase model, string name)
        {
            bool use = false;
            //庞物
            if (m_pet == null) return use;
            Variant pet = m_pet.Value;
            if (pet == null) return use;

            Variant moFa = pet.GetVariantOrDefault("MoFa");
            Variant shengMing = pet.GetVariantOrDefault("ShengMing");

            double dhp = v.GetDoubleOrDefault("HP");
            double dmp = v.GetDoubleOrDefault("MP");
            int hp, mp;
            if (dhp <= 1)
            {
                hp = (int)(dhp * shengMing.GetIntOrDefault("M")); //百分比方式
            }
            else
            {
                hp = (int)(dhp);
            }
            if (dmp <= 1)
            {
                mp = (int)(dmp * moFa.GetIntOrDefault("M")); //百分比方式
            }
            else
            {
                mp = (int)(dmp);
            }

            if (hp > 0)
            {
                int sv = shengMing.GetIntOrDefault("V");
                int need = shengMing.GetIntOrDefault("M") - sv;
                if (need > 0)
                {
                    m_pet.HP = Math.Min(need, hp) + sv;
                    shengMing["V"] = m_pet.HP;
                    use = true;
                }
            }

            if (mp > 0)
            {
                int mv = moFa.GetIntOrDefault("V");
                int need = moFa.GetIntOrDefault("M") - mv;
                if (need > 0)
                {
                    m_pet.MP = Math.Min(need, mp) + mv;
                    moFa["V"] = m_pet.MP;
                    use = true;
                }
            }

            if (hp > 0 || mp > 0)
            {
                List<PetDetail> list = new List<PetDetail>();
                PetDetail detail = new PetDetail(m_pet, name);
                list.Add(detail);
                model.CallAll(ArenaCommand.ArenaGoodsR, true, list);
                m_pet.Save();
            }
            return use;
        }
Example #4
0
        /// <summary>
        /// 竞技场创建限制
        /// </summary>
        /// <param name="note"></param>
        /// <param name="model">选择条件</param>
        /// <param name="v">限制条件</param>
        /// <returns></returns>
        private static bool ArenaLimit(UserNote note, ArenaBase model, Variant v)
        {
            int score = 0;
            int level = note.Player.Level;
            int fightvalue = 0;
            Variant gametime = v.GetValueOrDefault<Variant>("GameTime").GetValueOrDefault<Variant>(model.GameTime.ToString());
            if (gametime == null)
            {
                //请选择战斗时长
                note.Call(ArenaCommand.CreateArenaR, false, TipManager.GetMessage(ArenaReturn.ArenaLimit1));
                return false;
            }
            score += gametime.GetIntOrDefault("Score");
            fightvalue += gametime.GetIntOrDefault("FightValue");

            Variant group = v.GetValueOrDefault<Variant>("Group").GetValueOrDefault<Variant>(model.Group.ToString());
            if (group == null)
            {
                //请选择分组
                note.Call(ArenaCommand.CreateArenaR, false, TipManager.GetMessage(ArenaReturn.ArenaLimit2));
                return false;
            }
            score += group.GetIntOrDefault("Score");
            fightvalue += group.GetIntOrDefault("FightValue");

            if (!string.IsNullOrEmpty(model.PassWord))
            {
                Variant password = v.GetValueOrDefault<Variant>("PassWord").GetValueOrDefault<Variant>("1");
                if (password != null)
                {
                    score += password.GetIntOrDefault("Score");
                    fightvalue += password.GetIntOrDefault("FightValue");
                }
            }

            Variant petlevel = v.GetValueOrDefault<Variant>("PetLevel").GetValueOrDefault<Variant>(model.PetMin + "-" + model.PetMax);
            if (petlevel == null)
            {
                //请选择战宠等级
                note.Call(ArenaCommand.CreateArenaR, false, TipManager.GetMessage(ArenaReturn.ArenaLimit3));
                return false;
            }
            score += petlevel.GetIntOrDefault("Score");
            fightvalue += petlevel.GetIntOrDefault("FightValue");

            Variant petnumber = v.GetValueOrDefault<Variant>("PetNumber").GetValueOrDefault<Variant>(model.PetNumber.ToString());
            if (petnumber == null)
            {
                //请选择各组产战宠物数量
                note.Call(ArenaCommand.CreateArenaR, false, TipManager.GetMessage(ArenaReturn.ArenaLimit4));
                return false;
            }
            score += petnumber.GetIntOrDefault("Score");
            fightvalue += petnumber.GetIntOrDefault("FightValue");

            Variant preparetime = v.GetValueOrDefault<Variant>("PrepareTime").GetValueOrDefault<Variant>(model.PrepareTime.ToString());
            if (preparetime == null)
            {
                //请选择准备时间
                note.Call(ArenaCommand.CreateArenaR, false, TipManager.GetMessage(ArenaReturn.ArenaLimit5));
                return false;
            }
            score += preparetime.GetIntOrDefault("Score");
            fightvalue += preparetime.GetIntOrDefault("FightValue");

            Variant scene = v.GetValueOrDefault<Variant>("Scene").GetValueOrDefault<Variant>(model.Scene.ToString());
            if (scene == null)
            {
                //请选择竞技场
                note.Call(ArenaCommand.CreateArenaR, false, TipManager.GetMessage(ArenaReturn.ArenaLimit6));
                return false;
            }
            Variant userpets = v.GetValueOrDefault<Variant>("UserPets").GetValueOrDefault<Variant>(model.UserPets.ToString());
            if (userpets == null)
            {
                //请选择角色参战宠物数量
                note.Call(ArenaCommand.CreateArenaR, false, TipManager.GetMessage(ArenaReturn.ArenaLimit7));
                return false;
            }
            score += userpets.GetIntOrDefault("Score");
            fightvalue += userpets.GetIntOrDefault("FightValue");

            Variant fightpoor = v.GetValueOrDefault<Variant>("FightPoor").GetValueOrDefault<Variant>(model.FightPoor.ToString());
            if (fightpoor == null)
            {
                //请选择战绩差
                note.Call(ArenaCommand.CreateArenaR, false, TipManager.GetMessage(ArenaReturn.ArenaLimit8));
                return false;
            }
            score += fightpoor.GetIntOrDefault("Score");
            fightvalue += fightpoor.GetIntOrDefault("FightValue");

            //if (note.Player.FightValue< fightvalue)
            //{
            //    note.Call(ArenaCommand.CreateArenaR, false, "战绩值不足");
            //    return false;
            //}

            if (score < 0)
            {
                //配置有问题
                note.Call(ArenaCommand.CreateArenaR, false, TipManager.GetMessage(ArenaReturn.ArenaLimit9));
                return false;
            }

            if (note.Player.Score < score)
            {
                //石币不足,不能创建
                note.Call(ArenaCommand.CreateArenaR, false, TipManager.GetMessage(ArenaReturn.ArenaLimit10));
                return false;
            }

            if (!note.Player.AddScore(-score, FinanceType.CreateArena))
            {
                //石币不足,不能创建
                note.Call(ArenaCommand.CreateArenaR, false, TipManager.GetMessage(ArenaReturn.ArenaLimit10));
                return false;
            }

            //if (!note.Player.AddFightValue(-fightvalue, true, FinanceType.CreateArena))
            //{
            //    note.Call(ArenaCommand.CreateArenaR, false, "战绩值不足");
            //    return false;
            //}
            //战绩设置
            model.FightValue = note.Player.FightValue;
            return true;
        }
Example #5
0
        /// <summary>
        /// 创建竞技场
        /// </summary>
        /// <param name="note"></param>
        public static void CreateArena(UserNote note)
        {
            string soleid = note.PlayerID + "CreateArena";
            if (!m_dic.TryAdd(soleid, soleid))
                return;
            try
            {
                Variant m = note.GetVariant(0);
                if (m == null)
                {
                    //参数为不能为空
                    note.Call(ArenaCommand.CreateArenaR, false, TipManager.GetMessage(ArenaReturn.CreateArena1));
                    return;
                }
                ArenaBase model = new ArenaBase();
                model.PlayerID = note.PlayerID;
                model.ArenaID = m.GetStringOrDefault("ID");

                GameConfig gc = GameConfigAccess.Instance.FindOneById(model.ArenaID);
                if (gc == null)
                {
                    //竞技场基本配置不正确
                    note.Call(ArenaCommand.CreateArenaR, false, TipManager.GetMessage(ArenaReturn.CreateArena2));
                    return;
                }
                Variant v = gc.Value;
                if (v == null)
                {
                    note.Call(ArenaCommand.CreateArenaR, false, TipManager.GetMessage(ArenaReturn.CreateArena2));
                    return;
                }
                //ArenaConfig.ArenaInfo(gc);

                model.Group = m.GetIntOrDefault("Group");
                //if (!ArenaConfig.IsGroup(model.Group))
                //{
                //    note.Call(ArenaCommand.CreateArenaR, false, "分组数量不正确");
                //    return;
                //}

                //Variant group = v.GetValueOrDefault<Variant>("Group").GetValueOrDefault<Variant>(model.Group.ToString());

                string petlevel = m.GetStringOrDefault("PetLevel");
                //if (!ArenaConfig.IsPetLevel(petlevel))
                //{
                //    note.Call(ArenaCommand.CreateArenaR, false, "请选择宠物等级限制");
                //    return;
                //}

                int petmix = 0;
                int petmax = 0;

                string[] strs = petlevel.Split('-');

                if (!int.TryParse(strs[0], out petmix))
                {
                    //请选择宠物最底等级限制
                    note.Call(ArenaCommand.CreateArenaR, false, TipManager.GetMessage(ArenaReturn.CreateArena3));
                    return;
                }
                if (!int.TryParse(strs[1], out petmax))
                {
                    //请选择宠物最高等级限制
                    note.Call(ArenaCommand.CreateArenaR, false, TipManager.GetMessage(ArenaReturn.CreateArena4));
                    return;
                }

                model.PetMin = petmix;
                model.PetMax = petmax;

                model.WarType = m.GetIntOrDefault("WinType");
                if (model.WarType == 0)
                {
                    for (int i = 0; i < model.Group; i++)
                    {
                        model.GroupName.Add(i.ToString());
                    }
                }

                model.IsOtherInto = m.GetBooleanOrDefault("IsOtherInto");
                model.IsWatch = m.GetBooleanOrDefault("IsWatch");

                if (model.IsOtherInto && (!model.IsWatch))
                {
                    //允许中途参战必须可以观战
                    note.Call(ArenaCommand.CreateArenaR, false, TipManager.GetMessage(ArenaReturn.CreateArena5));
                    return;
                }

                model.IsGoods = m.GetBooleanOrDefault("IsGoods");

                model.WinType = m.GetIntOrDefault("WinType");

                model.Scene = m.GetStringOrDefault("Scene");

                GameConfig sc = GameConfigAccess.Instance.FindOneById(model.Scene);
                if (sc == null)
                {
                    //场景不存在
                    note.Call(ArenaCommand.CreateArenaR, false, TipManager.GetMessage(ArenaReturn.CreateArena6));
                    return;
                }
                //得到场景信息
                model.SceneSession = new ArenaScene(sc);

                int PrepareTime = m.GetIntOrDefault("PrepareTime");
                model.PrepareTime = PrepareTime;

                int GameTime = m.GetIntOrDefault("GameTime");
                model.GameTime = GameTime;

                DateTime dt = DateTime.UtcNow;

                model.StartTime = dt.AddMinutes(PrepareTime);

                model.EndTime = model.StartTime.AddMinutes(GameTime);
                model.PetNumber = m.GetIntOrDefault("PetNumber");
                model.Name = note.Player.Name;
                //密码设置
                model.PassWord = m.GetStringOrDefault("PassWord");
                model.SoleID = GetAreneID();// Guid.NewGuid().ToString("N");
                model.UserPets = m.GetIntOrDefault("UserPets");
                model.FightPoor = m.GetIntOrDefault("FightPoor");
                if (!ArenaLimit(note, model, v))
                    return;

                ArenaBusiness dal = new ArenaBusiness();
                int a = dal.CreateArenaBase(note.PlayerID, model);
                if (a == 0)
                {
                    PlayersProxy.CallAll(ArenaCommand.CreateArenaR, new object[] { true, note.Player.Name });
                    return;
                }
                if (a == 1)
                {
                    //该竞技场已经存在
                    note.Call(ArenaCommand.CreateArenaR, false, TipManager.GetMessage(ArenaReturn.CreateArena7));
                    return;
                }
                if (a == 2)
                {
                    //你已经创建有竞技场,不能再创建
                    note.Call(ArenaCommand.CreateArenaR, false, TipManager.GetMessage(ArenaReturn.CreateArena8));
                    return;
                }
            }
            finally
            {
                m_dic.TryRemove(soleid, out soleid);
            }
        }
Example #6
0
        /// <summary>
        /// 战斗信息
        /// </summary>
        public static void FightInfo()
        {
            if (ArenaBusiness.ArenaList.Count == 0)
                return;
            ArenaBase[] ab = new ArenaBase[ArenaBusiness.ArenaList.Count];
            ArenaBusiness.ArenaList.Values.CopyTo(ab, 0);
            for (int i = 0; i < ab.Length; i++)
            {
                ArenaBase model = ab[i];

                foreach (Pet p in model.Pets.Values)
                {
                    CurPoint(p);
                }

                if (model.Status == 0)
                {
                    if (model.StartTime <= DateTime.UtcNow)
                    {
                        CheckArenaStart(model);
                    }
                }
                else if (model.Status == 1)
                {
                    if (FightEnd(model))
                    {
                        model.Status = 2;

                        //竞技场结束,计算战斗结果
                        model.CallAll(ArenaCommand.ArenaEndR, SettleMessage(model));
                        ArenaBase tmp;
                        if (ArenaBusiness.ArenaList.TryRemove(model.SoleID, out tmp))
                        {
                            PlayerOut(tmp);
                        }
                        //foreach (PlayerBusiness user in tmp.Players.Values)
                        //{
                        //    user.GroupName = "";
                        //    user.SoleID = "";
                        //    user.SetActionState(ActionState.Standing);
                        //}
                    }
                    else
                    {
                        //战斗计算
                        Fight(model);
                    }
                }
            }
        }
Example #7
0
 /// <summary>
 /// 退出竞技场
 /// </summary>
 /// <param name="model"></param>
 private static void PlayerOut(ArenaBase model)
 {
     foreach (PlayerBusiness user in model.Players.Values)
     {
         user.GroupName = "";
         user.SoleID = "";
         user.SetActionState(ActionState.Standing);
     }
 }
Example #8
0
        /// <summary>
        /// 检查竞技场是否结束
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        private static bool FightEnd(ArenaBase model)
        {
            List<string> group = new List<string>();
            foreach (Pet p in model.Pets.Values)
            {
                Variant v = p.Value;
                if (v.GetValueOrDefault<Variant>("ShengMing").GetIntOrDefault("V") > 0)
                {
                    if (!group.Contains(p.GroupName))
                    {
                        group.Add(p.GroupName);
                    }
                }
            }

            //表示还有多组,没有分出胜负
            if (model.EndTime > DateTime.UtcNow && group.Count > 1)
                return false;
            ArenaSettle(model);
            return true;
        }
Example #9
0
        /// <summary>
        /// 战斗计算
        /// </summary>
        private static void Fight(ArenaBase model)
        {
            ArenaScene scene = model.SceneSession;

            ConcurrentDictionary<string, Pet> doc = model.Pets;
            foreach (Pet p in doc.Values)
            {
                Variant root = p.Value;
                Variant rsm = root.GetValueOrDefault<Variant>("ShengMing");
                //不能再攻击别人
                if (rsm.GetIntOrDefault("V") <= 0)
                {
                    p.CoolingTime = 0;
                    continue;
                }

                if (p.CoolingTime > 0)
                {
                    p.CoolingTime -= 500;
                    if (p.CoolingTime > 0)
                        continue;
                }

                Variant rmf = root.GetValueOrDefault<Variant>("MoFa");

                FightBase fightBase = new FightBase(model);
                fightBase.ID = p.ID;
                fightBase.Name = p.Name;
                fightBase.PlayerID = p.PlayerID;
                fightBase.Persons = 1;

                int CoolingTime = 0;

                if (!string.IsNullOrEmpty(p.CurSkill))
                {
                    GameConfig gc = GameConfigAccess.Instance.FindOneById(p.CurSkill);
                    if (gc != null)
                    {
                        //得到技能基本信息
                        ArenaSkill askill = new ArenaSkill(gc);
                        askill.BaseLevel(p.CurLevel);
                        if (rmf.GetIntOrDefault("V") >= askill.MPCost)
                        {
                            fightBase.Persons += askill.AddTargets;
                            //攻击方魔法消耗值
                            fightBase.MPCost = askill.MPCost;
                            fightBase.InjuryType = askill.InjuryType;
                            fightBase.A = askill.A;
                            fightBase.B = askill.B;
                            fightBase.CurSkill = p.CurSkill;
                            CoolingTime = askill.CoolingTime;

                            p.Range = askill.Range;//技能攻击范围
                        }
                        else
                        {
                            p.Range = 100;
                        }
                    }
                    else
                    {
                        p.Range = 100;
                    }
                }
                else
                {
                    p.Range = 100;
                }

                List<PetFightDetail> list = new List<PetFightDetail>();

                bool isRangetPet = false;
                if (!string.IsNullOrEmpty(p.RangePet))
                {
                    //主动攻击的宠物
                    Pet pt;
                    if (doc.TryGetValue(p.RangePet, out pt))
                    {
                        if (ChechFight(p, pt))
                        {
                            //主要攻击目标
                            fightBase.RangePet = pt.ID;
                            isRangetPet = true;
                            list.Add(fightBase.FightObject(p, pt));
                        }
                    }
                }

                //循环所有宠物,寻找可攻击的目标
                if (fightBase.Persons > list.Count)
                {
                    foreach (Pet pet in doc.Values)
                    {
                        if (ChechFight(p, pet))
                        {
                            if (!isRangetPet)
                            {
                                //主要攻击目标
                                fightBase.RangePet = pet.ID;
                            }
                            else
                            {
                                //主要攻击目标已经被攻击
                                if (pet.ID == fightBase.RangePet)
                                    continue;
                            }
                            list.Add(fightBase.FightObject(p, pet));
                            //攻击对象已经满,不需要再找
                            if (list.Count == fightBase.Persons)
                                break;
                        }
                    }
                }

                if (list.Count > 0)
                {
                    if (CoolingTime <= 0)
                    {
                        //攻击成功添加冷却时间
                        CoolingTime = 3000;
                    }
                    p.CoolingTime = CoolingTime;
                    //当前
                    rmf["V"] = rmf.GetIntOrDefault("V") - fightBase.MPCost;
                    fightBase.MoFa = rmf;
                    fightBase.ShengMing = rsm;

                    PetFightDetail gongji = new PetFightDetail(fightBase);
                    model.CallAll(ArenaCommand.ArenaFightR, gongji, list);
                }
            }
        }
Example #10
0
        /// <summary>
        /// 检查竞技场是否可以开始
        /// </summary>
        /// <param name="model">竞技场</param>
        /// <returns></returns>
        private static void CheckArenaStart(ArenaBase model)
        {
            Dictionary<string, int> dic = new Dictionary<string, int>();
            foreach (Pet p in model.Pets.Values)
            {
                if (!dic.ContainsKey(p.GroupName))
                {
                    dic.Add(p.GroupName, 1);
                }
                else
                {
                    dic[p.GroupName]++;
                }

                PlayerBusiness user;
                if (model.Players.TryGetValue(p.PlayerID, out user))
                {
                    Settle settle;
                    if (!model.SettleInfo.TryGetValue(p.PlayerID, out settle))
                    {
                        settle = new Settle();
                        settle.PlayerID = p.PlayerID;
                        settle.GroupName = p.GroupName;
                        settle.PlayerName = user.Name;
                        settle.ResultType = 0;
                        model.SettleInfo.TryAdd(p.PlayerID, settle);
                    }
                }
            }

            if (dic.Count <= 1)
            {
                //竞技场不满足开始条件
                model.CallAll(ArenaCommand.ArenaStartR, false,TipManager.GetMessage(ArenaReturn.CheckArenaStart1));
                ArenaBase tmp;
                if (ArenaBusiness.ArenaList.TryRemove(model.SoleID, out tmp))
                {
                    PlayerOut(tmp);
                }
                return;
            }

            model.Status = 1;
            //竞技场开始
            model.CallAll(ArenaCommand.ArenaStartR, true, TipManager.GetMessage(ArenaReturn.CheckArenaStart2));
        }
Example #11
0
        /// <summary>
        /// 竞技场结算
        /// </summary>
        /// <param name="model"></param>
        private static void ArenaSettle(ArenaBase model)
        {
            //判断组的胜负平关系,如果在结束时存在多组还有存活的宠物

            Dictionary<string, int> dic = new Dictionary<string, int>();
            foreach (string groupName in model.GroupName)
            {
                bool groupWin = false;

                foreach (Pet p in model.Pets.Values)
                {
                    Variant v = p.Value;
                    Variant shengMing = v.GetValueOrDefault<Variant>("ShengMing");
                    if (groupName == p.GroupName && shengMing.GetIntOrDefault("V") > 0)
                    {
                        groupWin = true;
                        break;
                    }
                }
                int win = groupWin ? 1 : 0;
                if (!dic.ContainsKey(groupName))
                {
                    dic.Add(groupName, win);
                }
            }

            int group = 0;//表示存在多少组存活的情况
            foreach (var item in dic)
            {
                if (item.Value == 1)
                {
                    group++;
                }
            }

            GameConfig gc = GameConfigAccess.Instance.FindOneById(model.ArenaID);
            if (gc == null) return;
            Variant t = gc.Value;
            Variant petLevel = t.GetValueOrDefault<Variant>("PetLevel").GetValueOrDefault<Variant>(model.PetMin + "-" + model.PetMax);
            if (petLevel == null)
                return;

            foreach (Settle s in model.SettleInfo.Values)
            {
                int otherFight = 0;
                int m = 0;
                int isType = 0;
                if (dic.TryGetValue(s.GroupName, out m))
                {
                    if (m == 0)
                    {
                        //输
                        otherFight = Convert.ToInt32(s.WinFight * 0.15 + s.LossFight * 1.5) - petLevel.GetIntOrDefault("LossFight");
                        isType = 0;
                    }
                    else if (m == 1 && group == 1)
                    {
                        //胜利
                        otherFight = Convert.ToInt32(s.WinFight * 0.25) + petLevel.GetIntOrDefault("WinFight");
                        isType = 1;
                    }
                    else
                    {
                        //平局
                        otherFight = Convert.ToInt32(s.WinFight * 0.1 + s.LossFight * 0.1);
                        isType = 2;
                    }
                }

                s.ResultType = isType;
                //附加战绩值
                s.OtherFight = otherFight;
                s.TotalFight = s.OtherFight + s.WinFight + s.LossFight;

                PlayerBusiness user;
                if (model.Players.TryGetValue(s.PlayerID, out user))
                {
                    user.AddFightValue(s.TotalFight, false, FinanceType.AuctionSell);
                    AddFatigue(model, user, s.ResultType);

                    if (s.ResultType == 1)
                    {
                        //竞技场胜利次数
                        user.FinishNote(FinishCommand.ArenaWin);
                    }
                }
            }
        }
Example #12
0
        /// <summary>
        /// 中途断线处理
        /// </summary>
        public static void UseDis(ArenaBase model, string playerid)
        {
            PlayerBusiness user;
            if (!model.Players.TryGetValue(playerid, out user))
                return;
            //表示没有参战竞技场
            if (string.IsNullOrEmpty(user.GroupName))
                return;
            GameConfig gc = GameConfigAccess.Instance.FindOneById(model.ArenaID);
            if (gc == null) return;
            Variant t = gc.Value;
            Variant petLevel = t.GetValueOrDefault<Variant>("PetLevel").GetValueOrDefault<Variant>(model.PetMin + "-" + model.PetMax);
            if (petLevel == null)
                return;

            Settle s;
            if (model.SettleInfo.TryGetValue(playerid, out s))
            {
                s.ResultType = 0;
                s.GroupName = user.GroupName;
            }
            else
            {
                s = new Settle();
                s.PlayerID = playerid;
                s.ResultType = 0;
                s.GroupName = user.GroupName;
                model.SettleInfo.TryAdd(playerid, s);
            }
            s.OtherFight = Convert.ToInt32(s.WinFight * 0.15 - s.LossFight * 1.5) - petLevel.GetIntOrDefault("LossFight");
            s.TotalFight = s.OtherFight + s.WinFight + s.LossFight;
            user.AddFightValue(s.TotalFight, false, FinanceType.AuctionSell);

            AddFatigue(model, user, 0);

            string title = "";
            string content = "";
            if (s.TotalFight >= 0)
            {
                // "致光荣的战场逃亡者";
                title = TipManager.GetMessage(ArenaReturn.UseDis1);
                //"你在竞技场的脱逃让人失望,不过凭着卓越的战斗技巧,仍然获得了X点附加战绩奖励。希望勇者不再以战败者的方式离开战场!";
                content = TipManager.GetMessage(ArenaReturn.UseDis2);
            }
            else
            {
                //"致可耻的战场逃亡者";
                title = TipManager.GetMessage(ArenaReturn.UseDis3);
                //"你在竞技场的脱逃行为被人唾弃,你在这次战斗中被判定为失败者,扣除了X点附加战绩惩罚。你的行为背离了竞技场精神!";
                content = TipManager.GetMessage(ArenaReturn.UseDis4);
            }
            int reTime = Convert.ToInt32(TipManager.GetMessage(EmailReturn.HameDay));
            if (EmailAccess.Instance.SendEmail(title, TipManager.GetMessage(ArenaReturn.UseDis5), user.ID, user.Name, content, string.Empty, null, reTime))
            {
                if (user.Online)
                {
                    user.Call(EmailCommand.NewEmailTotalR, EmailAccess.Instance.NewTotal(user.ID));
                }
            }
        }
Example #13
0
 /// <summary>
 /// 通知所有场景用户
 /// </summary>
 /// <param name="model"></param>
 /// <returns></returns>
 public static List<SettleDetail> SettleMessage(ArenaBase model)
 {
     List<SettleDetail> list = new List<SettleDetail>();
     foreach (Settle s in model.SettleInfo.Values)
     {
         SettleDetail sd = new SettleDetail(s);
         list.Add(sd);
     }
     return list;
 }
Example #14
0
 public FightBase(ArenaBase model)
 {
     m_model = model;
 }