public State(Spies spy, Infantry inf, Tanks tank, Jets jet, Bombers bomb, Sams sam, Ships ship) { this.Spy = spy; this.Inf = inf; this.Tank = tank; this.Jet = jet; this.Bomb = bomb; this.Sam = sam; this.Ship = ship; this.UserAttPwr = this.Inf.InfAttPwr + this.Tank.TankAttPwr + this.Jet.JetAttPwr + this.Bomb.BombAttPwr + this.Ship.ShipAttPwr; this.UserGADefPwr = this.Inf.InfAttPwr + this.Tank.TankAttPwr; this.UserARDefPwr = this.Jet.JetAttPwr + this.Sam.SamAttPwr; this.UserAADefPwr = this.Ship.ShipAttPwr; this.UserDefPwr = this.Inf.InfAttPwr + this.Tank.TankAttPwr + this.Sam.SamAttPwr + this.Ship.ShipAttPwr; this.UserGbAttPwr = (this.Spy.SpyUserPwr * this.Spy.SpyCount) + (this.Jet.JetUserPwr * this.Jet.JetCount) + (this.Bomb.BombUserPwr * this.Bomb.BombCount); this.userGbDefPwr = (this.Inf.InfUserPwr * this.Inf.InfCount) + (this.Tank.TankUserPwr * this.Tank.TankCount) + (this.Sam.SamUserPwr * this.Sam.SamCount) + (this.Ship.ShipUserPwr * this.Ship.ShipCount); if (this.UserGbAttPwr > this.userGbDefPwr) { this.GbProtection = "No"; } else { this.GbProtection = "Yes"; } this.Readiness = 0; }
public string CheckEnd() { if (resistanceWin == 3) { Spies = Spies.Remove(Spies.Length - 2, 2); return("R"); } else if (spyWin == 3) { Spies = Spies.Remove(Spies.Length - 2, 2); return("S"); } else { string playersname = ""; foreach (int i in SelectedPlayers) { playersname += playerlist[i].name + " "; } GameResultName[CurrentRound - 1] = playersname; GameResultFail[CurrentRound - 1] = FailCount; LeaderPos++; ResetSuccessFail(); CurrentRound++; return("N"); } }
public async Task <ActionResult <Spies> > PostSpies(Spies item) { _context.Spies.Add(item); await _context.SaveChangesAsync(); return(CreatedAtAction(nameof(Spies), new { id = item.Id }, item)); }
public override CommandResult OnExecute(ICommandSource src, ICommandArgs args) { if (args.Length < 2) { return(CommandResult.ShowUsage()); } var target = args[0].ToPlayer; if (target == null) { return(CommandResult.Lang("PLAYER_NOT_FOUND", args[0])); } var pmSettings = UEssentials.Config.PrivateMessage; var formatFrom = pmSettings.FormatFrom; var formatTo = pmSettings.FormatTo; var formatSpy = pmSettings.FormatSpy; var formatFromColor = ColorUtil.GetColorFromString(ref formatFrom); var formatToColor = ColorUtil.GetColorFromString(ref formatTo); var formatSpyColor = ColorUtil.GetColorFromString(ref formatSpy); var targetName = src.IsConsole ? pmSettings.ConsoleDisplayName : target.DisplayName; var srcName = src.IsConsole ? pmSettings.ConsoleDisplayName : src.DisplayName; formatFrom = string.Format(formatFrom, srcName, args.Join(1)); formatTo = string.Format(formatTo, targetName, args.Join(1)); formatSpy = string.Format(formatSpy, srcName, targetName, args.Join(1)); target.SendMessage(formatFrom, formatFromColor); src.SendMessage(formatTo, formatToColor); Spies.ForEach(p => { UPlayer.From(p).SendMessage(formatSpy, formatSpyColor); }); if (src.IsConsole) { return(CommandResult.Success()); } var srcPlayer = src.ToPlayer(); var srcId = srcPlayer.CSteamId.m_SteamID; if (Conversations.ContainsKey(srcId)) { if (!Conversations[srcId].Equals(target.CSteamId.m_SteamID)) { Conversations[srcId] = target.CSteamId.m_SteamID; } } else { Conversations.Add(srcId, target.CSteamId.m_SteamID); } return(CommandResult.Success()); }
public Army(Leader leader, Scouts scouts, Spies spies, Logistics logistics, IEnumerable <Squad> squadrons) { Leader = leader; Scouts = scouts; Spies = spies; Logistics = logistics; Squadrons = squadrons; }
public bool SetSpy(GameAction pDestSpyPosition) { if (pDestSpyPosition == GameAction.None) { Console.WriteLine("In Spy state only set spy"); return(false); } // Has spy in source if(GetSpyCount()<5) // Has money to dest for (int i = 0; i < Spies.Count(); i++) { if (Spies[i] == GameAction.None) { switch (pDestSpyPosition) { case GameAction.Spy: break; case GameAction.Invent: if (Coins >= 2) { DropCoins(2); } else { Console.WriteLine("Not enought coins to spy"); return(false); } break; case GameAction.Research: break; case GameAction.Work: if (Coins >= 1) { DropCoins(1); } else { Console.WriteLine("Not enought coins to spy"); return(false); } break; } Spies[i] = pDestSpyPosition; CurrentSetSpy = pDestSpyPosition; return(true); } } Console.WriteLine("No spy in source location"); return(false); }
public override CommandResult OnExecute(ICommandSource src, ICommandArgs args) { if (args.Length < 2) { return(CommandResult.ShowUsage()); } var target = args[0].ToPlayer; if (target == null) { return(CommandResult.Lang("PLAYER_NOT_FOUND", args[0])); } var formatFrom = UEssentials.Config.PMFormatFrom; var formatTo = UEssentials.Config.PMFormatTo; var formatFromColor = ColorUtil.GetColorFromString(ref formatFrom); var formatToColor = ColorUtil.GetColorFromString(ref formatTo); var message = string.Format(formatFrom, src.DisplayName, args.Join(1)); var message2 = string.Format(formatTo, target.DisplayName, args.Join(1)); target.SendMessage(message, formatFromColor); src.SendMessage(message2, formatToColor); Spies.ForEach(p => { UPlayer.From(p).SendMessage($"Spy: ({src.DisplayName} -> " + $"{target.CharacterName}): {args.Join(1)}", Color.gray); }); if (src.IsConsole) { return(CommandResult.Success()); } var srcPlayer = src.ToPlayer(); var srcId = srcPlayer.CSteamId.m_SteamID; if (Conversations.ContainsKey(srcId)) { if (!Conversations[srcId].Equals(target.CSteamId.m_SteamID)) { Conversations[srcId] = target.CSteamId.m_SteamID; } } else { Conversations.Add(srcId, target.CSteamId.m_SteamID); } return(CommandResult.Success()); }
public bool DropSpy(GameAction pSourceSpyPosition) { for (int i = 0; i < Spies.Count(); i++) { if (Spies[i] == pSourceSpyPosition) { Spies[i] = GameAction.None; CurrentDropSpy = pSourceSpyPosition; break; } } return(true); }
public override CommandResult OnExecute(ICommandSource src, ICommandArgs args) { if (args.Length < 2) { return(CommandResult.ShowUsage()); } var target = args[0].ToPlayer; if (target == null) { return(CommandResult.Lang(EssLang.PLAYER_NOT_FOUND, args[0])); } var rawMsg1 = UEssentials.Config.PrivateMessageFormat; var rawMsg2 = UEssentials.Config.PrivateMessageFormat2; var color1 = ColorUtil.GetColorFromString(ref rawMsg1); var color2 = ColorUtil.GetColorFromString(ref rawMsg2); var message = string.Format(rawMsg1, src.DisplayName, args.Join(1)); var message2 = string.Format(rawMsg2, target.DisplayName, args.Join(1)); target.SendMessage(message, color1); src.SendMessage(message2, color2); Spies.ForEach(p => { UPlayer.From(p).SendMessage($"Spy: ({src.DisplayName} -> " + $"{target.CharacterName}): {args.Join( 1 )}", Color.gray); }); if (Conversations.ContainsKey(src.DisplayName)) { if (!Conversations[src.DisplayName].Equals(target.DisplayName)) { Conversations[src.DisplayName] = target.CharacterName; } } else { Conversations.Add(src.DisplayName, target.DisplayName); } return(CommandResult.Success()); }
public override CommandResult OnExecute(ICommandSource src, ICommandArgs args) { var target = args[0].ToPlayer; if (target == null) { return(CommandResult.LangError("PLAYER_NOT_FOUND", args[0])); } var pmSettings = UEssentials.Config.PrivateMessage; var formatFrom = pmSettings.FormatFrom; var formatTo = pmSettings.FormatTo; var formatSpy = pmSettings.FormatSpy; var formatFromColor = ColorUtil.GetColorFromString(ref formatFrom); var formatToColor = ColorUtil.GetColorFromString(ref formatTo); var formatSpyColor = ColorUtil.GetColorFromString(ref formatSpy); var targetName = target.DisplayName; var srcName = src.IsConsole ? pmSettings.ConsoleDisplayName : src.DisplayName; formatFrom = string.Format(formatFrom, srcName, args.Join(1)); formatTo = string.Format(formatTo, targetName, args.Join(1)); formatSpy = string.Format(formatSpy, srcName, targetName, args.Join(1)); target.SendMessage(formatFrom, formatFromColor); src.SendMessage(formatTo, formatToColor); Spies.ForEach(p => { UPlayer.From(p).SendMessage(formatSpy, formatSpyColor); }); if (!src.IsConsole) { ReplyTo[target.CSteamId.m_SteamID] = src.ToPlayer().CSteamId.m_SteamID; } return(CommandResult.Success()); }
public int StageTwo(Callback StatusUpdate, Callback StatusUpdate_phone, int VoteNoCount) { if (VoteNoCount >= (int)Math.Ceiling((double)No_of_players / 2)) { CountFailMission++; if (CountFailMission == 5) { StatusUpdate("Mission failed consecutively for 5 times. Spy wins!");//SPY WIN StatusUpdate_phone("Mission failed consecutively for 5 times. Spy wins!"); Spies = Spies.Remove(Spies.Length - 2, 2); return(-1); } LeaderPos++; SetMissionLeader(); return(0); } else { StatusUpdate("---Turn in Success of Fail---"); StatusUpdate_phone("---Turn in Success of Fail---"); return(3); } }
public void FillWarEnemyInformation(object sender, Boolean recalculate = false) { if (defWarArmyInfo.Text.Length > 0) { string str = defWarArmyInfo.Text; Regex espRgx = new Regex("Espionage"); Match match; match = espRgx.Match(str); if (match.Success) { try { double readiness = 0; if (!recalculate) { string segment; Regex rgx = new Regex("[0-9]+\\.*[0-9]*\\.*[0-9]*"); int startChar; int endChar; // Find State Name and Cut String string stateStr = "State: "; startChar = str.IndexOf(stateStr); string readyStr = "Readiness"; endChar = str.IndexOf(readyStr); lblWarStateName.Text = str.Substring(startChar + stateStr.Length, endChar - startChar - stateStr.Length).Trim(); segment = str.Substring(endChar + readyStr.Length, str.Length - (endChar + readyStr.Length)); match = rgx.Match(segment); #region Get Readiness if (match.Success) { startChar = segment.IndexOf(match.Value); if (tbWarEnemyReadiness.Text.Length > 0) { readiness = Convert.ToDouble(tbWarEnemyReadiness.Text.Replace("%", "").Trim()) / 100; if (readiness == 0) { tbWarEnemyReadiness.Text = "0%"; } else { tbWarEnemyReadiness.Text = readiness.ToString("###%"); } } else { readiness = Convert.ToDouble(match.Value.Replace(".", ",").Trim()) / 100; tbWarEnemyReadiness.Text = readiness.ToString("###%"); } segment = segment.Substring(startChar + match.Value.Length); match = rgx.Match(segment); } #endregion //Get to the troop info startChar = str.IndexOf("Spies"); segment = str.Substring(startChar, (str.Length - startChar)); match = rgx.Match(segment); #region Gather Enemy Spies Info if (match.Success) { startChar = segment.IndexOf(match.Value); tbWarDefSpyCount.Text = match.Value.Replace(".", ",").Trim(); segment = segment.Substring(startChar + match.Value.Length); match = rgx.Match(segment); } if (match.Success) { startChar = segment.IndexOf(match.Value); tbWarDefNaSpyCount.Text = match.Value.Replace(".", ",").Trim(); segment = segment.Substring(startChar + match.Value.Length); match = rgx.Match(segment); } if (match.Success) { startChar = segment.IndexOf(match.Value); lblWarDefSpyLvl.Text = match.Value.Replace(".", ",").Trim(); segment = segment.Substring(startChar + match.Value.Length); match = rgx.Match(segment); } #endregion #region Gather Enemy Infantry Info if (match.Success) { startChar = segment.IndexOf(match.Value); tbWarDefInfCount.Text = match.Value.Replace(".", ",").Trim(); segment = segment.Substring(startChar + match.Value.Length); match = rgx.Match(segment); } if (match.Success) { startChar = segment.IndexOf(match.Value); tbWarDefNaInfCount.Text = match.Value.Replace(".", ",").Trim(); segment = segment.Substring(startChar + match.Value.Length); match = rgx.Match(segment); } if (match.Success) { startChar = segment.IndexOf(match.Value); lblWarDefInfLvl.Text = match.Value.Replace(".", ",").Trim(); segment = segment.Substring(startChar + match.Value.Length); match = rgx.Match(segment); } #endregion #region Gather Enemy Tanks Info if (match.Success) { startChar = segment.IndexOf(match.Value); tbWarDefTankCount.Text = match.Value.Replace(".", ",").Trim(); segment = segment.Substring(startChar + match.Value.Length); match = rgx.Match(segment); } if (match.Success) { startChar = segment.IndexOf(match.Value); tbWarDefNaTankCount.Text = match.Value.Replace(".", ",").Trim(); segment = segment.Substring(startChar + match.Value.Length); match = rgx.Match(segment); } if (match.Success) { startChar = segment.IndexOf(match.Value); lblWarDefTankLvl.Text = match.Value.Replace(".", ",").Trim(); segment = segment.Substring(startChar + match.Value.Length); match = rgx.Match(segment); } #endregion #region Gather Enemy Jets Info if (match.Success) { startChar = segment.IndexOf(match.Value); tbWarDefJetCount.Text = match.Value.Replace(".", ",").Trim(); segment = segment.Substring(startChar + match.Value.Length); match = rgx.Match(segment); } if (match.Success) { startChar = segment.IndexOf(match.Value); tbWarDefNaJetCount.Text = match.Value.Replace(".", ",").Trim(); segment = segment.Substring(startChar + match.Value.Length); match = rgx.Match(segment); } if (match.Success) { startChar = segment.IndexOf(match.Value); lblWarDefJetLvl.Text = match.Value.Replace(".", ",").Trim(); segment = segment.Substring(startChar + match.Value.Length); match = rgx.Match(segment); } #endregion #region Gather Enemy Bombers Info if (match.Success) { startChar = segment.IndexOf(match.Value); tbWarDefBombCount.Text = match.Value.Replace(".", ",").Trim(); segment = segment.Substring(startChar + match.Value.Length); match = rgx.Match(segment); } if (match.Success) { startChar = segment.IndexOf(match.Value); tbWarDefNaBombCount.Text = match.Value.Replace(".", ",").Trim(); segment = segment.Substring(startChar + match.Value.Length); match = rgx.Match(segment); } if (match.Success) { startChar = segment.IndexOf(match.Value); lblWarDefBombLvl.Text = match.Value.Replace(".", ",").Trim(); segment = segment.Substring(startChar + match.Value.Length); match = rgx.Match(segment); } #endregion #region Gather Enemy SAMS Info if (match.Success) { startChar = segment.IndexOf(match.Value); tbWarDefSamCount.Text = match.Value.Replace(".", ",").Trim(); segment = segment.Substring(startChar + match.Value.Length); match = rgx.Match(segment); } if (match.Success) { startChar = segment.IndexOf(match.Value); tbWarDefNaSamCount.Text = match.Value.Replace(".", ",").Trim(); segment = segment.Substring(startChar + match.Value.Length); match = rgx.Match(segment); } if (match.Success) { startChar = segment.IndexOf(match.Value); lblWarDefSamLvl.Text = match.Value.Replace(".", ",").Trim(); segment = segment.Substring(startChar + match.Value.Length); match = rgx.Match(segment); } #endregion #region Gather Enemy Ships Info if (match.Success) { startChar = segment.IndexOf(match.Value); tbWarDefShipCount.Text = match.Value.Replace(".", ",").Trim(); segment = segment.Substring(startChar + match.Value.Length); match = rgx.Match(segment); } if (match.Success) { startChar = segment.IndexOf(match.Value); tbWarDefNaShipCount.Text = match.Value.Replace(".", ",").Trim(); segment = segment.Substring(startChar + match.Value.Length); match = rgx.Match(segment); } if (match.Success) { startChar = segment.IndexOf(match.Value); lblWarDefShipLvl.Text = match.Value.Replace(".", ",").Trim(); segment = segment.Substring(startChar + match.Value.Length); match = rgx.Match(segment); } #endregion } else { tbWarDefSpyCount.Text = Convert.ToInt32(tbWarDefSpyCount.Text.Replace(",", "").Insert(0, "0")).ToString("#,##0"); tbWarDefNaSpyCount.Text = Convert.ToInt32(tbWarDefNaSpyCount.Text.Replace(",", "").Insert(0, "0")).ToString("#,##0"); tbWarDefInfCount.Text = Convert.ToInt32(tbWarDefInfCount.Text.Replace(",", "").Insert(0, "0")).ToString("#,##0"); tbWarDefNaInfCount.Text = Convert.ToInt32(tbWarDefNaInfCount.Text.Replace(",", "").Insert(0, "0")).ToString("#,##0"); tbWarDefTankCount.Text = Convert.ToInt32(tbWarDefTankCount.Text.Replace(",", "").Insert(0, "0")).ToString("#0"); tbWarDefNaTankCount.Text = Convert.ToInt32(tbWarDefNaTankCount.Text.Replace(",", "").Insert(0, "0")).ToString("#,##0"); tbWarDefJetCount.Text = Convert.ToInt32(tbWarDefJetCount.Text.Replace(",", "").Insert(0, "0")).ToString("#,##0"); tbWarDefNaJetCount.Text = Convert.ToInt32(tbWarDefNaJetCount.Text.Replace(",", "").Insert(0, "0")).ToString("#,##0"); tbWarDefBombCount.Text = Convert.ToInt32(tbWarDefBombCount.Text.Replace(",", "").Insert(0, "0")).ToString("#,##0"); tbWarDefNaBombCount.Text = Convert.ToInt32(tbWarDefNaBombCount.Text.Replace(",", "").Insert(0, "0")).ToString("#,##0"); tbWarDefSamCount.Text = Convert.ToInt32(tbWarDefSamCount.Text.Replace(",", "").Insert(0, "0")).ToString("#,##0"); tbWarDefNaSamCount.Text = Convert.ToInt32(tbWarDefNaSamCount.Text.Replace(",", "").Insert(0, "0")).ToString("#,##0"); tbWarDefShipCount.Text = Convert.ToInt32(tbWarDefShipCount.Text.Replace(",", "").Insert(0, "0")).ToString("#,##0"); tbWarDefNaShipCount.Text = Convert.ToInt32(tbWarDefNaShipCount.Text.Replace(",", "").Insert(0, "0")).ToString("#,##0"); readiness = Convert.ToDouble(tbWarEnemyReadiness.Text.Replace("%", "").Trim()) / 100; tbWarEnemyReadiness.Text = readiness.ToString("###%"); } #region Create Enemy State Spies spy = new Spies(Convert.ToInt32(tbWarDefSpyCount.Text.ToString().Replace(",", "")), Convert.ToInt32(lblWarDefSpyLvl.Text.ToString().Replace(",", "")), Convert.ToInt32(tbWarDefNaSpyCount.Text.ToString().Replace(",", ""))); Infantry inf = new Infantry(Convert.ToInt32(tbWarDefInfCount.Text.ToString().Replace(",", "")), Convert.ToInt32(lblWarDefInfLvl.Text.ToString().Replace(",", "")), Convert.ToInt32(tbWarDefNaInfCount.Text.ToString().Replace(",", ""))); Tanks tank = new Tanks(Convert.ToInt32(tbWarDefTankCount.Text.ToString().Replace(",", "")), Convert.ToInt32(lblWarDefTankLvl.Text.ToString().Replace(",", "")), Convert.ToInt32(tbWarDefNaTankCount.Text.ToString().Replace(",", ""))); Jets jet = new Jets(Convert.ToInt32(tbWarDefJetCount.Text.ToString().Replace(",", "")), Convert.ToInt32(lblWarDefJetLvl.Text.ToString().Replace(",", "")), Convert.ToInt32(tbWarDefNaJetCount.Text.ToString().Replace(",", ""))); Bombers bomb = new Bombers(Convert.ToInt32(tbWarDefBombCount.Text.ToString().Replace(",", "")), Convert.ToInt32(lblWarDefBombLvl.Text.ToString().Replace(",", "")), Convert.ToInt32(tbWarDefNaBombCount.Text.ToString().Replace(",", ""))); Sams sam = new Sams(Convert.ToInt32(tbWarDefSamCount.Text.ToString().Replace(",", "")), Convert.ToInt32(lblWarDefSamLvl.Text.ToString().Replace(",", "")), Convert.ToInt32(tbWarDefNaSamCount.Text.ToString().Replace(",", ""))); Ships ship = new Ships(Convert.ToInt32(tbWarDefShipCount.Text.ToString().Replace(",", "")), Convert.ToInt32(lblWarDefShipLvl.Text.ToString().Replace(",", "")), Convert.ToInt32(tbWarDefNaShipCount.Text.ToString().Replace(",", ""))); State enemyState = new State(spy, inf, tank, jet, bomb, sam, ship); enemyState.Readiness = readiness; enemyState.UserDefPwr *= enemyState.Readiness; enemyState.UserGADefPwr *= enemyState.Readiness; enemyState.UserARDefPwr *= enemyState.Readiness; enemyState.UserAADefPwr *= enemyState.Readiness; if (enemyState.UserGADefPwr == 0) { lblWarGADefPwr.Text = "0"; } else { lblWarGADefPwr.Text = enemyState.UserGADefPwr.ToString("###,###,###,###"); } if (enemyState.UserARDefPwr == 0) { lblWarARDefPwr.Text = "0"; } else { lblWarARDefPwr.Text = enemyState.UserARDefPwr.ToString("###,###,###,###"); } if (enemyState.UserAADefPwr == 0) { lblWarAADefPwr.Text = "0"; } else { lblWarAADefPwr.Text = enemyState.UserAADefPwr.ToString("###,###,###,###"); } #endregion if (defWarArmyInfo.Text.Length > 0) { calcWarBreaks(); } } catch { //clearWarEnemyInfo(); } } else { //clearWarEnemyInfo(); } } }
public int GetSpyCount() { return(Spies.Where(s => s != 0).Count()); }