Ejemplo n.º 1
0
        public override bool TakeAction()
        {
            if (string.IsNullOrEmpty(ContextUser.MercenariesID))
            {
                ErrorCode = LanguageManager.GetLang().ErrorCode;
                return false;
            }
            FightCombat fightCombat = new FightCombat();
            var cacheSet = new ShareCacheStruct<ServerFight>();
            ServerFight fight = cacheSet.FindKey(fightCombat.FastID, ContextUser.MercenariesID);
            if (fight != null)
            {
                if (GuildFightCombat.IsFightDate())
                {
                    ErrorCode = LanguageManager.GetLang().ErrorCode;
                    ErrorInfo = LanguageManager.GetLang().St6412_FightWarDate;
                    return false;
                }

                var fightUser = GuildFightCombat._fightUserList.Find(m => !m.IsRemove && m.UserId == ContextUser.UserID);
                if (fightUser == null)
                {
                    fightUser = new FightUser();
                    fightUser.GuildID = fight.GuildID;
                    fightUser.UserId = ContextUser.UserID;
                    fightUser.UserName = ContextUser.NickName;
                    fightUser.WinCount = 0;
                    fightUser.CityID = fight.CityID;
                    fightUser.ObtainNum = 0;
                    fightUser.InspirePercent = 0;
                    fightUser.IsRemove = false;
                    fightUser.IsNotEnough = false;
                    GuildFightCombat._fightUserList.Add(fightUser);
                }
                if (!string.IsNullOrEmpty(fight.CombatMember) && !GuildFightCombat.IsFightWar(ContextUser.UserID, fight.CombatMember))
                {
                    fight.CombatMember = fight.CombatMember + ContextUser.UserID + ",";
                }
                else
                {
                    fight.CombatMember = ContextUser.UserID + ",";
                }
                ContextUser.UserStatus = UserStatus.FightCombat;
                ErrorCode = 0;
                ErrorInfo = LanguageManager.GetLang().St6412_FightWarSuccess;
            }
            else
            {
                ErrorCode = LanguageManager.GetLang().ErrorCode;
                ErrorInfo = LanguageManager.GetLang().St6412_HaveSignedUp;
                return false;
            }
            return true;
        }
Ejemplo n.º 2
0
 public static void GuildFightCombatUserList()
 {
     _fightUserList = new CacheList<FightUser>();
     var fightList = new ShareCacheStruct<ServerFight>().FindAll(m => m.FastID == info.FastID);
     foreach (ServerFight fight in fightList)
     {
         if (string.IsNullOrEmpty(fight.CombatMember))
         {
             continue;
         }
         string[] strList = fight.CombatMember.Split(',');
         foreach (string s in strList)
         {
             if (string.IsNullOrEmpty(s))
             {
                 continue;
             }
             var FightStatusUser = _fightUserList.Find(m => !m.IsRemove && m.UserId == s);
             if (FightStatusUser != null)
             {
                 continue;
             }
             FightUser fightUser = new FightUser();
             fightUser.GuildID = fight.GuildID;
             fightUser.UserId = s;
             GameUser user = UserCacheGlobal.CheckLoadUser(s);
             if (user != null)
             {
                 fightUser.UserName = user.NickName;
                 user.UserStatus = UserStatus.FightCombat;
             }
             fightUser.WinCount = 0;
             fightUser.CityID = fight.CityID;
             fightUser.ObtainNum = 0;
             fightUser.InspirePercent = 0;
             fightUser.IsRemove = false;
             fightUser.IsNotEnough = false;
             _fightUserList.Add(fightUser);
         }
     }
 }
Ejemplo n.º 3
0
 /// <summary>
 /// 玩家成员分组表
 /// </summary>
 /// <param name="cuser1"></param>
 /// <param name="cuser2"></param>
 /// <param name="isWin"></param>
 /// <param name="process"></param>
 public static void MemberGroupProcess(FightUser cuser1, FightUser cuser2, bool isWin, FightCombatProcess process)
 {
     GameUser user1 = new GameDataCacheSet<GameUser>().FindKey(cuser1.UserId);
     GameUser user2 = new GameDataCacheSet<GameUser>().FindKey(cuser2.UserId);
     if (user1 == null || user2 == null)
     {
         return;
     }
     var cacheSet = new ShareCacheStruct<MemberGroup>();
     MemberGroup memberGroup = new MemberGroup(Guid.NewGuid().ToString())
                                   {
                                       FastID = info.FastID,
                                       GuildIDA = cuser1.GuildID,
                                       GuildIDB = cuser2.GuildID,
                                       UserIDA = cuser1.UserId,
                                       UserIDB = cuser2.UserId,
                                       Win = isWin,
                                       CombatProcess = process,
                                       IsRemove = false,
                                   };
     cacheSet.Add(memberGroup, GameEnvironment.CacheGlobalPeriod);
 }
