public AddEditFaunaViewModel() : base(-1) { ValidInanimateTemplates = TemplateCache.GetAll <IInanimateTemplate>(); ValidMaterials = TemplateCache.GetAll <IMaterial>(); ValidRaces = TemplateCache.GetAll <IRace>(); DataObject = new Fauna(); }
public Fauna GetFaunaById(int id) { Fauna result = (from f in Faunas where f.FaunaId == id select f).FirstOrDefault <Fauna>(); return(result); }
public void DeleteFauna(int id) { Fauna result = (from f in faunas where f.FaunaId == id select f).FirstOrDefault <Fauna>(); faunas.Remove(result); }
public void UpdateFauna(Fauna f) { int index = faunas.FindIndex(p => p.FaunaId == f.FaunaId); if (index < 0) { faunas.Add(f); } else { faunas[index] = f; } }
public void FaunaRepositoryMock_UpdateFauna() { FaunaRepositoryMock urm = new FaunaRepositoryMock(); Fauna fauna = new Fauna() { FaunaName = "Njajal Gan", FaunaId = 1 }; urm.UpdateFauna(fauna); var a = urm.GetFaunaById(1); Assert.AreEqual(fauna, a); }
public void FaunaRepositoryDb_UpdateFauna() { FaunaRepositoryDb urd = new FaunaRepositoryDb(); Fauna fauna = new Fauna() { FaunaName = "Njajal Gan", FaunaId = 1 }; urd.UpdateFauna(fauna); var a = urd.GetFaunaById(1); Assert.AreEqual(fauna, a); }
public void FaunaRepositoryMock_AddFauna() { FaunaRepositoryMock urm = new FaunaRepositoryMock(); Fauna fauna = new Fauna() { FaunaName = "Njajal Gan", FaunaId = 1000 }; urm.AddFauna(fauna); var a = urm.GetFaunaById(1000); Assert.IsNotNull(a); }
public void FaunaRepositoryDb_AddFauna() { FaunaRepositoryDb urd = new FaunaRepositoryDb(); Fauna fauna = new Fauna() { FaunaName = "Njajal Gan", FaunaId = 1000 }; urd.AddFauna(fauna); var a = urd.GetFaunaById(1000); Assert.IsNotNull(a); }
/// <summary> /// This is a mock function. /// </summary> virtual public void MockInstantiate(UInt64 maxWealth) { /**** ORDER IS ESSENTIAL ****/ Amiability = new Amiability.Amiability(Seed); // Will have a bearing on TechLevel TechLevel = Tech.TechLevel.WESTERN; // Need to determine how to set this Wealth = new Wealth(Seed, TechLevel, maxWealth); // Dependent on TechLevel Population = new Population(this); // Dependent on Tech, Amiability, and Wealth RaceMakeup = new RaceMakeup(Seed); Weather = new Weather.Weather(); Flora = new Flora(Weather); Fauna = new Fauna(Weather); }
// Use this for initialization void Start() { planet = GetComponentInParent <Planet>(); //print ("planetModifiers on currentresources = " + planetModifiers[0] + ", also nresMultipliers = " + planet.nResourceMultipliers + ", planet.resourcemult[0] = " + planet.resourceMultipliers[0]); //add resources pop = new Population(this); food = new Food(this); water = new Water(this); oxygen = new Oxygen(this); power = new Power(this); flora = new Flora(this); fauna = new Fauna(this); //@@ volgorde moet later aangepast.. res = new Resource[7] { pop, food, water, oxygen, power, flora, fauna }; }
public IActionResult Create(string name, IFormFile picture, string description, int height, int length, string color, string latitude, string longitude, DateTime date) { byte[] newPicture = new byte[0]; if (picture != null) { using (Stream fileStream = picture.OpenReadStream()) using (MemoryStream ms = new MemoryStream()) { fileStream.CopyTo(ms); newPicture = ms.ToArray(); } } Fauna newFauna = new Fauna(newPicture, name, description, length, height, color, latitude, longitude, date); newFauna.UserId = User.Identity.Name; db.Faunas.Add(newFauna); db.SaveChanges(); return(RedirectToAction("Index", "Account")); }
private static List <Fauna> GetFauna(int x, int y, int faunaCount = 35) { var fauna = new List <Fauna>(); var rng = new Random(); for (var i = 0; i < faunaCount; i++) { var newFauna = new Fauna() { Name = "plant" + i, PositionX = rng.Next(0, x), PositionY = rng.Next(0, y - 1), Resources = rng.Next(1, 25), Health = rng.Next(35, 100) // health of fauna is directly proportional to how many resource they provide }; if (!fauna.Any(x => x.PositionY == newFauna.PositionY && x.PositionX == newFauna.PositionX)) // if fauna doesn't already exist at this position, add it { fauna.Add(newFauna); } } return(fauna); }
public ActionResult AddFauna(FormCollection form) { if (Session["UserName"] != null) { Fauna fauna = new Fauna(); fauna.FaunaName = form.Get("name"); fauna.FaunaLatinName = form.Get("latin"); fauna.FaunaLongitude = float.Parse(form.Get("longitude")); fauna.FaunaLatitude = float.Parse(form.Get("latitude")); fauna.FaunaOtherDescription = form.Get("description"); fauna.FaunaReference = form.Get("reference"); fauna.FaunaPhoto = form.Get("photolink"); fauna.FaunaDate = DateTime.Now; fauna.UserId = int.Parse(Session["UserId"].ToString()); fns.AddFauna(fauna); return(View()); } else { return(RedirectToAction("Index")); } }
public override String ToString() { string pop = String.Format("\nPopulation: {0:N0}", Population.Pop); string wealth = String.Format("\nWealth: ${0:N2}", Wealth.RegionWealth); string income = String.Format("\nIncome: ${0:N2}", Income); string distance = String.Format("\nDistFrmCntr: {0:f6}", DistanceFromCenter); string printstr = "Region Information:" + pop + wealth + income + "\nAmiability: " + Amiability.AmiabilityLevel + "\nTechLevel: " + TechLevel + //"\nWorldCulture: " + WorldCulture + distance + "\nNclrWstlnd: " + NuclearWasteland + "\n" + RaceMakeup.ToString() + "\n" + Weather.ToString() + "\n" + Flora.ToString() + "\n" + Fauna.ToString(); return(printstr); }
public AddEditFaunaViewModel(long templateId) : base(templateId) { ValidInanimateTemplates = TemplateCache.GetAll <IInanimateTemplate>(); ValidMaterials = TemplateCache.GetAll <IMaterial>(); ValidRaces = TemplateCache.GetAll <IRace>(); DataObject = new Fauna(); //apply template if (DataTemplate != null) { DataObject.AmountMultiplier = DataTemplate.AmountMultiplier; DataObject.CanSpawnInSystemAreas = DataTemplate.CanSpawnInSystemAreas; DataObject.ElevationRange = DataTemplate.ElevationRange; DataObject.FemaleRatio = DataTemplate.FemaleRatio; DataObject.HumidityRange = DataTemplate.HumidityRange; DataObject.OccursIn = DataTemplate.OccursIn; DataObject.PopulationHardCap = DataTemplate.PopulationHardCap; DataObject.PuissanceVariance = DataTemplate.PuissanceVariance; DataObject.Rarity = DataTemplate.Rarity; DataObject.Race = DataTemplate.Race; DataObject.TemperatureRange = DataTemplate.TemperatureRange; } }
public void UpdateFauna(Fauna f) { context.Entry(f).State = EntityState.Modified; context.SaveChanges(); }
public void UpdateFauna(Fauna f) { faunaRepository.UpdateFauna(f); }
public void AddFauna(Fauna f) { faunas.Add(f); }
public void AddFauna(Fauna f) { context.Faunas.Add(f); context.SaveChanges(); }
public void AddFauna(Fauna f) { faunaRepository.AddFauna(f); }
public static Genome Combination(Fauna father, Fauna mother) => Combination(father.genome, mother.genome);