/// <summary> /// 参战 /// </summary> public bool JoinCombat() { AssignGoup(); bool result = true; CountryLvGroup lvGroup; if (TryLvGroup(out lvGroup) && lvGroup.UserList.ContainsKey(_countryUser.UserId)) { CountryUser cuser = lvGroup.UserList[_countryUser.UserId]; if (cuser != null && cuser.Status == 0) { cuser.Status = 1; cuser.Refresh = DateTime.Now; //lvGroup.Update(cuser); lvGroup.CombaQueue.Add(cuser); CombatHelper.EmbattlePostion(cuser.UserId); } else { result = false; } } return(result); }
private static void SendMessage(CountryLvGroup lvGroup) { List <KeyValuePair <string, CountryUser> > cuserList = lvGroup.UserList.ToList(); var chatService = new TjxChatService(); foreach (KeyValuePair <string, CountryUser> keyPair in cuserList) { CountryUser cuser = keyPair.Value; GameUser gameUser = new PersonalCacheStruct <GameUser>().FindKey(cuser.UserId); if (gameUser != null) { gameUser.UserStatus = UserStatus.Normal; gameUser.GroupType = CountryType.None; //领土战礼包 UserItemHelper.AddUserItem(gameUser.UserID, 5013, 1); CombatHelper.EmbattlePostion(gameUser.UserID); } string content = string.Format(LanguageManager.GetLang().St5204_CombatTransfusion, cuser.WinCount, cuser.FailCount, cuser.GameCoin, cuser.ObtainNum); chatService.SystemSendWhisper(cuser.UserId, cuser.UserName, cuser.UserVipLv, content); } }
//领土战赢杀人不留痕,败纸鸢线断,连胜1奖声10,金币7000,最高连胜杀人不留痕:1,失败方奖声1,金币500 private static void ProcessPrize(CountryUser wincuser, CountryUser failcuser, CountryCombatProcess process) { string logStr = string.Format("领土战赢{0}[连{2}],败{1}[连{3}]", wincuser.UserName, failcuser.UserName, wincuser.CurrWinNum, failcuser.CurrWinNum); //胜方自动加入下次战斗 int obtainNum = 0; int gameCoin = 0; wincuser.WinCount = wincuser.WinCount + 1; wincuser.CurrWinNum = wincuser.CurrWinNum + 1; //连胜奖励:声望=M*(X+1),金币=N+X*2000 obtainNum = ObtainNum * wincuser.CurrWinNum; gameCoin = PrizeGameCoin + (wincuser.CurrWinNum - 1) * 2000; logStr += string.Format(",连胜{2}奖声{0},金币{1}", obtainNum, gameCoin, wincuser.CurrWinNum); if (failcuser.CurrWinNum > 0) { //击杀连胜额外:声望=M*X,金币=N+X*1000 obtainNum += ObtainNum * failcuser.CurrWinNum; gameCoin += PrizeGameCoin + failcuser.CurrWinNum * 1000; logStr += string.Format(",击杀连胜后声{0},金币{1}", obtainNum, gameCoin); //Contribution(wincuser.UserId, obtainNum); //公会贡献 } if (FistCountryUser != null && wincuser.UserId.Equals(FistCountryUser.UserId)) { //最高连胜额外:N+X(最高连胜次数)*2000 gameCoin += PrizeGameCoin + (wincuser.CurrWinNum - 1) * 2000; logStr += string.Format(",最高连胜后金币{0}", gameCoin); } if (wincuser.CurrWinNum > wincuser.MaxWinNum) { wincuser.MaxWinNum = wincuser.CurrWinNum; } //最高连胜 if (FistCountryUser != null && wincuser.CurrWinNum > FistCountryUser.CurrWinNum) { lock (thisLock) { FistCountryUser = new CountryUser(); FistCountryUser.CurrWinNum = wincuser.CurrWinNum; FistCountryUser.MaxWinNum = wincuser.MaxWinNum; FistCountryUser.WinCount = wincuser.WinCount; FistCountryUser.UserId = wincuser.UserId; FistCountryUser.UserName = wincuser.UserName; FistCountryUser.UserVipLv = wincuser.UserVipLv; } logStr += string.Format(",最高连胜{0}:{1}", FistCountryUser.UserName, FistCountryUser.CurrWinNum); //Trace.WriteLine(string.Format("领土战最高连胜{0}:{1}", FistCountryUser.UserName, FistCountryUser.CurrWinNum)); } SetUserPrize(wincuser, obtainNum, gameCoin); wincuser.Status = 1; process.WinUserId = wincuser.UserId; process.WinUserName = wincuser.UserName; process.KillNum = wincuser.CurrWinNum; process.WinObtainNum = obtainNum; process.WinGameCoin = gameCoin; process.FaildKillNum = failcuser.CurrWinNum;//打败几连杀 //获胜方公会贡献 Contribution(wincuser.UserId, obtainNum); obtainNum = (int)Math.Floor((double)ObtainNum / 5); gameCoin = (int)Math.Floor((double)PrizeGameCoin / 10); logStr += string.Format(",失败方[{2}连杀]奖声{0},金币{1}", obtainNum, gameCoin, process.FaildKillNum); failcuser.Status = 0; failcuser.CurrWinNum = 0; failcuser.FailCount = failcuser.FailCount + 1; SetUserPrize(failcuser, obtainNum, gameCoin); process.FailUserId = failcuser.UserId; process.FailUserName = failcuser.UserName; process.FailObtainNum = obtainNum; process.FailGameCoin = gameCoin; //战败方公会贡献 Contribution(failcuser.UserId, obtainNum); _log.SaveDebugLog(logStr); CombatHelper.EmbattlePostion(failcuser.UserId); }