Ejemplo n.º 4
0
 public static void FightUserListCombat(FightUser cuser1, FightUser cuser2, bool orderly)
 {
     GameUser user1 = new GameDataCacheSet<GameUser>().FindKey(cuser1.UserId);
     GameUser user2 = new GameDataCacheSet<GameUser>().FindKey(cuser2.UserId);
     if (user1 == null || user2 == null)
     {
         return;
     }
     var serverfightgroup = new ShareCacheStruct<ServerFightGroup>().FindAll(m => m.FastID == info.FastID && m.GuildIDA == user1.MercenariesID && m.GuildIDB == user2.MercenariesID);
     if (serverfightgroup.Count > 0)
     {
         var fightInfo = new ConfigCacheSet<GuildFightInfo>().FindKey(cuser1.CityID);
         if (fightInfo != null)
         {
             if (orderly)
             {
                 cuser1.ObtainNum = MathUtils.Addition(cuser1.ObtainNum, (user1.UserLv * fightInfo.Victory).ToInt());
                 cuser2.ObtainNum = MathUtils.Addition(cuser2.ObtainNum, (user2.UserLv * fightInfo.Failure).ToInt());
                 cuser2.IsRemove = true;
                 user1.Fatigue = MathUtils.Addition(user1.Fatigue, 1, 5);
                 cuser1.WinCount = MathUtils.Addition(cuser1.WinCount, 1);
                 serverfightgroup[0].Awin = MathUtils.Addition(serverfightgroup[0].Awin, 1);
             }
             else
             {
                 cuser2.ObtainNum = MathUtils.Addition(cuser2.ObtainNum, (user2.UserLv * fightInfo.Victory).ToInt());
                 cuser1.ObtainNum = MathUtils.Addition(cuser1.ObtainNum, (user1.UserLv * fightInfo.Failure).ToInt());
                 cuser2.WinCount = MathUtils.Addition(cuser2.WinCount, 1);
                 cuser1.IsRemove = true;
                 user2.Fatigue = MathUtils.Addition(user2.Fatigue, 1, 5);
                 serverfightgroup[0].Bwin = MathUtils.Addition(serverfightgroup[0].Bwin, 1);
             }
         }
     }
     else
     {
         if (!orderly)
         {
             FightUserListCombat(cuser2, cuser1, true);
         }
         else
         {
             FightUserListCombat(cuser2, cuser1, false);
         }
     }
 }
Ejemplo n.º 5
0
        private static void AsyncDoCombat(FightUser cuser1, FightUser cuser2, FightCombatProcess process)
        {
            GameUser user1 = UserCacheGlobal.LoadOffline(cuser1.UserId); //new GameDataCacheSet<GameUser>().FindKey();
            GameUser user2 = UserCacheGlobal.LoadOffline(cuser2.UserId); // new GameDataCacheSet<GameUser>().FindKey(cuser2.UserId);
            if (user1 == null || user2 == null)
            {
                return;
            }
            decimal victory = 0;
            decimal failure = 0;
            var fightInfo = new ConfigCacheSet<GuildFightInfo>().FindKey(cuser1.CityID);
            if (fightInfo != null)
            {
                victory = fightInfo.Victory;
                failure = fightInfo.Failure;
            }
            ISingleCombat combater = CombatFactory.TriggerTournament(user1, user2);
            bool isWin = combater.Doing();
            if (isWin)
            {
                FightUserListCombat(cuser1, cuser2, true);
                process.WinUserId = user1.UserID;
                process.WinUserName = user1.NickName;
                process.FailUserId = user2.UserID;
                process.FailUserName = user2.NickName;
                process.WinObtainNum = (user1.UserLv * victory).ToInt();
                user1.ObtainNum = MathUtils.Addition(user1.ObtainNum, process.WinObtainNum);
                process.FailObtainNum = (user2.UserLv * failure).ToInt();
                user2.ObtainNum = MathUtils.Addition(user2.ObtainNum, process.FailObtainNum);
                user2.UserStatus = UserStatus.Normal;
            }
            else
            {
                FightUserListCombat(cuser2, cuser1, true);
                process.WinUserId = user2.UserID;
                process.WinUserName = user2.NickName;
                process.FailUserId = user1.UserID;
                process.FailUserName = user1.NickName;

                process.WinObtainNum = (user2.UserLv * victory).ToInt();
                user2.ObtainNum = MathUtils.Addition(user2.ObtainNum, process.WinObtainNum);
                process.FailObtainNum = (user1.UserLv * failure).ToInt();
                user1.ObtainNum = MathUtils.Addition(user1.ObtainNum, process.FailObtainNum);

                user1.UserStatus = UserStatus.Normal;
            }

            process.ProcessContainer = (CombatProcessContainer)combater.GetProcessResult();

            MemberGroupProcess(cuser1, cuser2, isWin, process);

            if (_combatProcessList != null) _combatProcessList.Add(process);
            //日志
            UserCombatLog log = new UserCombatLog();
            log.CombatLogID = Guid.NewGuid().ToString();
            log.UserID = cuser1.UserId;
            log.CityID = 0;
            log.PlotID = 0;
            log.NpcID = 0;
            log.CombatType = CombatType.Country;
            log.HostileUser = cuser2.UserId;
            log.IsWin = isWin;
            log.CombatProcess = JsonUtils.Serialize(process);
            log.CreateDate = DateTime.Now;
            var sender = DataSyncManager.GetDataSender();
            sender.Send(log);
        }