diff --git a/GoldRush/Board.cs b/GoldRush/Board.cs index b87920b..09e52af 100644 --- a/GoldRush/Board.cs +++ b/GoldRush/Board.cs @@ -12,7 +12,7 @@ public class Board private int amountOfCarts = 1; private Random random; public WaterQuay quay { get; set; } - public int Score { get; private set; } + public int Score { get; private set; } = 0; public WaterLink FirstRiver { get; set; } public Track TrackEnd { get; private set; } @@ -71,7 +71,7 @@ public bool HasAddedAShip() { return false; } - if(random.Next(1, 2) ==1) + if(random.Next(1, 10) == 1) { Ship newShip = new Ship(FirstRiver); FirstRiver.Occupant = newShip; diff --git a/GoldRush/Game.cs b/GoldRush/Game.cs index 5086a87..0a22261 100644 --- a/GoldRush/Game.cs +++ b/GoldRush/Game.cs @@ -14,7 +14,7 @@ public class Game : IObservable public Board board { get; set; } public InputController InputController { get; set; } = new InputController(); private Timer timer; - private Boolean isGameEnded; + private bool isGameEnded; private View.ObserverList, GameData> ObserverList = new View.ObserverList, GameData>(); public void Play() @@ -25,6 +25,7 @@ public void Play() this.timer = new Timer(1000); timer.Elapsed += OnTimedEvent; + timer.Elapsed += DecreaseTimerInterval; timer.AutoReset = true; timer.Enabled = true; timer.Start(); @@ -99,5 +100,18 @@ public IDisposable Subscribe(IObserver observer) ObserverList.Add(observer); return ObserverList; } + private void DecreaseTimerInterval(Object source, ElapsedEventArgs e) + { + var interval = NewTimerMilisecondsTime( this.timer.Interval); + // Create a minimum. + if (interval < 50) + interval = 50; + this.timer.Interval = this.timer.Interval; + } + private double NewTimerMilisecondsTime(double Time) + { + const double PowerTo = 13 / 10; + return 1000 - Math.Ceiling(Math.Pow(Time, PowerTo)); + } } } \ No newline at end of file diff --git a/GoldRush/View/EndGameView.cs b/GoldRush/View/EndGameView.cs index 3cbe67f..b15d80e 100644 --- a/GoldRush/View/EndGameView.cs +++ b/GoldRush/View/EndGameView.cs @@ -8,12 +8,15 @@ namespace GoldRush.View { class EndGameView : IRenderable { + public int Score { get;set;} public void Render() { Console.Clear(); Console.Write( "####################\n" + - " The game has ended.\n" + " The game has ended.\n" + + " Your score was: {0}", + Score ); } } diff --git a/GoldRush/View/MainViewViewModel.cs b/GoldRush/View/MainViewViewModel.cs index b46a5e8..713313f 100644 --- a/GoldRush/View/MainViewViewModel.cs +++ b/GoldRush/View/MainViewViewModel.cs @@ -25,7 +25,11 @@ public void OnNext(GameData value) { if (value.IsGameEnded) { - new EndGameView().Render(); + new EndGameView + { + Score = value.score + } + .Render(); return; } View.Board = _viewStringsFactory.GetDisplayLines(value.Game); diff --git a/view.png b/view.png new file mode 100644 index 0000000..92fd14a Binary files /dev/null and b/view.png differ