public void FoodProductionTest() { Harvest harvest = new Harvest(); Calendar calendar = new Calendar(); Province province = new Province(); Population startPopulation = new Population().Add(1000); Food food = harvest.FoodProduction(calendar, province); food.Rice.ShouldBe(0); province = province.Add(startPopulation); calendar.Month.ShouldBe(1); food = harvest.FoodProduction(calendar, province); food.Rice.ShouldBe(0); calendar = calendar.Add(4); food = harvest.FoodProduction(calendar, province); food.Rice.ShouldBeGreaterThan(0); calendar = new Calendar(); calendar.Month.ShouldBe(1); food = new Food(); food.Rice.ShouldBe(0); for (int month = 0; month < 12; month++) { food = food.Add(harvest.FoodProduction(calendar, province)); calendar = calendar.Add(1); } food.Rice.ShouldBeGreaterThan(12 * province.Population.Adults); }
public void FoodConsumptionTest() { Granary granary = new Granary(); Calendar calendar = new Calendar(); Province province = new Province(); Population startPopulation = new Population().Add(1000); Food foodStock = new Food(); foodStock = foodStock.Add(500); Food foodConsumption = granary.FoodConsumption(calendar, province); foodConsumption.Rice.ShouldBe(0); province = province.Add(startPopulation); province = province.Add(foodStock); calendar.Month.ShouldBe(1); foodConsumption = granary.FoodConsumption(calendar, province); foodConsumption.Rice.ShouldNotBe(0); foodConsumption.Rice.ShouldBeLessThanOrEqualTo(province.Food.Rice); calendar.Add(4); foodConsumption = granary.FoodConsumption(calendar, province); foodConsumption.Rice.ShouldBeGreaterThan(0); foodConsumption.Rice.ShouldBeLessThanOrEqualTo(province.Food.Rice); calendar = new Calendar(); calendar.Month.ShouldBe(1); foodConsumption = new Food(); foodConsumption.Rice.ShouldBe(0); foodStock = foodStock.Add(50000); province = province.Add(foodStock); for (int month = 0; month < 12; month++) { foodConsumption = foodConsumption.Add(granary.FoodConsumption(calendar, province)); calendar.Add(1); } foodConsumption.Rice.ShouldBeGreaterThan(12 * province.Population.Adults); foodConsumption.Rice.ShouldBeLessThanOrEqualTo(province.Food.Rice); }
public void AddTest() { Food food = new Food(); food = food.Add(42); food.Rice.ShouldBe(42); Food foodAdd = new Food(); foodAdd = foodAdd.Add(54); food = food.Add(foodAdd); food.Rice.ShouldBe(96); foodAdd.Rice.ShouldBe(54); }
public void RemoveTest() { Food food = new Food(); Food foodToRemove = new Food(); food = food.Add(42); foodToRemove = foodToRemove.Add(30); food = food.Remove(foodToRemove); food.Rice.ShouldBe(12); }
public void RemoveParameterTest() { Food food = new Food(); Should.Throw <ArgumentNullException>(() => { food.Remove(null); }).Message.ShouldContain("food"); Food foodToRemove = new Food(); foodToRemove = foodToRemove.Add(1); Should.Throw <ArgumentOutOfRangeException>(() => { food.Remove(foodToRemove); }).Message.ShouldContain("food"); }
private void AddFood() { Random random = new Random(); if (Food == null) { Food = new List<Pixel> { }; } else { Food.Clear(); } Food.Add(new Pixel { x = random.Next(Canvas.width), y = random.Next(Canvas.height) }); }
public void PlaceFood() { var point = new Point(StaticRandom.Next(Width), StaticRandom.Next(Height)); int count = 0; while (this[point] != Content.EMPTY) { if (++count > 1000) { throw new Exception(); } point = new Point(StaticRandom.Next(Width), StaticRandom.Next(Height)); } this[point] = Content.FOOD; Food.Add(point); }
public void AddTest() { Population population = new Population().Add(42); Province province = new Province(); province = province.Add(population); province.Population.Adults.ShouldBe(42); Food food = new Food(); food = food.Add(42); province.Food.Rice.ShouldBe(0); province = province.Add(food); province.Food.Rice.ShouldBe(42); }
public static void PlaceRandomFood() { Collection <Vector2Int> EligibleSpots = new Collection <Vector2Int>(); for (int i = TileIndexMin; i <= TileIndexMax; i++) { for (int j = TileIndexMin; j <= TileIndexMax; j++) { if (!CollisionMap[j, i]) { EligibleSpots.Add(new Vector2Int(i, j)); } } } Vector2Int SelectedSpot = EligibleSpots[UnityEngine.Random.Range(0, EligibleSpots.Count)]; Food.Add(SelectedSpot); CollisionMap[SelectedSpot.y, SelectedSpot.x] = true; }
public void TickTest() { World world = new World(); Province province = new Province(); Population population = new Population().Add(1000); Food food = new Food(); food = food.Add(12000); province = province.Add(population); province = province.Add(food); world = world.Add(province); for (int month = 0; month < 12; month++) { world = world.Tick(); } province = world.Provinces.Single(); province.Population.Adults.ShouldBeGreaterThan(population.Adults); province.Food.Rice.ShouldBeGreaterThan(food.Rice); }
private void ProcessResponse(GameBoardDto gameBoardDto) { Snake.Clear(); foreach (Point point in gameBoardDto.Snake) { ViewPoint processPoint = new ViewPoint(ParseCoordinate(point.X), ParseCoordinate(point.Y), rectangleSize, margin); Snake.Add(processPoint); } Food.Clear(); foreach (Point point in gameBoardDto.Food) { ViewPoint processPoint = new ViewPoint(ParseCoordinate(point.X), ParseCoordinate(point.Y), rectangleSize, margin); Food.Add(processPoint); } GameException = String.Empty; }
public void AddFood(int col, int row) { Food.Add(new Coordinates(col, row)); }
// Load the monster.txt drop file. private void LoadDropFile(bool edit) { var lines = (edit == false) ? File.ReadAllLines(Path.Combine(Settings.DropPath, String.Format("{0}.txt", listBoxMonsters.SelectedItem)), Encoding.GetEncoding("euc-kr")) : textBoxDropList.Lines; for (int i = 0; i < lines.Length; i++) { if (lines[i].StartsWith(";Gold")) { if (lines[i + 1].StartsWith("1/")) { var workingLine = lines[i + 1].Split(' '); GoldOdds = workingLine[0].Remove(0, 2); Gold = workingLine[2]; break; } else { GoldOdds = "0"; Gold = "0"; } } } string[] Headers = new string[34] { ";Weapons", ";Armours", ";Helmets", ";Necklaces", ";Bracelets", ";Rings", ";Amulets", ";Belts", ";Boots", ";Stones", ";Torches", ";Potions", ";Ores", ";Meat", ";Crafting Materials", ";Scrolls", ";Gems", ";Mount", ";Books", ";Nothing", ";Script", ";Reins", ";Bells", ";Saddle", ";Ribbon", ";Mask", ";Food", ";Hook", ";Float", ";Bait", ";Finder", ";Reel", ";Fish", ";Quest" }; for (int i = 0; i < Headers.Length; i++) { for (int j = 0; j < lines.Length; j++) { if (lines[j].StartsWith(Headers[i])) { for (int k = j + 1; k < lines.Length; k++) { if (lines[k].StartsWith(";")) { break; } var workingLine = lines[k].Split(' '); if (workingLine.Length < 2) { continue; } var quest = ""; if (workingLine.Length > 2 && workingLine[2] == "Q") { quest = workingLine[2]; } DropItem newDropItem = new DropItem { Odds = workingLine[0], Name = workingLine[1], Quest = quest }; switch (i) { case 0: Weapon.Add(newDropItem); break; case 1: Armour.Add(newDropItem); break; case 2: Helmet.Add(newDropItem); break; case 3: Necklace.Add(newDropItem); break; case 4: Bracelet.Add(newDropItem); break; case 5: Ring.Add(newDropItem); break; case 6: Amulet.Add(newDropItem); break; case 7: Belt.Add(newDropItem); break; case 8: Boot.Add(newDropItem); break; case 9: Stone.Add(newDropItem); break; case 10: Torch.Add(newDropItem); break; case 11: Potion.Add(newDropItem); break; case 12: Ore.Add(newDropItem); break; case 13: Meat.Add(newDropItem); break; case 14: CraftingMaterial.Add(newDropItem); break; case 15: Scrolls.Add(newDropItem); break; case 16: Gem.Add(newDropItem); break; case 17: Mount.Add(newDropItem); break; case 18: Book.Add(newDropItem); break; case 19: Nothing.Add(newDropItem); break; case 20: Script.Add(newDropItem); break; case 21: Reins.Add(newDropItem); break; case 22: Bells.Add(newDropItem); break; case 23: Saddle.Add(newDropItem); break; case 24: Ribbon.Add(newDropItem); break; case 25: Mask.Add(newDropItem); break; case 26: Food.Add(newDropItem); break; case 27: Hook.Add(newDropItem); break; case 28: Float.Add(newDropItem); break; case 29: Bait.Add(newDropItem); break; case 30: Finder.Add(newDropItem); break; case 31: Reel.Add(newDropItem); break; case 32: Fish.Add(newDropItem); break; case 33: Quest.Add(newDropItem); break; default: break; } } } } } }
// Add the item to the drop list private void buttonAdd_Click(object sender, EventArgs e) { int dropChance; int.TryParse(textBoxItemOdds.Text, out dropChance); if (dropChance < 1) { dropChance = 1; } string quest = QuestOnlyCheckBox.Checked ? "Q" : ""; try { switch (tabControlSeperateItems.SelectedTab.Tag.ToString()) { case "Weapon": Weapon.Add(new DropItem { Name = listBoxWeapon.SelectedItem.ToString().Replace(" ", string.Empty), Odds = string.Format("1/{0}", dropChance), Quest = quest }); break; case "Armour": Armour.Add(new DropItem { Name = listBoxArmour.SelectedItem.ToString().Replace(" ", string.Empty), Odds = string.Format("1/{0}", dropChance), Quest = quest }); break; case "Helmet": Helmet.Add(new DropItem { Name = listBoxHelmet.SelectedItem.ToString().Replace(" ", string.Empty), Odds = string.Format("1/{0}", dropChance), Quest = quest }); break; case "Necklace": Necklace.Add(new DropItem { Name = listBoxNecklace.SelectedItem.ToString().Replace(" ", string.Empty), Odds = string.Format("1/{0}", dropChance), Quest = quest }); break; case "Bracelet": Bracelet.Add(new DropItem { Name = listBoxBracelet.SelectedItem.ToString().Replace(" ", string.Empty), Odds = string.Format("1/{0}", dropChance), Quest = quest }); break; case "Ring": Ring.Add(new DropItem { Name = listBoxRing.SelectedItem.ToString().Replace(" ", string.Empty), Odds = string.Format("1/{0}", dropChance), Quest = quest }); break; case "Amulet": Amulet.Add(new DropItem { Name = listBoxAmulet.SelectedItem.ToString().Replace(" ", string.Empty), Odds = string.Format("1/{0}", dropChance), Quest = quest }); break; case "Belt": Belt.Add(new DropItem { Name = listBoxBelt.SelectedItem.ToString().Replace(" ", string.Empty), Odds = string.Format("1/{0}", dropChance), Quest = quest }); break; case "Boots": Boot.Add(new DropItem { Name = listBoxBoot.SelectedItem.ToString().Replace(" ", string.Empty), Odds = string.Format("1/{0}", dropChance), Quest = quest }); break; case "Stone": Stone.Add(new DropItem { Name = listBoxStone.SelectedItem.ToString().Replace(" ", string.Empty), Odds = string.Format("1/{0}", dropChance), Quest = quest }); break; case "Torch": Torch.Add(new DropItem { Name = listBoxTorch.SelectedItem.ToString().Replace(" ", string.Empty), Odds = string.Format("1/{0}", dropChance), Quest = quest }); break; case "Potion": Potion.Add(new DropItem { Name = listBoxPotion.SelectedItem.ToString().Replace(" ", string.Empty), Odds = string.Format("1/{0}", dropChance), Quest = quest }); break; case "Ore": Ore.Add(new DropItem { Name = listBoxOre.SelectedItem.ToString().Replace(" ", string.Empty), Odds = string.Format("1/{0}", dropChance), Quest = quest }); break; case "Meat": Meat.Add(new DropItem { Name = listBoxMeat.SelectedItem.ToString().Replace(" ", string.Empty), Odds = string.Format("1/{0}", dropChance), Quest = quest }); break; case "CraftingMaterial": CraftingMaterial.Add(new DropItem { Name = listBoxCraftingMaterial.SelectedItem.ToString().Replace(" ", string.Empty), Odds = string.Format("1/{0}", dropChance) }); break; case "Scroll": Scrolls.Add(new DropItem { Name = listBoxScroll.SelectedItem.ToString().Replace(" ", string.Empty), Odds = string.Format("1/{0}", dropChance), Quest = quest }); break; case "Gem": Gem.Add(new DropItem { Name = listBoxGem.SelectedItem.ToString().Replace(" ", string.Empty), Odds = string.Format("1/{0}", dropChance), Quest = quest }); break; case "Mount": Mount.Add(new DropItem { Name = listBoxMount.SelectedItem.ToString().Replace(" ", string.Empty), Odds = string.Format("1/{0}", dropChance), Quest = quest }); break; case "Book": Book.Add(new DropItem { Name = listBoxBook.SelectedItem.ToString().Replace(" ", string.Empty), Odds = string.Format("1/{0}", dropChance), Quest = quest }); break; case "Nothing": Nothing.Add(new DropItem { Name = listBoxNothing.SelectedItem.ToString().Replace(" ", string.Empty), Odds = string.Format("1/{0}", dropChance), Quest = quest }); break; case "Script": Script.Add(new DropItem { Name = listBoxScript.SelectedItem.ToString().Replace(" ", string.Empty), Odds = string.Format("1/{0}", dropChance), Quest = quest }); break; case "Reins": Reins.Add(new DropItem { Name = listBoxReins.SelectedItem.ToString().Replace(" ", string.Empty), Odds = string.Format("1/{0}", dropChance), Quest = quest }); break; case "Bells": Bells.Add(new DropItem { Name = listBoxBells.SelectedItem.ToString().Replace(" ", string.Empty), Odds = string.Format("1/{0}", dropChance), Quest = quest }); break; case "Saddle": Saddle.Add(new DropItem { Name = listBoxSaddle.SelectedItem.ToString().Replace(" ", string.Empty), Odds = string.Format("1/{0}", dropChance), Quest = quest }); break; case "Ribbon": Ribbon.Add(new DropItem { Name = listBoxRibbon.SelectedItem.ToString().Replace(" ", string.Empty), Odds = string.Format("1/{0}", dropChance), Quest = quest }); break; case "Mask": Mask.Add(new DropItem { Name = listBoxMask.SelectedItem.ToString().Replace(" ", string.Empty), Odds = string.Format("1/{0}", dropChance), Quest = quest }); break; case "Food": Food.Add(new DropItem { Name = listBoxFood.SelectedItem.ToString().Replace(" ", string.Empty), Odds = string.Format("1/{0}", dropChance), Quest = quest }); break; case "Hook": Hook.Add(new DropItem { Name = listBoxHook.SelectedItem.ToString().Replace(" ", string.Empty), Odds = string.Format("1/{0}", textBoxItemOdds.Text), Quest = quest }); break; case "Float": Float.Add(new DropItem { Name = listBoxFloat.SelectedItem.ToString().Replace(" ", string.Empty), Odds = string.Format("1/{0}", textBoxItemOdds.Text), Quest = quest }); break; case "Bait": Bait.Add(new DropItem { Name = listBoxBait.SelectedItem.ToString().Replace(" ", string.Empty), Odds = string.Format("1/{0}", textBoxItemOdds.Text), Quest = quest }); break; case "Finder": Finder.Add(new DropItem { Name = listBoxFinder.SelectedItem.ToString().Replace(" ", string.Empty), Odds = string.Format("1/{0}", textBoxItemOdds.Text), Quest = quest }); break; case "Reel": Reel.Add(new DropItem { Name = listBoxReel.SelectedItem.ToString().Replace(" ", string.Empty), Odds = string.Format("1/{0}", textBoxItemOdds.Text), Quest = quest }); break; case "Fish": Fish.Add(new DropItem { Name = listBoxFish.SelectedItem.ToString().Replace(" ", string.Empty), Odds = string.Format("1/{0}", textBoxItemOdds.Text), Quest = quest }); break; case "Quest": Quest.Add(new DropItem { Name = listBoxQuest.SelectedItem.ToString().Replace(" ", string.Empty), Odds = string.Format("1/{0}", textBoxItemOdds.Text), Quest = quest }); break; } UpdateDropFile(); } catch { //No item selected when trying to add an item to the drop } }
public void AddParameterTest() { Food food = new Food(); Should.Throw <ArgumentNullException>(() => { food.Add(null); }).Message.ShouldContain("food"); }