/// <summary> /// Builds a new life form. /// </summary> /// <param name="lifeFormType">The life form type to build.</param> /// <returns>A newly instantiated life form object.</returns> public static LifeFormBase Build(LifeForm lifeFormType) { LifeFormBase lifeForm = null; switch (lifeFormType) { case LifeForm.Empty: lifeForm = new Empty(); break; case LifeForm.Acorn: lifeForm = new Acorn(); break; case LifeForm.AircraftCarrier: lifeForm = new AircraftCarrier(); break; case LifeForm.FivePoint: lifeForm = new FivePoint(); break; default: lifeForm = new RandomPattern( rows: RANDOMPATTERNHEIGHT, cols: RANDOMPATTERNWIDTH); break; } return(lifeForm); }
public void Constructor_WhenInvoked_PreparesAcornCorrectly() { // act var acorn = new Acorn(); int oneSide = acorn.GetPattern().Length; int otherSide = acorn.GetPattern().Max(x => x.Length); // assert Assert.IsTrue( oneSide == 8 && oneSide == otherSide, message: "The acorn pattern was not of size 8x8."); Assert.IsTrue( acorn.IsStable, message: "The acorn pattern was not stable."); Assert.AreEqual( expected: 5206, actual: acorn.StabilizesAt, message: "The acorn pattern stabilizes at the wrong time."); Assert.AreEqual( expected: 633, actual: acorn.StablePopulation, message: "The acorn pattern has wrong number of cells in the stable population."); }
public void CallDbSetFakeDirectly() { var context = ContextFaker.CreateContext <TestContext>(); var data = new Acorn[] { }; IQueryable <Acorn> dataQueryable = data.AsQueryable(); IEnumerator <Acorn> dataEnumerator = dataQueryable.GetEnumerator(); var mockSet = A.Fake <DbSet <Acorn> >(builder => { builder.Implements(typeof(IDbAsyncEnumerable <Acorn>)); builder.Implements(typeof(IQueryable <Acorn>)); }); var mockEnumerable = (IDbAsyncEnumerable <Acorn>)mockSet; A.CallTo(() => (mockEnumerable).GetAsyncEnumerator()) .Returns(new TestDbAsyncEnumerator <Acorn>(dataEnumerator)); A.CallTo(() => ((IQueryable <Acorn>)mockSet).Provider) .Returns(new TestDbAsyncQueryProvider <Acorn>(dataQueryable.Provider)); A.CallTo(() => ((IQueryable <Acorn>)mockSet).Expression).Returns(dataQueryable.Expression); A.CallTo(() => ((IQueryable <Acorn>)mockSet).ElementType).Returns(dataQueryable.ElementType); A.CallTo(() => ((IQueryable <Acorn>)mockSet).GetEnumerator()).Returns(dataEnumerator); A.CallTo(() => context.Acorns).Returns(mockSet); Assert.Empty(context.Acorns.ToArray()); }
public void CallDbSetFakeDirectly() { var context = ContextFaker.CreateContext<TestContext>(); var data = new Acorn[] { }; IQueryable<Acorn> dataQueryable = data.AsQueryable(); IEnumerator<Acorn> dataEnumerator = dataQueryable.GetEnumerator(); var mockSet = A.Fake<DbSet<Acorn>>(builder => { builder.Implements(typeof(IDbAsyncEnumerable<Acorn>)); builder.Implements(typeof(IQueryable<Acorn>)); }); var mockEnumerable = (IDbAsyncEnumerable<Acorn>)mockSet; A.CallTo(() => (mockEnumerable).GetAsyncEnumerator()) .Returns(new TestDbAsyncEnumerator<Acorn>(dataEnumerator)); A.CallTo(() => ((IQueryable<Acorn>)mockSet).Provider) .Returns(new TestDbAsyncQueryProvider<Acorn>(dataQueryable.Provider)); A.CallTo(() => ((IQueryable<Acorn>)mockSet).Expression).Returns(dataQueryable.Expression); A.CallTo(() => ((IQueryable<Acorn>)mockSet).ElementType).Returns(dataQueryable.ElementType); A.CallTo(() => ((IQueryable<Acorn>)mockSet).GetEnumerator()).Returns(dataEnumerator); A.CallTo(() => context.Acorns).Returns(mockSet); Assert.Empty(context.Acorns.ToArray()); }
public void CanAddThenRemoveEntry() { var acorn = new Acorn {Id = 0, NutritionValue = 25}; context.Acorns.Add(acorn); context.Acorns.Remove(acorn); Assert.Equal(initialCount, context.Acorns.Count()); }
public void CanAddThenRemoveThenAddAgain() { var acorn = new Acorn {Id = 0, NutritionValue = 25}; context.Acorns.Add(acorn); context.Acorns.Remove(acorn); context.Acorns.Add(acorn); Assert.Contains(acorn, context.Acorns.ToList()); }
public void CanAddThenRemoveEntry() { var acorn = new Acorn { Id = 0, NutritionValue = 25 }; context.Acorns.Add(acorn); context.Acorns.Remove(acorn); Assert.Equal(initialCount, context.Acorns.Count()); }
public void AddTwiceOnlyAddsOnce() { var acorn = new Acorn { NutritionValue = 1 }; context.Acorns.Add(acorn); context.Acorns.Add(acorn); Assert.Single(context.Acorns.Local, a => a.NutritionValue == 1); }
void Update() { if (gt.Count < 2) //not enough parents in list to breed { if (Input.GetMouseButtonDown(0)) { ray = Camera.main.ScreenPointToRay(Input.mousePosition); if (Physics.Raycast(ray, out hit, 100f)) //cast to tree layer { if (hit.transform.gameObject.layer == 8) { gt.Add(hit.collider.gameObject.transform.parent.GetComponent <Acorn>().gt); //add parent genes GUIUpdate(); } } } } else //two parents in list { if (Input.GetMouseButtonDown(0)) { ray = Camera.main.ScreenPointToRay(Input.mousePosition); if (Physics.Raycast(ray, out hit, 100f)) //cast to ground layer { if (hit.transform.gameObject.layer == 9) { acornObj = (GameObject)Instantiate(new GameObject(), hit.point, Quaternion.identity); Acorn acorn = acornObj.AddComponent <Acorn>(); List <Dom> chromatid1 = gt[0].GetChromatid(); List <Dom> chromatid2 = gt[1].GetChromatid(); acorn.SetGametes( chromatid1[0], chromatid2[0], chromatid1[1], chromatid2[1], chromatid1[2], chromatid2[2], chromatid1[3], chromatid2[3] ); } } } } if (Input.GetMouseButtonDown(1)) { gt.Clear(); GUIUpdate(); } }
public void CanAddThenRemoveThenAddAgain() { var acorn = new Acorn { Id = 0, NutritionValue = 25 }; context.Acorns.Add(acorn); context.Acorns.Remove(acorn); context.Acorns.Add(acorn); Assert.Contains(acorn, context.Acorns.ToList()); }
public int GetAcorn(Acorn newAcorn) { if (curAcorns < MAX_CARRY) { acornList[curAcorns] = newAcorn; curAcorns++; return(curAcorns); } else { return(-1); } }
void OnTriggerStay(Collider other) { if (other.CompareTag(Tags.Player) && Input.GetButtonDown("Interact")) { PlayerItem playerItem = other.GetComponent <PlayerItem>(); if (playerItem.hasItem) { acorn = playerItem.heldItem.GetComponent <Acorn>(); if (acorn != null) { StartCoroutine(CoPlantAcorn(playerItem)); } } } }
public void PlayerScore(int playerIndex, Acorn acorn) { var player = scores.FirstOrDefault(s => s.Player.playerIndex == playerIndex); if (acorn.Dud) { player.Score = Mathf.Max(0, player.Score - 2); OnPlayerTricked.Invoke(player); } else { player.Score++; OnPlayerScored.Invoke(player); } }
public ContextAddTests() { context = ContextFaker.CreateContext<TestContext>(); acorns = TestDataFactory.AcornTestData.ToList(); ContextFaker.ContextReturnsDbSet(() => context.Acorns, acorns); acorn1 = new Acorn { Id = 3, NutritionValue = 5 }; acorn2 = new Acorn { Id = 4, NutritionValue = 7 }; }
public ContextAddTests() { context = ContextFaker.CreateContext <TestContext>(); acorns = TestDataFactory.AcornTestData.ToList(); ContextFaker.ContextReturnsDbSet(() => context.Acorns, acorns); acorn1 = new Acorn { Id = 3, NutritionValue = 5 }; acorn2 = new Acorn { Id = 4, NutritionValue = 7 }; }
internal IScript ParseScript([NotNull] string source, [CanBeNull] string scriptName, bool strictEval, bool inFunction) { //https://tc39.github.io/ecma262/#sec-parse-script IScript script; try { var result = Acorn.Parse(source, new Options { ecmaVersion = 8, SourceFile = scriptName, StartInFunction = inFunction }); script = new NodeScript(result); } catch (SyntaxError e) { throw new ScriptException(CreateError(Realm.SyntaxErrorPrototype, e.Message), e); } script.HandleEarlyErrors(this, strictEval); return(script); }
private IModule ParseModule([NotNull] string source, [CanBeNull] string scriptName) { //https://tc39.github.io/ecma262/#sec-parsemodule IModule module; try { var result = Acorn.Parse(source, new Options { ecmaVersion = 8, SourceFile = scriptName, sourceType = SourceType.Module }); module = new NodeModule(result); } catch (SyntaxError e) { throw new ScriptException(CreateError(Realm.SyntaxErrorPrototype, e.Message), e); } module.HandleEarlyErrors(this, false); module.Initialise(); return(module); }
public Squirrel() : base(AIType.AI_Animal, FightMode.Aggressor, 10, 1, 0.2, 0.4) { Name = "a squirrel"; Body = 0x116; Hue = Utility.RandomList(0, 0, 0x966); SetStr(44, 50); SetDex(35); SetInt(5); SetHits(42, 50); SetDamage(1, 2); SetDamageType(ResistanceType.Physical, 100); SetResistance(ResistanceType.Physical, 30, 34); SetResistance(ResistanceType.Fire, 10, 14); SetResistance(ResistanceType.Cold, 30, 35); SetResistance(ResistanceType.Poison, 20, 25); SetResistance(ResistanceType.Energy, 20, 25); SetSkill(SkillName.MagicResist, 4.0); SetSkill(SkillName.Tactics, 4.0); SetSkill(SkillName.Wrestling, 4.0); Tamable = true; ControlSlots = 1; MinTameSkill = -21.3; if (Utility.RandomMinMax(1, 5) == 1) { Item acorn = new Acorn(Utility.RandomMinMax(1, 3)); PackItem(acorn); } }
public static ILifePattern ChoosePattern() { Console.WriteLine("Available pattern:"); Console.WriteLine("0: GliderGun"); Console.WriteLine("1: Acorn"); Console.WriteLine("2: DieHard"); Console.WriteLine("3: Pentadecathlon"); Console.WriteLine("4: Pulsar"); Console.WriteLine("5: Toad"); Console.WriteLine("6: Beacon"); Console.WriteLine("7: Blinker"); Console.WriteLine("8: AcornDoubleMirror"); Console.WriteLine("9: AcornMirror"); string choosen = Console.ReadLine(); int patternChoosen = 0; if (!string.IsNullOrWhiteSpace(choosen)) { patternChoosen = Convert.ToInt32(choosen); } ILifePattern pattern; switch (patternChoosen) { case 0: pattern = new GliderGun(); break; case 1: pattern = new Acorn(); break; case 2: pattern = new Diehard(); break; case 3: pattern = new Pentadecathlon(); break; case 4: pattern = new Pulsar(); break; case 5: pattern = new Toad(); break; case 6: pattern = new Beacon(); break; case 7: pattern = new Blinker(); break; case 8: pattern = new AcornDoubleMirror(); break; case 9: pattern = new AcornMirror(); break; default: pattern = new Acorn(); break; } return(pattern); }
protected override void OnTarget(Mobile from, object targeted) { if (m_Item.Deleted) { return; } if (targeted is ICarvable) { ((ICarvable)targeted).Carve(from, m_Item); } else if (targeted is Container) { Container body = (Container)targeted; if (body.ItemID >= 0x4B5A && body.ItemID <= 0x4BAB) { body.ItemID = Utility.RandomList(0xECA, 0xECB, 0xECC, 0xECD, 0xECE, 0xECF, 0xED0, 0xED1, 0xED2); body.Hue = 0; from.CriminalAction(true); Misc.Titles.AwardKarma(from, -50, true); body.DropItem(new BodyPart(0x1D9F)); body.DropItem(new BodyPart(0x1DA4)); body.DropItem(new BodyPart(0x1DA2)); body.DropItem(new BodyPart(0x1DA3)); body.DropItem(new BodyPart(0x1DA1)); body.DropItem(new BodyPart(0x1DA0)); from.SendMessage("You hack up the body into bloody pieces."); } } else if (targeted is SwampDragon && ((SwampDragon)targeted).HasBarding) { SwampDragon pet = (SwampDragon)targeted; if (!pet.Controlled || pet.ControlMaster != from) { from.SendLocalizedMessage(1053022); // You cannot remove barding from a swamp dragon you do not own. } else { pet.HasBarding = false; } } else { HarvestSystem system = Lumberjacking.System; HarvestDefinition def = Lumberjacking.System.Definition; int tileID; Map map; Point3D loc; if (!system.GetHarvestDetails(from, m_Item, targeted, out tileID, out map, out loc)) { from.SendLocalizedMessage(500494); // You can't use a bladed item on that! } else if (!def.Validate(tileID)) { from.SendLocalizedMessage(500494); // You can't use a bladed item on that! } else { HarvestBank bank = def.GetBank(map, loc.X, loc.Y); if (bank == null) { return; } if (bank.Current < 5) { from.SendMessage("There is not enough here to harvest."); //from.SendLocalizedMessage( 500493 ); // There's not enough wood here to harvest. } else { bank.Consume(5, from); if (tileID == 0x4D96 || tileID == 0x4D9A) // apples { Item item = new Apple(); if (from.PlaceInBackpack(item)) { from.SendMessage("You put an apple into your backpack."); } else { from.SendMessage("You can't place any apples into your backpack!"); item.Delete(); } } else if (tileID == 0x4DA6 || tileID == 0x4DAA) // pears { Item item = new Pear(); if (from.PlaceInBackpack(item)) { from.SendMessage("You put a pear into your backpack."); } else { from.SendMessage("You can't place any pears into your backpack!"); item.Delete(); } } else if (tileID == 0x4D9E || tileID == 0x4DA2) // peaches { Item item = new Peach(); if (from.PlaceInBackpack(item)) { from.SendMessage("You put a peach into your backpack."); } else { from.SendMessage("You can't place any peaches into your backpack!"); item.Delete(); } } else if (tileID == 0x4CDA || tileID == 0x4CDB || tileID == 0x4CDC || tileID == 0x4CDD || tileID == 0x4CDE || tileID == 0x4CDF) // acorns { Item item = new Acorn(); if (from.PlaceInBackpack(item)) { from.SendMessage("You put an acorn into your backpack."); } else { from.SendMessage("You can't place any acorns into your backpack!"); item.Delete(); } } else if (tileID == 0x4CA8 || tileID == 0x4CAA || tileID == 0x4CAB) // bananas { Item item = new Banana(); if (from.PlaceInBackpack(item)) { from.SendMessage("You put a banana into your backpack."); } else { from.SendMessage("You can't place any bananas into your backpack!"); item.Delete(); } } else if (tileID == 0x4C95) // coconut { Item item = new Coconut(); if (from.PlaceInBackpack(item)) { from.SendMessage("You put a coconut into your backpack."); } else { from.SendMessage("You can't place any coconuts into your backpack!"); item.Delete(); } } else if (tileID == 0x4C96) // dates { Item item = new Dates(); if (from.PlaceInBackpack(item)) { from.SendMessage("You put some dates into your backpack."); } else { from.SendMessage("You can't place any dates into your backpack!"); item.Delete(); } } else { Item item = new Kindling(); if (from.PlaceInBackpack(item)) { from.SendLocalizedMessage(500491); // You put some kindling into your backpack. from.SendLocalizedMessage(500492); // An axe would probably get you more wood. } else { from.SendLocalizedMessage(500490); // You can't place any kindling into your backpack! item.Delete(); } } } } } }