public void CreateTournament() { TournamentModel tournament = new TournamentModel (TournamentName, IsLeague, HomeAndAway, VictoryPoints, DrawPoints, OfficialScore, EntryFee); SqlDataHandler.CreateTournament(tournament); foreach (TeamModel team in TournamentTeams) { tournament.ParticipatingTeams.Add(team); } RoundLogic.CreateDummyTeams(tournament); if (tournament.IsLeague) { foreach (TeamModel team in tournament.ParticipatingTeams) { SqlDataHandler.CreateLeagueParticipant(tournament, team); } } foreach (PrizeModel prize in TournamentPrizes) { tournament.TournamentPrizes.Add(prize); SqlDataHandler.CreatePrize(tournament, prize); } RoundLogic.CreateRounds(tournament); var conductor = Parent as IConductor; conductor.ActivateItem(new HomeViewModel()); // TODO - activate tournamentView instead of homeView }
public void GetSecondPlayerWhenPlayer1IsInTurnTest() { RoundLogic atTest = new RoundLogic(2); int expected = 2; int actual = atTest.secondPlayer(); Assert.AreEqual(expected, actual); }
public void GetSecondBoardAtPlayTest() { RoundLogic atTest = new RoundLogic(2); Board b1 = new Board(); Board expected = new Board(); Board actual = atTest.currentBoardAtPlay(ref b1, ref expected); Assert.AreEqual(expected, actual); }
public void RoundLogicChangeFromPlayer1to2TurnTest() { RoundLogic atTest = new RoundLogic(2); int expected = 2; atTest.changePlayerTurn(true); int actual = atTest.playerAtTurn; Assert.AreEqual(expected, actual); }
public RoundLogicState(RoundLogic logic) { Time = logic.Time; Kills = logic.Kills; ScoreLost = logic.ScoreLost; ScoreGained = logic.ScoreGained; RoundStarted = logic.RoundStarted; CanMiasma = logic.CanMiasma; Players = logic.Players; Restarted = RoundLogic.Restarted; }
public void GetPlayerCurrentlyInTurnShouldBe1Test() { RoundLogic atTest = new RoundLogic(2); int expected = 1; atTest.changePlayerTurn(true); atTest.changePlayerTurn(true); int actual = atTest.playerAtTurn; Assert.AreEqual(expected, actual); }
public new static RoundLogic GetRoundLogic(Session session) { switch (session.MatchSettings.Mode) { case RespawnRoundLogic.Mode: return(new RespawnRoundLogic(session)); case MobRoundLogic.Mode: return(new MobRoundLogic(session)); default: return(RoundLogic.GetRoundLogic(session)); } }
public void GetPlayer1DominoeNumberInHandTest() { RoundLogic atTest = new RoundLogic(2); Player[] players = new Player[2]; players[0] = new Player(); players[1] = new Player(); atTest.dominoesPlaced = 0; players[0].playerHand[0] = 1; int expected = 1; int actual = 0; atTest.getProperDomino(ref players, ref actual); Assert.AreEqual(expected, actual); }
public void EnterResult() { HomeTeam.Score = int.Parse(HomeScore); AwayTeam.Score = int.Parse(AwayScore); tournamentView.SelectedGame.Unplayed = false; SqlDataHandler.UpdateGameScoreAndStatus(tournamentView.SelectedGame); if (tournamentView.CurrentTournament.IsLeague) { SqlDataHandler.UpdateLeagueParticipants(tournamentView.CurrentTournament, tournamentView.SelectedGame); } else { SqlDataHandler.UpdateGameParticipantAsCupRoundWinner(tournamentView.SelectedGame); if (RoundComplete()) { int currentRoundIndex = tournamentView.SelectedRound.RoundNumber - 1; List <TeamModel> nextRoundParticipants = SqlDataHandler.GetRoundWinners(tournamentView.SelectedRound.Id); if (tournamentView.SelectedRound.RoundNumber < tournamentView.RoundList.Count) { RoundModel nextRound = tournamentView.CurrentTournament.Rounds[currentRoundIndex + 1]; RoundLogic.CreateCupRoundGames(nextRoundParticipants, nextRound); } } } if (TournamentComplete()) { tournamentView.CurrentTournament.Finished = true; SqlDataHandler.UpdateTournamentStatus(tournamentView.CurrentTournament); } tournamentView.CanEnterResult = false; tournamentView.GameList.Refresh(); TryClose(); }
private static double RoundInchesOfDecimalFeet(double oldDecimalFeet, double roundingValue, RoundDirection roundValue) { const double unit = 12.0; const int digits = 6; var oldDecimalInches = Math.Round(oldDecimalFeet * unit, digits); var oldWholeInches = Math.Truncate(oldDecimalInches); var oldPartialInches = oldDecimalInches - oldWholeInches; var newPartialInches = 0.0; if (Math.Abs(oldPartialInches % roundingValue) <= 0) { newPartialInches = oldPartialInches; } else { if (roundValue == RoundDirection.Up) { newPartialInches = RoundLogic.RoundPartialInchUp(oldPartialInches, roundingValue); } else if (roundValue == RoundDirection.Down) { newPartialInches = RoundLogic.RoundPartialInchDown(oldPartialInches, roundingValue); } } var newDecimalInches = oldWholeInches + newPartialInches; var newDecimalFeet = newDecimalInches / unit; var oldFraction = ConvertDecimalFeetToFractionalFormat(oldDecimalFeet, roundingValue, FractionalFormat.FeetInchAndFraction); var newFraction = ConvertDecimalFeetToFractionalFormat(newDecimalFeet, roundingValue, FractionalFormat.FeetInchAndFraction); Console.WriteLine($"Old Decimal Feet: {oldDecimalFeet}\t({oldFraction}).\t\tNew Decimal Feet: {newDecimalFeet}\t({newFraction})."); return(newDecimalFeet); }
public RoundEventArgs(RoundLogic logic) { RoundLogic = logic; }
internal void RoundEnd(RoundLogic logic) { OnRoundEnd?.Invoke(this, new RoundEventArgs(logic)); }
internal void RoundBegin(RoundLogic logic) { OnRoundStart?.Invoke(this, new RoundEventArgs(logic)); }
public void Run() { Console.WriteLine("Run"); var listRounds = ReaderFile(); var logicRound = new RoundLogic(); var rounds = new List <Round>(); Round tempRound; foreach (var item in listRounds) { tempRound = logicRound.Create(item[0], item[1], item[2], out IEnumerable <ValidationFailure> listError); if (tempRound != null) { rounds.Add(tempRound); } foreach (var error in listError) { Console.WriteLine($"{error.ErrorMessage} coord: x= {item[0]} y={item[1]} radius={item[2]}"); } } //Демонстрация Round c1 = rounds[0]; Round c2 = rounds[1]; Round c3 = rounds[2]; Round c4 = rounds[3]; Console.WriteLine("Окружность 1: " + c1.ToString()); Console.WriteLine("Окружность 2: " + c2.ToString()); Console.WriteLine("Окружность 3: " + c3.ToString()); if (c1 == c2) { Console.WriteLine("Окружности 1 и 2 равны"); } if (c2 == c3) { Console.WriteLine("Окружности 2 и 3 равны"); } if (c1 != c2) { Console.WriteLine("Окружности 1 и 2 не равны"); } if (c2 != c3) { Console.WriteLine("Окружности 2 и 3 не равны"); } Console.WriteLine("Площадь 1 окружности: " + c1.Ploshad()); Console.WriteLine("Площадь 2 окружности: " + c2.Ploshad()); Console.WriteLine("Площадь 3 окружности: " + c3.Ploshad()); Console.WriteLine("Установка координат 2 окружности. Теперь координаты x и y равны 3 и 4 соответственно "); c2[1] = 3; c2[2] = 4; Console.WriteLine("Окружность 2: " + c2.ToString()); Console.WriteLine("Координаты 2 окружности: x = " + c2[1] + " y = " + c2[2]); Console.WriteLine("Увеличение радиуса окружности"); Console.WriteLine("До увеличения радиуса окружности 3: " + c3.ToString()); Console.WriteLine("Увеличение радиуса 3 окружности в 5 раз. Теперь радиус равен " + c3 * 5); Console.WriteLine("После увеличения радиуса окружности 3: " + c3.ToString()); Console.WriteLine("Уменьшение радиуса окружности"); Console.WriteLine("До уменьшения радиуса окружности 2: " + c2.ToString()); Console.WriteLine("Уменьшение радиуса 2 окружности в 2 раза. Теперь радиус равен " + c2 / 2); Console.WriteLine("После уменьшения радиуса окружности 2: " + c2.ToString()); Console.ReadKey(); }