public static Team CreateTeam(string teamName, bool isPlayable) { var team = new Team(teamName, isPlayable); for (var i = 0; i < GameConfig.TeamSize; i++) { var freeNames = SoldierConfig.Names.Where(w => !_usedNames.Contains(w)).ToArray(); var name = freeNames[RNG.GetNumber(freeNames.Length)]; _usedNames.Add(name); var unit = new Unit(name) { Stats = new UnitStats { TU = RNG.GetNumber(SoldierConfig.TimeUnitsRange), MaxHP = RNG.GetNumber(SoldierConfig.HitPointsRange), Accuracy = RNG.GetNumber(SoldierConfig.AccuracyRange), Strength = RNG.GetNumber(SoldierConfig.StrengthRange) }, View = ViewLogic.Initialize(GameConfig.DefaultViewWidth, GameConfig.DefaultViewDistance, RNG.GetNumber(8)), Inventory = new Inventory(ItemConfig.DefaultInventories[i].Select(w => new Item(w))) }; unit.Stats.CurrentHP = unit.Stats.MaxHP; unit.Inventory.ActiveItem = unit.Inventory.FirstOrDefault(); team.Add(unit); } return team; }
private static void AddTeam(string name, string nickname, DateTime dateOfFounding) { if (CheckIfTeamExists(name)) { throw new InvalidOperationException(name + " are already in the league"); } Team team = new Team(name, nickname, dateOfFounding); League.AddTeam(team); Console.WriteLine("{0} ({1}) were added to the league", team.Name, team.Nickname); }
public static void LocateTeamInStation(Team team, SpaceStation station, int levelId) { var level = station.Levels[levelId]; var corner = (Corner)RNG.GetNumber(0, 3, (int)level.StairsDownLocation); var coordX = corner == Corner.TopLeft || corner == Corner.BottomLeft ? 3 : MapConfig.LevelSize.Width - 6; var coordY = corner == Corner.TopLeft || corner == Corner.TopRight ? 3 : MapConfig.LevelSize.Height - 6; for (var i = 0; i < 2; i++) for (var j = 0; j < 2; j++) { var unit = team.Units[i*2 + j]; unit.Position = new Position(levelId, coordX + j*2, coordY + i*2); unit.View.Direction = corner == Corner.TopLeft ? 4 : corner == Corner.TopRight ? 6 : corner == Corner.BottomLeft ? 2 : 0; level.Map[coordY + i*2, coordX + j*2] = new Tile("Empty"); } }
public static StatsAggregateViewModel.BiggestRatingWinModel GetBiggestRatingWin() { var matches = Dbh.GetCollection<Match>("Matches").FindAll(); var biggestRatingWin = new StatsAggregateViewModel.BiggestRatingWinModel(); foreach (var match in matches) { // Determine the winners and the losers var winners = new Team(); var losers = new Team(); if (match.RedScore > match.BlueScore) { winners.Players.Add(match.RedPlayer1); winners.Players.Add(match.RedPlayer2); losers.Players.Add(match.BluePlayer1); losers.Players.Add(match.BluePlayer2); } else { winners.Players.Add(match.BluePlayer1); winners.Players.Add(match.BluePlayer2); losers.Players.Add(match.RedPlayer1); losers.Players.Add(match.RedPlayer2); } // Get the rating modifier var ratingModifier = Rating.GetRatingModifier(winners.GetTeamRating(), losers.GetTeamRating()); if (ratingModifier > biggestRatingWin.Rating) { biggestRatingWin.Rating = ratingModifier; biggestRatingWin.WinningTeam = winners; biggestRatingWin.LosingTeam = losers; } } return biggestRatingWin; }