diff --git a/MudClient/..svnbridge/.svnbridge b/MudClient/..svnbridge/.svnbridge new file mode 100644 index 0000000..bdf168c --- /dev/null +++ b/MudClient/..svnbridge/.svnbridge @@ -0,0 +1,3 @@ +svn:ignorebin +obj + \ No newline at end of file diff --git a/MudEngine/GameManagement/Game.cs b/MudEngine/GameManagement/Game.cs index adc7837..418dad7 100644 --- a/MudEngine/GameManagement/Game.cs +++ b/MudEngine/GameManagement/Game.cs @@ -331,6 +331,7 @@ namespace MudEngine.GameManagement lastSaveGap++; } + if (IsMultiplayer) { Console.Write(Log.GetMessages()); diff --git a/MudEngine/GameManagement/GameTime.cs b/MudEngine/GameManagement/GameTime.cs index 1831ed6..c1e3a5a 100644 --- a/MudEngine/GameManagement/GameTime.cs +++ b/MudEngine/GameManagement/GameTime.cs @@ -40,7 +40,7 @@ namespace MudEngine.GameManagement /// /// Gets or Sets the current Time of the System /// - private DateTime CurrentTime { get; set; } + private DateTime CurrentSystemTime { get; set; } /// /// Gets or Sets how many Hours it takes to make a full day in the World @@ -126,6 +126,29 @@ namespace MudEngine.GameManagement MonthNames.Add("October"); MonthNames.Add("November"); MonthNames.Add("December"); + + Time t = new Time(); + t.Second = 0; + t.Minute = 1; + t.Hour = 8; + t.Day = 1; + t.Month = 1; + t.Year = 2010; + + InitialGameTime = t; + + DawnTime = 19; + SunriseTime = 6; + + DayTransitions = TimeOfDayOptions.Transition; + + SecondsPerMinute = 60; + MinutesPerHour = 60; + HoursPerDay = 24; + DaysPerMonth = 31; + MonthsPerYear = 12; + + CurrentWorldTime = InitialGameTime; } public void Initialize() @@ -136,21 +159,20 @@ namespace MudEngine.GameManagement public virtual void Update() { - TimeSpan ts = CurrentTime - DateTime.Now; + TimeSpan ts = CurrentSystemTime - DateTime.Now; //If the seconds that has passed inbetween the last Update call is greater than 0 //Then we need to increment a Second, which will start a domino effect if it needs to //in order to increment minute/hours/days/months and years. - if (ts.Seconds != 0) + if (ts.Seconds <= -1) { - IncrementSecond(); + CurrentSystemTime = DateTime.Now; + Int32 amount = Math.Abs(ts.Seconds); + IncrementSecond(amount); } - - CurrentTime = DateTime.Now; - } - public void IncrementSecond() + public void IncrementSecond(Int32 amount) { Time t = new Time(); t = CurrentWorldTime; @@ -158,15 +180,24 @@ namespace MudEngine.GameManagement if (CurrentWorldTime.Second == SecondsPerMinute) { t.Second = 0; - IncrementMinute(); + IncrementMinute(1); + t = CurrentWorldTime; + } + else if (CurrentWorldTime.Second > SecondsPerMinute) + { + Int32 minutes = CurrentWorldTime.Second / SecondsPerMinute; + Int32 seconds = CurrentWorldTime.Second - SecondsPerMinute; + IncrementMinute(minutes); + t = CurrentWorldTime; //Get the updated world time. + t.Second = seconds; //Edit it. } else - t.Second++; + t.Second += amount; CurrentWorldTime = t; } - public void IncrementMinute() + public void IncrementMinute(Int32 amount) { Time t = new Time(); t = CurrentWorldTime; @@ -174,15 +205,23 @@ namespace MudEngine.GameManagement if (CurrentWorldTime.Minute == MinutesPerHour) { t.Minute = 0; - IncrementHour(); + IncrementHour(1); + } + else if (CurrentWorldTime.Minute > MinutesPerHour) + { + Int32 hours = CurrentWorldTime.Minute / MinutesPerHour; + Int32 Minutes = CurrentWorldTime.Minute - MinutesPerHour; + IncrementHour(hours); + t = CurrentWorldTime; + t.Minute = Minutes; } else - t.Minute++; + t.Minute += amount; CurrentWorldTime = t; } - public void IncrementHour() + public void IncrementHour(Int32 amount) { Time t = new Time(); t = CurrentWorldTime; @@ -192,6 +231,14 @@ namespace MudEngine.GameManagement t.Hour = 0; IncrementDay(); } + else if (CurrentWorldTime.Hour > HoursPerDay) + { + Int32 days = CurrentWorldTime.Hour / HoursPerDay; + Int32 hours = CurrentWorldTime.Hour - HoursPerDay; + IncrementDay(); + t = CurrentWorldTime; + t.Hour = hours; + } else t.Hour++; @@ -202,7 +249,8 @@ namespace MudEngine.GameManagement { Time t = new Time(); t = CurrentWorldTime; - + + //TODO: Finish GameTime syncing with Server Time. if (CurrentWorldTime.Day == DaysPerMonth) { t.Day = 1; diff --git a/MudEngine/GameObjects/Items/BaseItem.cs b/MudEngine/GameObjects/Items/BaseItem.cs index 83547bc..4a1a48e 100644 --- a/MudEngine/GameObjects/Items/BaseItem.cs +++ b/MudEngine/GameObjects/Items/BaseItem.cs @@ -4,11 +4,13 @@ using System.Collections.Generic; using System.Linq; using System.Text; +using MudEngine.GameManagement; + namespace MudEngine.GameObjects.Items { public class BaseItem : BaseObject { - public BaseItem(GameManagement.Game game) : base(game) + public BaseItem(Game game) : base(game) { } } diff --git a/MudGame/Scripts/CommandCreate.cs b/MudGame/Scripts/CommandCreate.cs index f994496..c81358e 100644 --- a/MudGame/Scripts/CommandCreate.cs +++ b/MudGame/Scripts/CommandCreate.cs @@ -39,21 +39,28 @@ { //Instance a new Realm. Realm realm = new Realm(player.ActiveGame); + Boolean isLegalName = false; - //Get the name of this Realm from the player. - player.Send("Realm Name: ", false); - realm.Name = player.ReadInput(); - - //Check if a Realm with this name already exists. - foreach (Realm r in player.ActiveGame.World.RealmCollection) + while (!isLegalName) { - if (r.Name == realm.Name) + isLegalName = true; + //Get the name of this Realm from the player. + player.Send("Realm Name: ", false); + realm.Name = player.ReadInput(); + + //Check if a Realm with this name already exists. + foreach (Realm r in player.ActiveGame.World.RealmCollection) { - player.Send("Realm already exists!"); + if (r.Name == realm.Name) + { + player.Send("Realm already exists!"); + isLegalName = false; + } } } player.ActiveGame.World.AddRealm(realm); + Log.Write(player.Name + " has created a Realm called " + realm.Name); player.Send(realm.Name + " has been created and added to the world."); } @@ -122,6 +129,7 @@ } } + Log.Write(player.Name + " has created a Zone called " + zone.Name + " within the Realm " + realm.Name); player.Send(zone.Name + " has been created and added to Realm " + realm.Name + "."); } } \ No newline at end of file