public Cookbook(int[] startRecipes) { if (startRecipes.Length != 2) { throw new ArgumentException("Only works with exactly 2 starting elfs"); } recipes = new List <int>(); elfs = new Elf[2]; for (int i = 0; i < startRecipes.Length; i++) { recipes.Add(startRecipes[i]); elfs[i] = new Elf(recipes[i], i); } numRecipes = recipes.Count; }
/// <summary> /// returns best target to attack or null if shouldn't attack or no targets in range /// </summary> /// <param name="elf"> elf object </param> /// <returns></returns> public static GameObject GetAttackTarget(this Elf elf) { IEnumerable <GameObject> allTargets = ((GameObject[])GameState.Game.GetEnemyLivingElves()) .Concat(GameState.Game.GetEnemyPortals()) .Concat(GameState.Game.GetEnemyManaFountains()) .Concat(GameState.EnemyLivingTornadoes); return((from target in allTargets where elf.InAttackRange(target) orderby target is Elf ? 0 : 1, target is Portal ? 0 : 1, target is Tornado ? 0 : 1, target.CurrentHealth select target).FirstOrDefault()); }
public void Dispose() { if (!disposed) { if (Elf != null) { Elf.Dispose(); } if (CD != null) { CD.Dispose(); } disposed = true; } }
public static void Main(string[] args) { Item espada = new Item("Espada", 45, 0, null); Item baston = new Item("Baston", 50, 10, null); Item garrote = new Item("Garrote", 35, 0, null); Item capa = new Item("Capa de la invisibilidad", 0, 100, null); Item varita = new Item("Varita", 100, 45, null); Item excalibur = new Item("Excalibur", 80, 0, null); Item gwaihir = new Item("Gwaihir", 70, 60, null); List <Item> artMagia = new List <Item>(); List <Item> itemsElfo = new List <Item>(); List <Item> itemsEnano = new List <Item>(); artMagia.Add(baston); itemsElfo.Add(garrote); itemsEnano.Add(espada); artMagia.Add(capa); artMagia.Add(varita); itemsElfo.Add(excalibur); artMagia.Add(gwaihir); Wizard mago = new Wizard("Mago", 60, artMagia); Dwarf enano = new Dwarf("Enano", 40, itemsEnano); Elf elfo = new Elf("Elfo", 45, itemsElfo); Wizard Gandalf = new Wizard("Gandalf", 100, artMagia); Wizard hp = new Wizard("Harry Potter", 2, artMagia); Wizard lv = new Wizard("Lord Voldemort", 7, artMagia); ConsolePrinter print = new ConsolePrinter(); print.AfterAttack(elfo.ElfAttack(mago.Items[0].Damage)); print.AfterAttack(mago.WizardAttack(enano.Items[0].Damage)); print.AfterAttack(enano.DwarfAttack(elfo.Items[0].Damage)); print.AfterAttack(Gandalf.WizardAttack(elfo.Items[1].Damage)); print.AfterAttack(hp.WizardAttack(lv.Items[2].Damage)); print.AfterCure(elfo.ElfCure()); }
private void SearchRace() { if (isElfRadio.Checked) { elfHistories = elfLogic.GetAllElves(); index = 0; currentRace = "elf"; currentElf = elfHistories.First(); Display(); } else if (isDwarfRadio.Checked) { dwarfHistories = dwarfLogic.GetAllDwarves(); index = 0; currentRace = "dwarf"; currentDwarf = dwarfHistories.First(); Display(); } else if (isWizardRadio.Checked) { wizardHistories = wizardLogic.GetAllWizards(); index = 0; currentRace = "wizard"; currentWizard = wizardHistories.First(); Display(); } else if (isHumanRadio.Checked) { humanHistories = humanLogic.GetAllHumans(); index = 0; currentRace = "human"; currentHuman = humanHistories.First(); Display(); } else if (isHobbitRadio.Checked) { hobbitHistories = hobbitLogic.GetAllHobbits(); index = 0; currentRace = "hobbit"; currentHobbit = hobbitHistories.First(); Display(); } else { MessageBox.Show("Please select one of the races!", "Error"); return; } }
static void Main() { Elf elf = new Elf(); elf.ElfInfo(); Gnome gnome = new Gnome(); gnome.GnomeInfo(); Daemon daemon = new Daemon(); daemon.DaemonInfo(); Console.ReadLine(); }
public void WhenHPIs0CharacterIsDead() { Elf elfo = new Elf("Eduardo"); Elf elfoBufado = new Elf("El Mata Eduardos"); Gauntlet gauntlet = new Gauntlet(); for (int i = 0; i < 10; i++) { gauntlet.AddGem(new Gem()); } elfoBufado.AddItem(gauntlet); elfo.ReceiveAttack(elfoBufado.AttackPower); bool expectedIsDead = true; Assert.AreEqual(elfo.IsDead, expectedIsDead); }
public void TestCharacterWithMagicAttackPower7() { Elf elf = new Elf("Elf"); int firstExpected = 0; Assert.AreEqual(firstExpected, elf.AttackPower); Magic magic = new Magic(); elf.AddItem(magic); int secondExpected = 80; Assert.AreEqual(secondExpected, elf.AttackPower); }
/// <summary> /// Tries to attack gameObject, if we can't we move to it's intercept location /// </summary> /// <param name="elf"></param> /// <param name="target"></param> public static void TryAttack(Elf elf, GameObject target) { if (target == null) { return; } if (elf.InAttackRange(target)) { elf.Attack(target); } else { elf.MoveToIntercept(target); } }
public static MemoryStream ErzeugeElfBogen(Elf elf) { var assembly = typeof(PdfCreator).Assembly; using var elfBogen = assembly.GetManifestResourceStream("DccCharCreator.pdf.Resources.DCC_Elf_ausfüllbar.pdf"); using var pdf = PdfReader.Open(elfBogen); SetNeedAppearances(pdf); FillElf(elf, pdf.AcroForm); var stream = new MemoryStream(); pdf.Save(stream, false); pdf.Dispose(); return(stream); }
public void EnoughAttackShouldKill() { Elf attacker1 = new Elf(100, "attacker1"); Elf attacker2 = new Elf(100, "attacker2"); Item theAdminsSword = new Item("The admin sword", 1000, 1000); attacker1.AddItem(theAdminsSword); attacker2.AddItem(testingItem); attacker2.RecieveAttack(attacker1.GetCharacterAttack()); int expected = 0; Assert.AreEqual(expected, attacker2.Health); Assert.True(attacker2.IsDead); }
static void Main(string[] args) { Console.WriteLine("Wonderful World of Elves!"); Elf albert = new Elf("Fat Albert", 576, 5.76, "122 Shelf Ln."); albert.PrintInfo(); Console.WriteLine(albert.Height); albert.PrintInfo(); Keebler dhaval = new Keebler("Dhaval", 450, 3.45); dhaval.PrintInfo(); NorthPole mitch = new NorthPole("Mitch", 150, 4.67); mitch.PrintInfo(); Warrior Ramar = new Warrior("Ra'mar", 700, 7.6, "Darkness"); while (!albert.IsDead) { Ramar.Attack(albert); } Ramar.AddWeapon("Tin of Popcorn Skulls", 30); Ramar.AddWeapon("Pine Tree Bazooka", 50); Warrior Nibbles = new Warrior("Mr. Nibbles", 400, 3.5, "Revenge Lane"); Nibbles.AddWeapon("Tinsle Tosser", 70); while (!Nibbles.IsDead && !Ramar.IsDead) { Random rand = new Random(); int dice = rand.Next(0, 20); if (dice % 2 == 0) { Nibbles.Attack(Ramar); } else { Ramar.Attack(Nibbles); } } }
private float GetScore(VirtualGame virtualGame, Dictionary <int, FutureLocation> myFutureElfLocations, Dictionary <int, GameObject> enemyGameObjects) { float score = 0; while (myFutureElfLocations.Count > 0 && enemyGameObjects.Count > 0) { float bestScore = 0; bool iterated = false; int myElfUniqueId = -1; int enemyGameObjectUniqueId = -1; foreach (KeyValuePair <int, FutureLocation> myFutureElfLocation in myFutureElfLocations) { Location elfLocation = myFutureElfLocation.Value.GetFutureLocation(); foreach (KeyValuePair <int, GameObject> enemyGameObjectPair in enemyGameObjects) { float tempScore = GetPairScore(enemyGameObjectPair, elfLocation); if (!iterated || tempScore > bestScore) { iterated = true; bestScore = tempScore; myElfUniqueId = myFutureElfLocation.Key; enemyGameObjectUniqueId = enemyGameObjectPair.Key; } } } if (bestScore > 0 && virtualGame.futureSpeedUpSpells.ContainsKey(myElfUniqueId)) { Elf myElf = myFutureElfLocations[myElfUniqueId].GetElf(); GameObject enemyGameObject = enemyGameObjects[enemyGameObjectUniqueId]; float dist = myElf.Distance(enemyGameObject); if (dist - distanceTarget > Constants.Game.ElfMaxSpeed * 6) { score += 1; } } myFutureElfLocations.Remove(myElfUniqueId); enemyGameObjects.Remove(enemyGameObjectUniqueId); } return(score); }
/// <summary> /// returns the target the elf should go and attack. exceptions are ignored /// </summary> /// <param name="e"> elf object </param> /// <param name="exceptions"></param> /// <returns></returns> public static GameObject GetMoveTarget(this Elf e, params GameObject[] exceptions) { IEnumerable <GameObject> allTargets = ((GameObject[])GameState.Game.GetEnemyPortals()) .Concat(GameState.Game.GetEnemyManaFountains()) .Concat(GameState.EnemyLivingElves); return((from target in allTargets let attackLocation = e.GetAttackLocation(target) where !exceptions.Contains(target) && (!(target is Elf) || target.CurrentHealth <= e.CurrentHealth) orderby LocationFinder.GetPossibleAttackers(e, attackLocation, exceptions: target).Count, e.Distance(attackLocation), target is Portal ? target.Distance(GameState.MyCastle) : int.MaxValue, target is ManaFountain ? 0 : 1, target.CurrentHealth select target).FirstOrDefault()); }
protected override void OnSetModel(ref object model) { var g = (LinksGroup)model; groupName.text = g.name; groupKey.text = g.key.ToUpper(); link = g.link; model = g.link; Elf.With(GetComponent <ContainerListView>(), l => l.GetComponent <ContainerListView>().AddRange(link.ByElements().Skip(1)), l => links = l.gameObject ); Refresh(); }
public void TestElfCreation3() { int result = 0; Elf Fran = new Elf("Francisco"); int health = Fran.Health; foreach (IItem item in Fran.Items) { if (item is Robes) { result += 1; } } Assert.AreEqual(120, health); Assert.AreEqual(1, result); }
static void Main(string[] args) { Elf jingle = new Elf("Jingle", 6, 10, 18); Elf dash = new Elf("Dash", 7, 10, 1); Elf bubbles = new Elf("Bubbles", 8, 12, 10); Elf sparkle = new Elf("Sparkle", 10, 11, 17); Elf cookie = new Elf("Cookie", 11, 16, 4); Elf frosty = new Elf("Frosty", 11, 14, 8); Elf twinkle = new Elf("Twinkle", 13, 14, 22); Elf jangle = new Elf("Jangle", 13, 18, 15); Elf spunky = new Elf("Spunky", 15, 22, 1); Elf sunny = new Elf("Sunny", 14, 20, 12); Elf happy = new Elf("Happy", 16, 19, 13); List <Elf> elves = new List <Elf>() { jingle, dash, bubbles, sparkle, cookie, frosty, twinkle, jangle, spunky, sunny, happy }; int outCandy = 0; int peakOut = 0; int peakHour = 0; for (int i = 6; i < 22; i++) { foreach (Elf elf in elves) { if (elf.TimeIn == i) { //add to current outCandy outCandy += elf.CandyConsumed; } if (elf.TimeOut == i) { //decrement outCandy outCandy -= elf.CandyConsumed; } } System.Console.WriteLine("At " + i + " there is " + outCandy + " pieces of candy out"); if (outCandy > peakOut) { peakOut = outCandy; peakHour = i; } } System.Console.WriteLine(peakOut + " candy out at " + peakHour); }
public void TestAsignarRobes() { elf = new Elf("El elfo"); Robes expectedRobes = new Robes(); Robes robes = null; foreach (IItem item in elf.Items) { if (item is Robes) { robes = (Robes)item; expectedRobes = (Robes)item; } } Assert.AreEqual(expectedRobes, robes); }
public int ArrayPoolW() { for (int i = 0; i < N; i++) { _menArray[i] = new Man(0, 0, i, i); } for (int i = 0; i < N; i++) { _elvesArray[i] = new Elf(0, 0, i, i); } for (int i = 0; i < N; i++) { _dwarvesArray[i] = new Dwarf(0, 0, i); } return(_menArray.Length + _elvesArray.Length + _dwarvesArray.Length); }
public Elf Closest_Elf_to_Portal(Elf[] f, Portal w, Game game) { Elf closest = null; if (f.Length != 0) { closest = f[0]; foreach (var p in f) { if (w.Distance(p) < closest.Distance(p)) { closest = p; } } } return(closest); }
public IActionResult Pdf(int seed, int character, Klasse klasse, int stufe, Gesinnung gesinnung) { MemoryStream ms = null; switch (klasse) { case Klasse.Dieb: var dieb = new Dieb(seed, character, stufe, gesinnung); ms = PdfCreator.ErzeugeDiebBogen(dieb); break; case Klasse.Elf: var elf = new Elf(seed, character, stufe, gesinnung); ms = PdfCreator.ErzeugeElfBogen(elf); break; case Klasse.Halbling: var halbling = new Halbling(seed, character, stufe, gesinnung); ms = PdfCreator.ErzeugeHalblingBogen(halbling); break; case Klasse.Kleriker: var kleriker = new Kleriker(seed, character, stufe, gesinnung); ms = PdfCreator.ErzeugeKlerikerBogen(kleriker); break; case Klasse.Krieger: var krieger = new Krieger(seed, character, stufe, gesinnung); ms = PdfCreator.ErzeugeKriegerBogen(krieger); break; case Klasse.Zauberkundiger: var zauberkundiger = new Zauberkundiger(seed, character, stufe, gesinnung); ms = PdfCreator.ErzeugeZauberkundigerBogen(zauberkundiger); break; case Klasse.Zwerg: var zwerg = new Zwerg(seed, character, stufe, gesinnung); ms = PdfCreator.ErzeugeZwergBogen(zwerg); break; } ; return(File(ms, "application/pdf", $"Charakterbogen_{klasse}_{seed}_{character}.pdf")); }
private ICard InitalizeCardAsObject(string id, string name, float damage, string elementType, string cardType) { if (cardType == CardType.Dragon.ToString()) { var card = new Dragon(id, name, damage, (Element)Enum.Parse(typeof(Element), elementType)); return(card); } else if (cardType == CardType.Elf.ToString()) { var card = new Elf(id, name, damage, (Element)Enum.Parse(typeof(Element), elementType)); return(card); } else if (cardType == CardType.Goblin.ToString()) { var card = new Goblin(id, name, damage, (Element)Enum.Parse(typeof(Element), elementType)); return(card); } else if (cardType == CardType.Knight.ToString()) { var card = new Knight(id, name, damage, (Element)Enum.Parse(typeof(Element), elementType)); return(card); } else if (cardType == CardType.Kraken.ToString()) { var card = new Kraken(id, name, damage, (Element)Enum.Parse(typeof(Element), elementType)); return(card); } else if (cardType == CardType.Ork.ToString()) { var card = new Ork(id, name, damage, (Element)Enum.Parse(typeof(Element), elementType)); return(card); } else if (cardType == CardType.Wizzard.ToString()) { var card = new Wizzard(id, name, damage, (Element)Enum.Parse(typeof(Element), elementType)); return(card); } else if (cardType == CardType.Spell.ToString()) { var card = new Spell(id, name, damage, (Element)Enum.Parse(typeof(Element), elementType)); return(card); } return(null); }
public void NoItemForExchangeEncounterTest() { Dwarf gimli = new Dwarf(); Elf legolas = new Elf(); BasicSword sword = new BasicSword(); try { ExchangeEncounter encounter = new ExchangeEncounter(gimli, legolas, sword.Name); encounter.PlayEncounter(); Assert.Fail(); } //Si hay una excepción al tratar de intercambiar un item que no se tiene, se pasa al bloque catch y por ende se cumple el test. catch { Assert.Pass(); } }
public override void Populate() { var elf = new Elf(); var human = new Human(); var animal1 = new Animal(); var animal2 = new Animal(); var beast = new Beast(); Creatures = new Creature[] { elf, human, animal1, animal2, beast }; foreach (var creature in Creatures) { creature.Speak(); } }
public override HandlerRequest Handle(HandlerRequest handlerRequest) { String cleanLine = handlerRequest.Line.Replace("\n", ""); String[] typeSplit = cleanLine.Split('-'); if (typeSplit[0] != "Elf") { return(nextHandler?.Handle(handlerRequest)); } String[] values = typeSplit[1].Split(','); Elf elf = new Elf(values[0], Convert.ToInt32(values[1]), Convert.ToInt32(values[2]), Convert.ToInt32(values[3])); handlerRequest.ListOfCharacter.Add(elf); return(handlerRequest); }
public void TakePresentsFromOpposite() { var alternator = (_numberOfElves + 1) % 2; var oppositeElf = _currentElf.Skip(_numberOfElves / 2); while (_currentElf.Next != _currentElf) { // Steal present and delete it. _currentElf.Presents += oppositeElf.Presents; oppositeElf.Delete(); // update opposite alternator = ++alternator % 2; oppositeElf = oppositeElf.Skip(alternator + 1); _currentElf = _currentElf.Next; } }
/// <summary> /// Creates a linked list, then iterates through it until one element remains, eliminating the node directly opposite it /// </summary> /// <param name="runTestCase">if true, uses test input to validate success, else, uses puzzle input</param> /// <returns>id of the Elf with all presents</returns> public int PartTwoFaster(bool runTestCase) { Elf root = new Elf { id = 1 }; Elf current = root; Elf target = null; int size = PUZZLE_INPUT; if (runTestCase) { size = TEST_INPUT; } int count = size; for (int i = 1; i < size + 1; i++) { current.next = (i == size) ? root : new Elf { id = i + 1, prev = current }; current = current.next; if (i == size / 2) { target = current; } } root.prev = current; while (current.next != current) { // removes target from linked list and links the surrounding nodes target.prev.next = target.next; target.next.prev = target.prev; // changes target target = count % 2 == 1 ? target.next.next : target.next; count--; current = current.next; } return(current.id); }
private void searchIDBtn_Click(object sender, EventArgs e) { PrevBtn.Visible = false; NextBtn.Visible = false; if (Int32.TryParse(idTxtBx.Text, out int result)) { Person person = personLogic.GetPerson(result); if (person == null) { MessageBox.Show("Person with ID was not found", "404: Not Found"); } else { currentRace = person.RaceType.ToLower(); if (person.RaceType == "elf") { currentElf = elfLogic.GetElf(result); } if (person.RaceType == "dwarf") { currentDwarf = dwarfLogic.GetDwarf(result); } if (person.RaceType == "human") { currentHuman = humanLogic.GetHuman(result); } if (person.RaceType == "wizard") { currentWizard = wizardLogic.GetWizard(result); } if (person.RaceType.ToLower() == "hobbit") { currentHobbit = hobbitLogic.GetHobbit(result); } Display(); } } else { MessageBox.Show("ID must be a number!", "Error"); } }
public override float GetScore(VirtualGame virtualGame) { float score = 0; foreach (GameObject attacker in virtualGame.GetAllFutureAttacks()) { if (attacker is Elf) { Elf elf = (Elf)attacker; if (elf.Invisible) { score--; } } } return(score); }
public ElfDetailsViewModel(Elf elf, double ratio, IEnumerable <Reindeer> reindeer, IEnumerable <Present> presents) { this.ID = elf.ID; this.Name = elf.Name; this.YearsOnJob = elf.YearsOnJob; this.Salary = elf.Salary; this.Rank = elf.Rank; this.Reindeer = reindeer; this.Ratio = ratio; var presentViewModels = new List <PresentDetailsViewModel>(); foreach (var present in presents) { presentViewModels.Add(new PresentDetailsViewModel(present)); } this.Presents = presentViewModels; }
public static Hero MakeHero(string heroType) { Hero generatedHero = null; if (heroType == HeroFactory.Human) { generatedHero = new Human(); } else if (heroType == HeroFactory.Elf) { generatedHero = new Elf(); } else if (heroType == HeroFactory.Dwarf) { generatedHero = new Dwarf(); } else { throw new InvalidHeroException("Entered hero is invalid!"); } return generatedHero; }
protected IEnumerable<Elf.SectionHeader> SectionHeadersWithFlag(Elf.SectionHeader.FlagsSet Flag) { return SectionHeaders.Where(SectionHeader => SectionHeader.Flags.HasFlag(Flag)); }
public Stream SectionHeaderMemoryStream(Elf.SectionHeader SectionHeader) { return this.MemoryStream.SliceWithLength(BaseAddress + SectionHeader.Address, SectionHeader.Size); }
public Stream SectionHeaderFileStream(Elf.SectionHeader SectionHeader) { return this.FileStream.SliceWithLength(SectionHeader.Offset, SectionHeader.Size); }
public Stream ProgramHeaderFileStream(Elf.ProgramHeader ProgramHeader) { return this.FileStream.SliceWithLength(ProgramHeader.Offset, ProgramHeader.FileSize); }
public RelocCommand(Word source, Word target, Elf.Reloc reloc) : base((Ids)reloc, source) { Target = target; }