public void A_goose_and_Saddle_of_the_same_size_should_be_compatible() { //Arrange var bunny = new Rabbit(); var emotionalState = "Pooped-filled Anger"; var largeGoose = new Goose { Name = "Tedothy", Sex = Sex.Male, Size = Size.Large, EmotinalState = emotionalState }; var largeSaddle = new Saddle { Size = Size.Large, InUse = false }; bunny.OwnedSaddle.Add(largeSaddle); bunny.OwnedGeese.Add(largeGoose); //Act // ctrl. to create a method in Rabbit.cs bunny.SaddleThatGoose(largeGoose, largeSaddle); //Assert Assert.Same(largeSaddle, largeGoose.Saddle); Assert.True(largeSaddle.InUse); Assert.Equal(emotionalState, largeGoose.EmotinalState); }
public void A_goose_and_Saddle_that_are_not_same_size_should_not_be_compatible() { //Arrange var bunny = new Rabbit(); var largeGoose = new Goose { Name = "Tedothy", Sex = Sex.Male, Size = Size.Large }; var smallSaddle = new Saddle { Size = Size.Small, InUse = false }; bunny.OwnedSaddle.Add(smallSaddle); bunny.OwnedGeese.Add(largeGoose); //Act bunny.SaddleThatGoose(largeGoose, smallSaddle); //Assert Assert.NotSame(smallSaddle, largeGoose.Saddle); // what we are not expecting, what should happen Assert.False(smallSaddle.InUse); Assert.Equal("Distraught by fat shaming", largeGoose.EmotinalState); }
public void A_goose_that_is_saddled_should_not_accept_another_saddle() { //Arrange var bunny = new Rabbit(); var emotionalState = "Pooped-filled Anger"; var orignalSaddle = new Saddle(); var largeGoose = new Goose { Name = "Tedothy", Sex = Sex.Male, Size = Size.Large, EmotinalState = emotionalState, Saddle = orignalSaddle }; var largeSaddle = new Saddle { Size = Size.Large, InUse = false }; bunny.OwnedSaddle.Add(largeSaddle); bunny.OwnedGeese.Add(largeGoose); //Act bunny.SaddleThatGoose(largeGoose, largeSaddle); //Assert // Assert.NotEqual(largeSaddle, largeGoose.Saddle); Assert.Equal(orignalSaddle, largeGoose.Saddle); Assert.Equal("Exhausted", largeGoose.EmotinalState); // the goose should be exhausted }
private static void appendEquipment(Animal animal, string[] choice) { IEquipment equipment = null; if ("Bridle".Equals(choice[2])) { equipment = new Bridle(); } else if ("Halter".Equals(choice[2])) { equipment = new Halter(); } else if ("Saddle".Equals(choice[2])) { equipment = new Saddle(); } else if ("Saddle Blanket".Equals(choice[2] + " " + choice[3])) { equipment = new SaddleBlanket(); } else if ("Tether".Equals(choice[2])) { equipment = new Tether(); } animal.Equipments.Add(equipment); }
public IActionResult ProcureGooseSaddle(int id, Saddle saddle) { var rabbit = _storage.GetById(id); if (rabbit == null) { return(NotFound()); } rabbit.OwnedSaddles.Add(saddle); return(Ok()); }
[HttpPut("{id}/saddles")] // updating a saddle on a rabbit public IActionResult ProcureGooseSaddle(int id, Saddle saddle) { var rabbit = _storage.GetById(id); // check to see if a rabbit is not null so it wont throw an excecption error if (rabbit == null) { return(NotFound()); } rabbit.OwnedSaddle.Add(saddle); return(Ok()); }
protected static void OnLotChanged(Event e) { Sim sim = e.Actor as Sim; Lot lot = e.TargetObject as Lot; if (sim.IsHuman) { if (Dresser.Settings.mSwitchFormal) { if ((!sim.IsSelectable) || (Dresser.Settings.mTransitionAffectActive)) { if ((lot != null) && (lot != sim.LotHome) && (!lot.IsWorldLot) && (sim.CurrentOutfitCategory == OutfitCategories.Formalwear)) { if (sim.IsOutside) { CommonSpace.Helpers.SwitchOutfits.SwitchNoSpin(sim, Sim.ClothesChangeReason.GoingOutside); } else { CommonSpace.Helpers.SwitchOutfits.SwitchNoSpin(sim, Sim.ClothesChangeReason.GoingOffLot); } } } } SimDescription simDesc = sim.SimDescription; if ((sim.IsOutside) && (Dresser.Settings.ShouldCheck(simDesc))) { int count = SavedOutfit.Cache.CountOutfits(simDesc, false); if (count != Dresser.Settings.GetOutfitCount(simDesc)) { CheckOutfitTask.Controller.PerformCheck(simDesc); Dresser.Settings.SetOutfitCount(simDesc, count); } } } else if ((sim.IsHorse) && (SimTypes.IsService(sim.SimDescription))) { if (Saddle.IsOutfitCategorySaddled(sim.CurrentOutfitCategory)) { BeingRiddenPosture posture = sim.Posture as BeingRiddenPosture; if (posture == null) { CommonSpace.Helpers.SwitchOutfits.SwitchNoSpin(sim, Sim.ClothesChangeReason.GoingToBathe); } } } }
public override bool Run() { try { if (!IntroTutorial.IsRunning || IntroTutorial.AreYouExitingTutorial()) { SocialJig = GlobalFunctions.CreateObjectOutOfWorld("horseMountDismountJig", ProductVersion.EP5) as SocialJig; SocialJig.RegisterParticipants(Actor, Target); bool succeeded = false; if (!BeginSocialInteraction(new SocialInteractionB.Definition(null, Saddle.LocalizeString(Target.IsFemale, "HaveOutfitEdited", new object[0x0]), false), true, false)) { return(succeeded); } StandardEntry(); if (Responder.Instance.OptionsModel.SaveGameInProgress) { BeginCommodityUpdates(); EndCommodityUpdates(true); StandardExit(); return(true); } mTookSemaphore = GameStates.WaitForInteractionStateChangeSemaphore(Target, ~(ExitReason.Replan | ExitReason.MidRoutePushRequested | ExitReason.ObjectStateChanged | ExitReason.PlayIdle | ExitReason.MaxSkillPointsReached)); if (!mTookSemaphore) { StandardExit(); return(false); } if (Target.IsSelectable) { while ((Sims3.Gameplay.Gameflow.CurrentGameSpeed == Sims3.Gameplay.Gameflow.GameSpeed.Pause) || MoveDialog.InProgress()) { SpeedTrap.Sleep(); } BeginCommodityUpdates(); SimDescription simDescription = Target.SimDescription; if (simDescription == null) { throw new Exception("ChangeOutfit: sim doesn't have a description!"); } CASChangeReporter.Instance.ClearChanges(); new Sims.Dresser().Perform(new GameHitParameters <GameObject>(Target, Target, GameObjectHit.NoHit)); while (GameStates.NextInWorldStateId != InWorldState.SubState.LiveMode) { SpeedTrap.Sleep(); } EndCommodityUpdates(true); /* * if (Target.CurrentOutfitIndex > simDescription.GetOutfitCount(Target.CurrentOutfitCategory)) * { * Target.UpdateOutfitInfo(); * } * * (Responder.Instance.HudModel as Sims3.Gameplay.UI.HudModel).NotifySimChanged(Target.ObjectId); */ StandardExit(); return(true); } StandardExit(); } return(false); } catch (ResetException) { throw; } catch (Exception e) { Common.Exception(Actor, Target, e); } return(false); }
// 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 } }
private void btn_Submit_Click(object sender, RoutedEventArgs e) { Random rand = new Random(); Business.Frame frame = new Business.Frame(); if (rand.Next(0, 2) == 1) { frame.Type = combo_frame_type.Text; frame.Colour = combo_frame_colour.Text; frame.Size = combo_frame_size.Text; } else { MessageBox.Show("Frame OOS: Adding 2 days to Completion Time"); frame.Type = combo_frame_type.Text; frame.Colour = combo_frame_colour.Text; frame.Size = combo_frame_size.Text; duration += 2; } double frameTypeCost = Double.Parse(((ComboBoxItem)combo_frame_type.SelectedItem).Tag.ToString()); double frameColourCost = Double.Parse(((ComboBoxItem)combo_frame_colour.SelectedItem).Tag.ToString()); double frameSizeCost = Double.Parse(((ComboBoxItem)combo_frame_size.SelectedItem).Tag.ToString()); frame.Cost = frameTypeCost + frameColourCost + frameSizeCost; Gears gears = new Gears(); if (rand.Next(0, 2) == 1) { gears.Type = combo_gears.Text; } else { MessageBox.Show("Gears OOS: Adding 2 days to Completion Time"); gears.Type = combo_gears.Text; duration += 2; } gears.Cost = Double.Parse(((ComboBoxItem)combo_gears.SelectedItem).Tag.ToString()); Breaks breaks = new Breaks(); if (rand.Next(0, 2) == 1) { breaks.Type = combo_breaks.Text; } else { MessageBox.Show("Breaks OOS: Adding 2 days to Completion Time"); breaks.Type = combo_breaks.Text; duration += 2; } breaks.Cost = Double.Parse(((ComboBoxItem)combo_breaks.SelectedItem).Tag.ToString()); GroupSet groupSet = new GroupSet(); groupSet.Gears = gears; groupSet.Breaks = breaks; groupSet.Cost = groupSet.calculateGroupSet(gears, breaks); Wheels wheels = new Wheels(); if (rand.Next(0, 2) == 1) { wheels.Type = combo_handlebars.Text; } else { MessageBox.Show("Wheels OOS: Adding 2 days to Completion Time"); wheels.Type = combo_handlebars.Text; duration += 2; } wheels.Cost = Double.Parse(((ComboBoxItem)combo_wheels.SelectedItem).Tag.ToString()); Handlebars handleBars = new Handlebars(); if (rand.Next(0, 2) == 1) { handleBars.Type = combo_handlebars.Text; } else { MessageBox.Show("Handlebars OOS: Adding 2 days to Completion Time"); handleBars.Type = combo_handlebars.Text; duration += 2; } handleBars.Cost = Double.Parse(((ComboBoxItem)combo_handlebars.SelectedItem).Tag.ToString()); Saddle saddle = new Saddle(); if (rand.Next(0, 2) == 1) { saddle.Type = combo_saddle.Text; } else { MessageBox.Show("Saddle OOS: Adding 2 days to Completion Time"); saddle.Type = combo_saddle.Text; duration += 2; } saddle.Cost = Double.Parse(((ComboBoxItem)combo_saddle.SelectedItem).Tag.ToString()); FinishingSet finishingSet = new FinishingSet(); finishingSet.HandleBars = handleBars; finishingSet.Saddle = saddle; finishingSet.Cost = finishingSet.calculateFinishingSet(handleBars, saddle); Bicycle bicycle = new Bicycle(); bicycle.Frame = frame; bicycle.GroupSet = groupSet; bicycle.FinishingSet = finishingSet; bicycle.Cost = bicycle.calculateFinalCost(frame, groupSet, finishingSet, wheels); if (check_warranty.IsChecked == true) { bicycle.Cost += 50.0; } bicycle.Duration = duration; duration = 2; bikeList.Add(bicycle); string output = ""; int bikeNum = 1; double totalCost = 0.0; foreach (Bicycle bike in bikeList) { output += "Bike " + bikeNum + ":\n" + "Cost: " + bike.Cost + "\nCompletion Time: " + bike.Duration + " days.\n\n"; bikeNum++; totalCost += bike.Cost; } MessageBox.Show(output + "\nTotal Cost: " + totalCost); }