public GlobalEvent(StarSystemModel starSystem, GlobalEventType @event, int eventValue, DateTime date) { StarSystemIndex = starSystem.Coords.Y * GameConfig.CurrentGalaxySizeX + starSystem.Coords.X; Event = @event; EventValue = eventValue; EventDate = date; }
public static StarSystemModel CreateRandom(Allegiance allegiance) { var independentBonus = allegiance == Allegiance.Independent ? GameConfig.IndependentIllegalBonus : 0; var model = new StarSystemModel(); if (RNG.GetDice() + independentBonus <= GameConfig.GoodIsIllegalChance-1) model.IllegalGoods.Add(Merchandise.Luxury); if (RNG.GetDice() + independentBonus <= GameConfig.GoodIsIllegalChance-1) model.IllegalGoods.Add(Merchandise.Drugs); if (RNG.GetDice() + independentBonus <= GameConfig.GoodIsIllegalChance) model.IllegalGoods.Add(Merchandise.Weapons); if (RNG.GetDice() + independentBonus <= GameConfig.GoodIsIllegalChance) model.IllegalGoods.Add(Merchandise.Slaves); model.LegalGoods.AddRange(Enums.All_Merchandise.Where(a => !model.IllegalGoods.Contains(a))); model.Allegiance = allegiance; return model; }
public static void Create(GalaxyModel galaxy, StarSystemModel currentSystem) { galaxy.LastEventDate = galaxy.GameDate; var globalEvent = Enums.All_GlobalEvents.Get_Random(); if (globalEvent == GlobalEventType.Normal) globalEvent = GlobalEventType.AlienInvasion; #region If it's time for Great Alien Attack if (galaxy.AlienStrength != AlienStrength.FatherIsKilled && (galaxy.GameDate > GameConfig.AlienAttackDate || galaxy.AlienStrength == AlienStrength.FatherIsHere || (globalEvent == GlobalEventType.AlienInvasion && galaxy.Get_AllSystems().Count(a => a.CurrentEvent == GlobalEventType.AlienInvasion) > GameConfig.AlienAttackTriggerCount))) { galaxy.AlienStrength = AlienStrength.FatherIsHere; globalEvent = GlobalEventType.AlienInvasion; } #endregion #region Get star system and event duration var system = galaxy.Get_RandomSystemForEvent(globalEvent); if (globalEvent == GlobalEventType.Epidemy || globalEvent == GlobalEventType.Starvation || globalEvent == GlobalEventType.CivilWar) { system.CurrentEvent = globalEvent; system.EventDuration = GameConfig.BaseGlobalEventDuration + RNG.GetDice(); system.EventEndDate = galaxy.GameDate.AddDays(system.EventDuration); } if (globalEvent == GlobalEventType.AlienInvasion) system.CurrentEvent = globalEvent; var eventValue = system.EventDuration; #endregion #region Process the event impact switch (globalEvent) { case GlobalEventType.AlienInvasion: break; case GlobalEventType.LevelUp : system.TechLevel++; eventValue = system.TechLevel; break; case GlobalEventType.LevelDown : system.TechLevel--; eventValue = system.TechLevel; break; case GlobalEventType.IllegalAdd : var merchToAdd = Enums.All_MerchandiseIllegal.Where(a => !system.IllegalGoods.Contains(a)).ToList().Get_Random(); system.IllegalGoods.Add(merchToAdd); eventValue = (int) merchToAdd; break; case GlobalEventType.IllegalRemove: var merchToRemove = system.IllegalGoods.Get_Random(); system.IllegalGoods.Remove(merchToRemove); eventValue = (int) merchToRemove; break; } #endregion #region Add the event to EventLog and print it if needed var newGlobalEvent = new GlobalEvent(system, globalEvent, eventValue, galaxy.GameDate); galaxy.GlobalEventLog.Add(newGlobalEvent); if (globalEvent == GlobalEventType.AlienInvasion || (Enums.All_GlobalEventsWithDuration.Contains(globalEvent) && system.Allegiance == currentSystem.Allegiance)) { newGlobalEvent.Print(); } #endregion }