public void CanCreateStable(double alpha, double beta, double scale, double location) { var n = new Stable(alpha, beta, scale, location); Assert.AreEqual(alpha, n.Alpha); Assert.AreEqual(beta, n.Beta); Assert.AreEqual(scale, n.Scale); Assert.AreEqual(location, n.Location); }
public void CanCreateStable([Values(0.1, 2.0)] double alpha, [Values(-1.0, 1.0)] double beta, [Values(0.1, Double.PositiveInfinity)] double scale, [Values(Double.NegativeInfinity, -1.0, 0.0, 1.0, Double.PositiveInfinity)] double location) { var n = new Stable(alpha, beta, scale, location); Assert.AreEqual(alpha, n.Alpha); Assert.AreEqual(beta, n.Beta); Assert.AreEqual(scale, n.Scale); Assert.AreEqual(location, n.Location); }
public void ValidateMedian(double location) { var n = new Stable(1.0, 0.0, 1.0, location); if (n.Beta == 0) { Assert.AreEqual(location, n.Mode); } }
/// <summary>Get whether a stable is a tractor garage.</summary> /// <param name="stable">The stable to check.</param> private bool IsGarage(Stable stable) { return (stable != null && ( stable.maxOccupants.Value == this.MaxOccupantsID || stable.buildingType.Value == this.BlueprintBuildingType // freshly constructed, not yet normalized )); }
public void ValidateSkewness() { var n = new Stable(2.0, 1.0, 1.0, 1.0); if (n.Alpha == 2) { Assert.AreEqual(0.0, n.Skewness); } }
public HorseWrapper(Stable stable, HorseOverhaul mod, Chest saddleBag, int?stableID) { Stable = stable; // has to be assigned right now because the horse gets removed from the character list while it has a rider Horse = stable.getStableHorse(); this.mod = mod; SaddleBag = saddleBag; StableID = stableID; }
public override void Kill() { base.Kill(); if (Origin is Stable) { Stable ls = (Stable)Origin; ls.Yield += yield; ls.Spawned--; } }
public override void DestroySelf() { base.DestroySelf(); if (Origin is Stable) { Stable ls = (Stable)Origin; ls.AmountStored += yield; ls.Spawned--; } }
public override void DestroySelf() { base.DestroySelf(); if (Origin is Stable) { Stable ls = (Stable)Origin; ls.AmountStored += VisitedSpots.Count * 5; ls.Spawned--; } }
public override void Kill() { base.Kill(); if (Origin is Stable) { Stable ls = (Stable)Origin; ls.Yield += VisitedSpots.Count; ls.Spawned--; } }
public void ValidateDensity( [Values(2.0, 2.0, 2.0, 1.0, 1.0, 1.0, 0.5, 0.5, 0.5)] double alpha, [Values(-1.0, -1.0, -1.0, 0.0, 0.0, 0.0, 1.0, 1.0, 1.0)] double beta, [Values(1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0)] double scale, [Values(0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0)] double location, [Values(1.5, 3.0, 5.0, 1.5, 3.0, 5.0, 1.5, 3.0, 5.0)] double x, [Values(0.16073276729880184, 0.029732572305907354, 0.00054457105758817781, 0.097941503441166353, 0.031830988618379068, 0.012242687930145794, 0.15559955475708653, 0.064989885240913717, 0.032286845174307237)] double d) { var n = new Stable(alpha, beta, scale, location); AssertHelpers.AlmostEqual(d, n.Density(x), 15); }
public void ValidateDensityLn( [Values(2.0, 2.0, 2.0, 1.0, 1.0, 1.0, 0.5, 0.5, 0.5)] double alpha, [Values(-1.0, -1.0, -1.0, 0.0, 0.0, 0.0, 1.0, 1.0, 1.0)] double beta, [Values(1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0)] double scale, [Values(0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0)] double location, [Values(1.5, 3.0, 5.0, 1.5, 3.0, 5.0, 1.5, 3.0, 5.0)] double x, [Values(-1.8280121234846454, -3.5155121234846449, -7.5155121234846449, -2.3233848821910463, -3.4473149788434458, -4.4028264238708825, -1.8604695287002526, -2.7335236328735038, -3.4330954018558235)] double dln) { var n = new Stable(alpha, beta, scale, location); AssertHelpers.AlmostEqual(dln, n.DensityLn(x), 15); }
public void ValidateCumulativeDistribution( [Values(2.0, 2.0, 2.0, 1.0, 1.0, 1.0, 0.5, 0.5, 0.5)] double alpha, [Values(-1.0, -1.0, -1.0, 0.0, 0.0, 0.0, 1.0, 1.0, 1.0)] double beta, [Values(1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0)] double scale, [Values(0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0)] double location, [Values(1.5, 3.0, 5.0, 1.5, 3.0, 5.0, 1.5, 3.0, 5.0)] double x, [Values(0.8555778168267576, 0.98305257323765538, 0.9997965239912775, 0.81283295818900125, 0.89758361765043326, 0.93716704181099886, 0.41421617824252516, 0.563702861650773, 0.65472084601857694)] double cdf) { var n = new Stable(alpha, beta, scale, location); AssertHelpers.AlmostEqual(cdf, n.CumulativeDistribution(x), 15); }
public async Task <IActionResult> PostStable([FromBody] Stable stable) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } _context.Stables.Add(stable); await _context.SaveChangesAsync(); return(CreatedAtAction("GetStable", new { id = stable.StableID }, stable)); }
public override void Activate() { base.Activate(); if (Origin is Stable) { Stable ls = (Stable)Origin; ls.Spawned++; } UpdateRandomMovement(); }
public void ValidateMinimum(double beta) { var n = new Stable(1.0, beta, 1.0, 1.0); if (Math.Abs(beta) != 1) { Assert.AreEqual <double>(Double.NegativeInfinity, n.Minimum); } else { Assert.AreEqual <double>(0.0, n.Minimum); } }
/// <summary>Migrate tractors and garages from older versions of the mod.</summary> /// <remarks>The Robin construction logic is derived from <see cref="NPC.reloadSprite"/> and <see cref="Farm.resetForPlayerEntry"/>.</remarks> private void LoadLegacyData() { // fix building types foreach (BuildableGameLocation location in this.GetBuildableLocations()) { foreach (Stable stable in location.buildings.OfType <Stable>()) { if (stable.buildingType.Value == this.BlueprintBuildingType) { stable.buildingType.Value = "Stable"; stable.maxOccupants.Value = this.MaxOccupantsID; } } } // get save data LegacySaveData saveData = this.Helper.Data.ReadSaveData <LegacySaveData>("tractors"); // 4.6 if (saveData?.Buildings == null) { saveData = this.Helper.Data.ReadJsonFile <LegacySaveData>(this.LegacySaveDataRelativePath); // pre-4.6 } if (saveData?.Buildings == null) { return; } // add tractor + garages BuildableGameLocation[] locations = this.GetBuildableLocations().ToArray(); foreach (LegacySaveDataBuilding garageData in saveData.Buildings) { // get location BuildableGameLocation location = locations.FirstOrDefault(p => p.NameOrUniqueName == (garageData.Map ?? "Farm")); if (location == null) { this.Monitor.Log($"Ignored legacy tractor garage in unknown location '{garageData.Map}'.", LogLevel.Warn); continue; } // add garage Stable garage = location.buildings.OfType <Stable>().FirstOrDefault(p => p.tileX.Value == (int)garageData.Tile.X && p.tileY.Value == (int)garageData.Tile.Y); if (garage == null) { garage = new Stable(garageData.TractorID, this.GetBlueprint(), garageData.Tile); garage.daysOfConstructionLeft.Value = 0; location.buildings.Add(garage); } garage.maxOccupants.Value = this.MaxOccupantsID; garage.load(); } }
public double[] massAssignFunc(double stability, double skew, double scale, double location) { double[] m1 = new double[12]; double sum = 0; for (int i = 0; i < 11; i++) { m1[i] = Stable.PDF(stability, skew, scale, location, 2 * i - 9) - Stable.PDF(stability, skew, scale, location, 2 * i - 11); sum += m1[i]; } m1[11] = 1.0 - sum; return(m1); }
private static void CopyAndReplace() { if (BaseHorse == null) { // Get my stable Stable stable = Game1.getFarm().buildings.OfType <Stable>() .Where(bld => bld.GetType().FullName?.Contains("TractorMod") == false && (!Context.IsMultiplayer || bld.owner.Value == Game1.player.UniqueMultiplayerID)) .FirstOrDefault(); if (stable == null) { return; } BaseHorse = Utility.findHorse(stable.HorseId); if (BaseHorse == null) { return; } if (BaseHorse.Name != Game1.player.horseName.Value) { Game1.player.horseName.Value = BaseHorse.Name; } } if (MyHorse == null) { MyHorse = new EasyHorse(); } CopyHorse(BaseHorse, MyHorse); var npcs = MyHorse.currentLocation.characters; for (int index = 0; index < npcs.Count; ++index) { if (npcs[index] == BaseHorse) { npcs[index] = MyHorse; return; } } }
public FarmShould() { Stable stable1 = new Stable(3, 3); stable1.PutHorseInStable(new Horse()); Stable stable2 = new Stable(3, 3); stable2.PutHorseInStable(new Horse()); Stable stable3 = new Stable(3, 3); stable3.PutHorseInStable(new Horse()); _sut = new Farm { Stables = new List <Stable>() { stable1, stable2, stable3 } }; }
/// <summary>Send a tractor back home.</summary> /// <param name="tractor">The tractor to dismiss.</param> private void DismissTractor(Horse tractor) { if (tractor == null || !this.IsTractor(tractor)) { return; } // dismount if (tractor.rider != null) { tractor.dismount(); } // get home position (garage may have been moved since the tractor was spawned) Farm location = Game1.getFarm(); Stable garage = location.buildings.OfType <Stable>().FirstOrDefault(p => p.HorseId == tractor.HorseId); Vector2 tile = garage != null ? this.GetDefaultTractorTile(garage) : tractor.DefaultPosition; // warp home TractorManager.SetLocation(tractor, location, tile); }
public static bool SaveItemsFromDemolition(Stable __instance) { try { if (HorseOverhaul.IsGarage(__instance)) { return(true); } HorseWrapper horseW = null; mod.Horses.Where(x => x.Horse == __instance.getStableHorse()).Do(x => horseW = x); if (horseW != null && horseW.SaddleBag != null) { if (horseW.SaddleBag.items.Count > 0) { foreach (var item in horseW.SaddleBag.items) { Game1.player.team.returnedDonations.Add(item); Game1.player.team.newLostAndFoundItems.Value = true; } horseW.SaddleBag.items.Clear(); } horseW.SaddleBag = null; } return(true); } catch (Exception e) { mod.ErrorLog("There was an exception in a patch", e); return(true); } }
/// <summary>Calls all horses owned by the player to return to the player's stable</summary> internal static void CorralHorses() { // Find the farm's stable Stable horsehut = null; foreach (Building building in Game1.getFarm().buildings) { if (building is Stable) { horsehut = building as Stable; } } if (horsehut != null) { // WARP THEM. WARP THEM ALL. int stableX = int.Parse(horsehut.tileX.ToString()) + 1; int stableY = int.Parse(horsehut.tileY.ToString()) + 1; Vector2 stableWarp = new Vector2(stableX, stableY); foreach (Horse horse in ModApi.GetHorses()) { if (!ModApi.IsWildHorse(horse)) { Game1.warpCharacter(horse, "farm", stableWarp); } } ModEntry.SMonitor.Log("All horses have been warped to the stable.", LogLevel.Info); return; } // Player does not own a stable ModEntry.SMonitor.Log("NOTICE: You don't have a stable to warp to!", LogLevel.Error); Game1.chatBox.addInfoMessage("Your Grandfather's voice echoes in your head.. \"You aren't yet ready for this gift.\""); }
// GET api/stables/5 public IHttpActionResult Get(int id) { try { Stable result; if (id > 0) { result = repo.Retrieve().FirstOrDefault(stable => stable.Id == id); if (result == null) { return(NotFound()); } } else { result = new Stable(); } return(Ok(result)); } catch (Exception e) { return(InternalServerError(e)); } }
// PUT api/stables/5 public IHttpActionResult Put(int id, [FromBody] Stable stable) { try { if (stable == null) { return(BadRequest("Stable cannot be null")); } Stable result = repo.Save(id, stable); if (result == null) { return(NotFound()); } if (!ModelState.IsValid) { return(BadRequest(ModelState)); } return(Ok()); } catch (Exception e) { return(InternalServerError(e)); } }
public void ValidateMinimum(double beta) { var n = new Stable(1.0, beta, 1.0, 1.0); Assert.AreEqual(Math.Abs(beta) != 1 ? Double.NegativeInfinity : 0.0, n.Minimum); }
public void ValidateMinimum(double beta) { var n = new Stable(1.0, beta, 1.0, 1.0); if (Math.Abs(beta) != 1) { Assert.AreEqual<double>(Double.NegativeInfinity, n.Minimum); } else { Assert.AreEqual<double>(0.0, n.Minimum); } }
public void CanSample() { var n = new Stable(1.0, 1.0, 1.0, 1.0); n.Sample(); }
public void SetLocationFail() { var n = new Stable(1.0, 1.0, 1.0, 1.0); n.Location = Double.NaN; }
public void ValidateCumulativeDistribution(double alpha, double beta, double scale, double location, double x, double cdf) { var n = new Stable(alpha, beta, scale, location); AssertHelpers.AlmostEqual(cdf, n.CumulativeDistribution(x), 15); }
public void SetAlphaFail(double alpha) { var n = new Stable(1.0, 1.0, 1.0, 1.0); Assert.Throws<ArgumentOutOfRangeException>(() => n.Alpha = alpha); }
public void CanSetScale(double scale) { var n = new Stable(1.0, 1.0, 1.0, 1.0); n.Scale = scale; }
public void ValidateToString() { var n = new Stable(1.2, 0.3, 1.0, 2.0); Assert.AreEqual(String.Format("Stable(Stability = {0}, Skewness = {1}, Scale = {2}, Location = {3})", n.Alpha, n.Beta, n.Scale, n.Location), n.ToString()); }
public void StableCreateFailsWithBadParameters(double alpha, double beta, double location, double scale) { var n = new Stable(alpha, beta, location, scale); }
public void SetAlphaFail(double alpha) { var n = new Stable(1.0, 1.0, 1.0, 1.0); n.Alpha = alpha; }
public void SetBetaFail(double beta) { var n = new Stable(1.0, 1.0, 1.0, 1.0); n.Beta = beta; }
public void ValidateMaximum() { var n = new Stable(1.0, 1.0, 1.0, 1.0); Assert.AreEqual(Double.PositiveInfinity, n.Maximum); }
public Posture(Stable state) { SetState(state); }
public void ValidateDensityLn(double alpha, double beta, double scale, double location, double x, double dln) { var n = new Stable(alpha, beta, scale, location); AssertHelpers.AlmostEqual(dln, n.DensityLn(x), 15); }
public void CanSetAlpha(double alpha) { var n = new Stable(1.0, 1.0, 1.0, 1.0); n.Alpha = alpha; }
public void CanSampleSequence() { var n = new Stable(1.0, 1.0, 1.0, 1.0); var ied = n.Samples(); ied.Take(5).ToArray(); }
public void SetState(Stable state) { BaseState = State.Stable; StableState = state; }
public void CanSetLocation(double location) { var n = new Stable(1.0, 1.0, 1.0, 1.0); n.Location = location; }
public void SetBetaFail(double beta) { var n = new Stable(1.0, 1.0, 1.0, 1.0); Assert.Throws<ArgumentOutOfRangeException>(() => n.Beta = beta); }
public void SetScaleFail(double scale) { var n = new Stable(1.0, 1.0, 1.0, 1.0); n.Scale = scale; }
public void CanSetBeta(double beta) { var n = new Stable(1.0, 1.0, 1.0, 1.0); n.Beta = beta; }
public void ValidateEntropyThrowsNotSupportedException() { var n = new Stable(1.0, 1.0, 1.0, 1.0); Assert.Throws <NotSupportedException>(() => { var e = n.Entropy; }); }
public void SetScaleFail(double scale) { var n = new Stable(1.0, 1.0, 1.0, 1.0); Assert.Throws<ArgumentOutOfRangeException>(() => n.Scale = scale); }
public void ValidateEntropy() { var n = new Stable(1.0, 1.0, 1.0, 1.0); var e = n.Entropy; }
public void SetLocationFail() { var n = new Stable(1.0, 1.0, 1.0, 1.0); Assert.Throws<ArgumentOutOfRangeException>(() => n.Location = Double.NaN); }
public void ValidateEntropyThrowsNotSupportedException() { var n = new Stable(1.0, 1.0, 1.0, 1.0); Assert.Throws<NotSupportedException>(() => { var e = n.Entropy; }); }
public void ValidateToString() { var n = new Stable(1.2, 0.3, 1.0, 2.0); Assert.AreEqual<string>("Stable(Stability = 1.2, Skewness = 0.3, Scale = 1, Location = 2)", n.ToString()); }