public ActionResult New(CivilizationForm form) { Debug.WriteLine(string.Format("POST: Civilization Controller: New Civilization - gameID={0}", GameState.GameID)); var game = GameState.Game; DB_civilization civilization = new DB_civilization(); civilization.game_id = game.Info.id; var selectedTraits = form.CivilizationTraits.Where(x => x.IsChecked).ToList(); if (selectedTraits.Count > 0) { civilization.civilization_traits_1_id = selectedTraits[0].ID; } if (selectedTraits.Count > 1) { civilization.civilization_traits_2_id = selectedTraits[1].ID; } if (selectedTraits.Count > 2) { civilization.civilization_traits_3_id = selectedTraits[2].ID; } civilization.tech_level_id = (form.SelectedTechLevel == -1) ? null : form.SelectedTechLevel; civilization.name = form.Name; civilization.colour = form.Colour; civilization.rp = form.RP; civilization.gmnotes = form.GMNotes; Database.Session.Save(civilization); foreach (var player in form.Players) { if (player.IsChecked) { DB_user_civilizations userCivilization = new DB_user_civilizations( player.ID, civilization.id, game.ID, game.GetPlayer(player.ID).GameUserInfo.id); Database.Session.Save(userCivilization); } } foreach (var civilizationMet in form.MetCivilizations) { if (civilizationMet.IsChecked) { DB_civilization_met dbCivilizationMet = new DB_civilization_met(civilization.id, civilizationMet.ID, game.ID); Database.Session.Save(dbCivilizationMet); } } Database.Session.Flush(); return(RedirectToRoute("Civilizations")); }
private void CreateSpeciesAndCivilization(Game game, DB_planets planet, DB_starsystems starsystem, Fotiv_Automator.Models.StarMapGenerator.Models.SentientSpecies species) { // Create the Civilization DB_civilization dbCivilization = new DB_civilization(); dbCivilization.game_id = game.ID; dbCivilization.civilization_traits_1_id = RetrieveCivilizationTrait(species.Traits[0].ToString().SpaceUppercaseLetters()).id; dbCivilization.civilization_traits_2_id = RetrieveCivilizationTrait(species.Traits[1].ToString().SpaceUppercaseLetters()).id; dbCivilization.civilization_traits_3_id = RetrieveCivilizationTrait(species.Traits[2].ToString().SpaceUppercaseLetters()).id; dbCivilization.tech_level_id = RetrieveTechLevel($"TL{(int)species.TechLevel} {species.TechLevel.ToString().SpaceUppercaseLetters()}").id; dbCivilization.colour = "#E4D12F"; dbCivilization.name = $"Civilization {game.Random.Next(int.MaxValue)}"; dbCivilization.rp = 0; Database.Session.Save(dbCivilization); DB_species dbSpecies = new DB_species(); dbSpecies.game_id = game.ID; dbSpecies.name = $"Species {game.Random.Next(int.MaxValue)}"; dbSpecies.description = string.Join(",", species.Classifications.Select(x => x.ToString())); Database.Session.Save(dbSpecies); DB_civilization_species dbCivSpecies = new DB_civilization_species(); dbCivSpecies.game_id = game.ID; dbCivSpecies.civilization_id = dbCivilization.id; dbCivSpecies.species_id = dbSpecies.id; Database.Session.Save(dbCivSpecies); var homeworldInfrastructure = RetrieveInfrastructure("Homeworld"); DB_civilization_infrastructure dbInfrastructure = new DB_civilization_infrastructure(); dbInfrastructure.game_id = game.ID; dbInfrastructure.struct_id = homeworldInfrastructure.id; dbInfrastructure.civilization_id = dbCivilization.id; dbInfrastructure.planet_id = planet.id; dbInfrastructure.current_health = homeworldInfrastructure.base_health; dbInfrastructure.experience = 0; dbInfrastructure.name = homeworldInfrastructure.name; dbInfrastructure.can_upgrade = false; dbInfrastructure.is_military = true; Database.Session.Save(dbInfrastructure); DB_visited_starsystems dbVisitedStarSystem = new DB_visited_starsystems(); dbVisitedStarSystem.game_id = game.ID; dbVisitedStarSystem.civilization_id = dbCivilization.id; dbVisitedStarSystem.starsystem_id = starsystem.id; }
public Civilization(DB_civilization dbCivilization, Game game) { Info = dbCivilization; ThisGame = game; Assets = new CivilizationAssets(this); QueryOwners(); QueryResearch(); QueryInfrastructure(); QueryUnits(); QueryVisitedStarsystemInfo(); QueryMetCivilizationsInfo(); QuerySpeciesInfo(); }