public void Chop(Mobile from) { if (from.InRange(this.GetWorldLocation(), 1)) { if (from == m_sower) { from.Direction = from.GetDirectionTo(this); double lumberValue = from.Skills[SkillName.Lumberjacking].Value / 100; if ((lumberValue > .5) && (Utility.RandomDouble() <= lumberValue)) { Lime fruit = new Lime(Utility.Random(m_yield + 2)); from.AddToBackpack(fruit); int cnt = Utility.Random(20) + 1; Log logs = new Log(cnt); from.AddToBackpack(logs); } this.Delete(); from.SendMessage("You chop the plant up"); } else { from.SendMessage("You do not own this plant !!!"); } } else { from.SendLocalizedMessage(500446); } }
public void Constructor_ValidQuality_CorrectProperties() { const int FruitQuality = 85; const string FruitName = nameof(Lime); const string FruitColor = "Green"; var lime = new Lime(FruitQuality); Assert.That(lime.Quality, Is.EqualTo(FruitQuality)); Assert.That(lime.Name, Is.EqualTo(FruitName)); Assert.That(lime.Color, Is.EqualTo(FruitColor)); }
/// <summary> /// Oh no! all the fruits are named the wrong names! /// Fix them, both in the constructor and the FruitSalad.AddX methods! /// </summary> public void FirstExercise() { var pear = new Apple(); var apple = new Pear(); var orange = new Lime(); var lime = new Orange(); // Creat the CustomFruitSaladImplementation var fruitSalad = new FruitSalad(); fruitSalad.AddApple(pear); fruitSalad.AddPear(apple); fruitSalad.AddLime(orange); fruitSalad.AddOrange(lime); }
/// <summary> /// Oh no! We have to implement our own fruit salad. /// Create a class, and give it some AddX() methods for each fruit. /// </summary> public void SecondExercise() { var apple = new Apple(); var pear = new Pear(); var lime = new Lime(); var orange = new Orange(); // Create the CustomFruitSaladImplementation var fruitSalad = new CustomFruitSaladImplementation(); // Implement an AddX for each fruit type above and call it // It doesn't have to do anything // E.g. fruitSalad.AddApple(apple); // fruitSalad.AddPear(pear); }
public void Chop(Mobile from) { if (from.InRange(this.GetWorldLocation(), 1)) { if ((chopTimer == null) || (!chopTimer.Running)) { if ((TreeHelper.TreeOrdinance) && (from.AccessLevel == AccessLevel.Player)) { if (from.Region is Regions.GuardedRegion) { from.CriminalAction(true); } } chopTimer = new TreeHelper.ChopAction(from); Point3D pnt = this.Location; Map map = this.Map; from.Direction = from.GetDirectionTo(this); chopTimer.Start(); double lumberValue = from.Skills[SkillName.Lumberjacking].Value / 100; if ((lumberValue > .5) && (Utility.RandomDouble() <= lumberValue)) { Lime fruit = new Lime((int)Utility.Random(13) + m_yield); from.AddToBackpack(fruit); int cnt = Utility.Random((int)(lumberValue * 10) + 1); Log logs = new Log(cnt); // Fruitwood Logs ?? from.AddToBackpack(logs); FruitTreeStump i_stump = new FruitTreeStump(typeof(LimeTree)); Timer poof = new StumpTimer(this, i_stump, from); poof.Start(); } else { from.SendLocalizedMessage(500495); // You hack at the tree for a while, but fail to produce any useable wood. } } } else { from.SendLocalizedMessage(500446); // That is too far away. } }
public override void OnDoubleClick(Mobile from) { if (m_sower == null || m_sower.Deleted) { m_sower = from; } if (from != m_sower) { from.SendMessage("You do not own this plant !!!"); return; } if (from.Mounted && !CropHelper.CanWorkMounted) { from.SendMessage("You cannot harvest a crop while mounted."); return; } if (DateTime.UtcNow > lastpicked.AddSeconds(3)) { lastpicked = DateTime.UtcNow; int cookValue = (int)from.Skills[SkillName.Cooking].Value / 20; if (cookValue == 0) { from.SendMessage("You have no idea how to harvest this crop."); return; } if (from.InRange(this.GetWorldLocation(), 1)) { if (m_yield < 1) { from.SendMessage("There is nothing here to harvest."); } else { from.Direction = from.GetDirectionTo(this); from.Animate(from.Mounted ? 29:32, 5, 1, true, false, 0); m_lastvisit = DateTime.UtcNow; if (cookValue > m_yield) { cookValue = m_yield + 1; } int pick = Utility.RandomMinMax(cookValue - 4, cookValue); if (pick < 0) { pick = 0; } if (pick == 0) { from.SendMessage("You do not manage to harvest any crops."); return; } m_yield -= pick; from.SendMessage("You harvest {0} crop{1}!", pick, (pick == 1 ? "" : "s")); if (m_yield < 1) { ((Item)this).ItemID = pickedGraphic; } Lime crop = new Lime(pick); from.AddToBackpack(crop); if (!regrowTimer.Running) { regrowTimer.Start(); } } } else { from.SendMessage("You are too far away to harvest anything."); } } }
public void AddLime(Lime lime) { throw new System.NotImplementedException(); }
public override void OnDoubleClick(Mobile from) { if (from.Mounted && !TreeHelper.CanPickMounted) { from.SendMessage("You cannot pick fruit while mounted."); return; } /* To Kill Tree * if ( Utility.RandomDouble() <= .05 ) * { //.25 is 25% Chance * from.SendMessage( "The crop withers away." ); * if ( regrowTimer.Running ) * regrowTimer.Stop(); * * this.Delete(); * } */ if (DateTime.Now > lastpicked.AddSeconds(3)) // 3 seconds between picking { lastpicked = DateTime.Now; int lumberValue = (int)from.Skills[SkillName.Lumberjacking].Value / 20; if (from.Mounted) { ++lumberValue; } if (lumberValue < 0) { from.SendMessage("You have no idea how to pick this fruit."); return; } if (from.InRange(this.GetWorldLocation(), 2)) { if (m_yield < 1) { from.SendMessage("There is nothing here to harvest."); } else //check skill { from.Direction = from.GetDirectionTo(this); from.Animate(from.Mounted ? 26:17, 7, 1, true, false, 0); if (lumberValue < m_yield) { lumberValue = m_yield + 1; } int pick = Utility.Random(lumberValue); if (pick == 0) { from.SendMessage("You do not manage to gather any fruit."); return; } m_yield -= pick; from.SendMessage("You pick {0} Lime{1}!", pick, (pick == 1 ? "" : "s")); //PublicOverheadMessage( MessageType.Regular, 0x3BD, false, string.Format( "{0}", m_yield )); Lime crop = new Lime(pick); from.AddToBackpack(crop); if (!regrowTimer.Running) { regrowTimer.Start(); } } } else { from.SendLocalizedMessage(500446); // That is too far away. } } }