/// <summary> /// Run all the matches for the current game date /// </summary> /// <param name="MatchCallback"></param> public void Run(IMatchCallback MatchCallback) { MatchPlayer mp = new MatchPlayer(); WorldAdapter wa = new WorldAdapter(); FixtureAdapter fa = new FixtureAdapter(); TeamAdapter ta = new TeamAdapter(); ManagerAdapter ma = new ManagerAdapter(); foreach (Fixture f in fa.GetFixtures(wa.CurrentDate)) { mp.Fixture = f; mp.Interactive = false; for (int t = 0; t <= 1; t++) { if (ma.GetManager(ta.GetTeam(f.TeamIDs[t]).ManagerID).Human) { mp.Interactive = true; break; } } mp.MatchCallback = MatchCallback; mp.StartMatch(); } MatchCallback.MatchdayComplete(); }
public void SetupGameScreenData(GameScreenSetup dataFromUI) { if (dataFromUI.TeamData == null) { throw new Exception("TeamData is null"); } ManagerAdapter ma = new ManagerAdapter(); WorldAdapter wa = new WorldAdapter(); SetupData = dataFromUI; SetupData.ManagerData = ma.GetManager(SetupData.TeamData.ManagerID); MyTeam = (wa.CurrentManagerID == SetupData.TeamData.ManagerID); if (MyTeam) { SetupData.MainButtons.Add(LangResources.CurLang.Save); SetupData.MainButtons.Add(LangResources.CurLang.UndoChanges); } SetupData.MainButtons.Add(LangResources.CurLang.Back); SetupData.ShowContinueButton = MyTeam; SetupData.Title1 = SetupData.TeamData.Name; SetupData.Title2 = SetupData.ManagerData.Name; ctlFormation.team = SetupData.TeamData; }
public void SetupGameScreenData(GameScreenSetup dataFromUI) { if (dataFromUI.TeamData == null) { throw new Exception("TeamData is null"); } ManagerAdapter ma = new ManagerAdapter(); WorldAdapter wa = new WorldAdapter(); SetupData = dataFromUI; SetupData.ManagerData = ma.GetManager(SetupData.TeamData.ManagerID); MyTeam = (wa.CurrentManagerID == SetupData.TeamData.ManagerID); SetupData.ShowContinueButton = MyTeam; SetupData.MainButtons.Add(LangResources.CurLang.Tactics); SetupData.MainButtons.Add(LangResources.CurLang.Back); SetupData.Title1 = SetupData.TeamData.Name; SetupData.Title2 = SetupData.ManagerData.Name; UpdatePlayers(); }
private ScreenReturnData SetupGame() { ScreenReturnData ValidationResult = ValidateInput(); if (ValidationResult != null) { return(ValidationResult); } Manager you = new Manager(); you.FirstName = txtFirstName.Text; you.LastName = txtSurname.Text; you.Human = true; you.DateOfBirth = new DateTime(Convert.ToInt32(cboDOBYear.Text), cboDOBMonth.SelectedIndex + 1, Convert.ToInt32(cboDOBDay.Text)); you.Reputation = 50; ManagerAdapter ma = new ManagerAdapter(); int ManagerID = ma.AddManager(you); Team T = ta.GetTeam(lstTeams.SelectedID); ma.AssignToTeam(ManagerID, T.UniqueID); return(new ScreenReturnData(ScreenReturnCode.Ok)); }
/// <summary> /// Loop round all AI teams, and select a team appropriate to play the fixture. /// </summary> public void SelectTeamIfPlaying() { FixtureAdapter fa = new FixtureAdapter(); WorldAdapter wa = new WorldAdapter(); TeamAdapter ta = new TeamAdapter(); ManagerAdapter ma = new ManagerAdapter(); List <Fixture> AllFixtures = fa.GetFixtures(wa.CurrentDate); int TESTf = 0; foreach (Fixture f in AllFixtures) { TESTf++; Debug.Print("Fixture " + f.ToString()); for (int t = 0; t <= 1; t++) { Team ThisTeam = ta.GetTeam(f.TeamIDs[t]); Manager M = ma.GetManager(ThisTeam.ManagerID); if (!M.Human) { Team Opposition = ta.GetTeam(f.TeamIDs[1 - t]); PlayerAdapter pa = new PlayerAdapter(); int[,] PlayerGridPositions = new int[5, 8]; // TODO: Maybe not hard code these... for (int x = 0; x <= PlayerGridPositions.GetUpperBound(0); x++) { for (int y = 0; y <= PlayerGridPositions.GetUpperBound(1); y++) { PlayerGridPositions[x, y] = -1; } } Formation TeamFormation = new FormationAdapter().GetFormation(ThisTeam.CurrentFormation); List <AvailablePlayer> avail = GetEligiblePlayers(ThisTeam, f); foreach (Point2 point in TeamFormation.Points) { AvailablePlayer SelPlayer = FindBestPlayerForPosition(point, avail); if (SelPlayer == null) { throw new Exception("Unable to find a player for this position"); } PlayerGridPositions[point.X, point.Y] = SelPlayer.PlayerID; avail.Remove(SelPlayer); } ta.SavePlayerFormation(ThisTeam.UniqueID, TeamFormation.UniqueID, PlayerGridPositions); } } } }
public static void ThirdDemo() { IPerson managerOrEmployeee = null; IPerson employeeOrManager = null; //Based on the need person can be both Manager Or Employee and simply provide a One level of Abstraction managerOrEmployeee = new ManagerAdapter(); employeeOrManager = new EmployeeAdapter(); Console.WriteLine($"{managerOrEmployeee.GetType().Name} have a salary of {managerOrEmployeee.CalculateSalary()} Euro"); Console.WriteLine($"{employeeOrManager.GetType().Name} have a salary of {employeeOrManager.CalculateSalary()} Euro"); }
public void GoodAndBadFixtureFeedback(List <Fixture> fixtures) { ManagerAdapter ma = new ManagerAdapter(); EmailAdapter ea = new EmailAdapter(); foreach (Manager m in ma.GetHumanManagers()) { foreach (Fixture f in fixtures) { for (int team = 0; team <= 1; team++) { if (f.TeamIDs[team] == m.CurrentTeam) // Find manager's team { int opp = 1 - team; // Opposition team if (Math.Abs(f.Score[team] - f.Score[opp]) >= 3) { if (f.Score[team] > f.Score[opp]) { ea.SendEmail(m.UniqueID, EmailType.GoodMatch, new List <int>() { f.Score[0], f.Score[1], f.TeamIDs[opp] }); } if (f.Score[team] < f.Score[opp]) { ea.SendEmail(m.UniqueID, EmailType.BadMatch, new List <int>() { f.Score[0], f.Score[1], f.TeamIDs[opp] }); } } } } } } }
private void NextManagerOrContinueDay() { ManagerAdapter ma = new ManagerAdapter(); FixtureAdapter fa = new FixtureAdapter(); WorldAdapter wa = new WorldAdapter(); TeamAdapter ta = new TeamAdapter(); if (HumanManagers == null) { // Going to first manager, which means we have to run Start Of Day, unless loading from a savegame if (!SaveGameJustLoaded) { RunProcesses(false); } else { SaveGameJustLoaded = false; } HumanManagers = ma.GetHumanManagers(); PlayingHumanManager = 0; wa.CurrentManagerID = HumanManagers[PlayingHumanManager].UniqueID; if (HumanManagers.Count() < 1) { throw new Exception("No human managers"); } } else { // Check selections if a matchday if (fa.IsTodayAMatchDay(HumanManagers[PlayingHumanManager].CurrentTeam)) { const int REQUIREDCOUNT = 11; int PlayerCount = ta.CountSelectedPlayers(HumanManagers[PlayingHumanManager].CurrentTeam); if (PlayerCount < REQUIREDCOUNT) { UiUtils.OpenDialogBox(UiUtils.MainWindowGrid, LangResources.CurLang.MatchDay, string.Format(LangResources.CurLang.YouHaveNotSelectedEnoughPlayers, PlayerCount, REQUIREDCOUNT), new List <DialogButton>() { new DialogButton(LangResources.CurLang.OK, null, null) }); return; } } // Go to next human manager PlayingHumanManager++; if (PlayingHumanManager >= HumanManagers.Count()) { HumanManagers = null; wa.CurrentManagerID = -1; } else { wa.CurrentManagerID = HumanManagers[PlayingHumanManager].UniqueID; } } if (HumanManagers != null) { // Display home screen for the current manager Manager PlayingManager = HumanManagers[PlayingHumanManager]; ShowHomeScreenForCurrentManager(PlayingManager); if (fa.IsTodayAMatchDay(PlayingManager.CurrentTeam)) { Fixture f = fa.GetNextFixture(PlayingManager.CurrentTeam, wa.CurrentDate); int Opposition = (f.TeamIDs[0] != PlayingManager.CurrentTeam ? f.TeamIDs[0] : f.TeamIDs[1]); string Message = string.Format(LangResources.CurLang.YouHaveAMatchAgainst, ta.GetTeam(Opposition).Name); UiUtils.OpenDialogBox(UiUtils.MainWindowGrid, LangResources.CurLang.MatchDay, Message, new List <DialogButton>() { new DialogButton(LangResources.CurLang.OK, null, null) }); } } else { if (fa.IsTodayAMatchDay()) { ShowGameScreen(new MatchdayMain(), true); } else { RunProcesses(true); } } }