public async Task <IActionResult> PutFisher(int id, Fisher fisher) { if (id != fisher.UserId) { return(BadRequest()); } _context.Entry(fisher).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!FisherExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <ActionResult <Fisher> > PostFisher(Fisher fisher) { _context.Fishers.Add(fisher); await _context.SaveChangesAsync(); return(CreatedAtAction("GetFisher", new { id = fisher.UserId }, fisher)); }
/// <summary> /// Casts the line out for a user, starting the fishing process. /// </summary> /// <param name="userId">The twitch id of the user to begin fishing for.</param> public void Cast(string userId) { var fisher = GetFisherById(userId); var hookTime = DateTime.Now; if (Tournament.IsRunning) { hookTime = hookTime.AddSeconds(Random.Next(Settings.FishingTournamentCastMinimum, Settings.FishingTournamentCastMaximum + 1)); } else { hookTime = hookTime.AddSeconds(Random.Next(Settings.FishingCastMinimum, Settings.FishingCastMaximum + 1)); } if (fisher == null) { fisher = new Fisher() { UserId = userId, IsFishing = true, HookedTime = hookTime }; Fishers.Create(fisher); } else { fisher.IsFishing = true; fisher.HookedTime = hookTime; Fishers.Update(fisher); } Fishers.Commit(); }
/// <summary> /// Updates the personal leaderboard with new data if the catch object /// would set a new record. /// </summary> /// <param name="fisher">The fisher object for the user catching the /// fish.</param> /// <param name="catchData">An object with catch data to use for the /// update.</param> /// <returns>Whether or not the leaderboard was updated.</returns> public bool UpdatePersonalLeaderboard(Fisher fisher, Catch catchData) { if (fisher == null || catchData == null) { return(false); } var record = fisher.Records?.Where(x => x.Fish.Equals(catchData.Fish)).FirstOrDefault(); if (record == null || record.Weight < catchData.Weight) { if (record == null) { fisher.Records.Add(catchData); } else { record.CopyFrom(catchData); } Fishers.Update(fisher); Fishers.Commit(); return(true); } return(false); }
public Fisher GetFisherByName(int id) { Fisher fisher = new Fisher(); string reply = sock.GetFisher(id); if (reply.Contains("ResponseCode")) { Debug.WriteLine("Failed to get fisher"); return(fisher); } string js = @"{""fisher"":" + reply + "}"; JObject jObject = JObject.Parse(js); JToken jFisher = jObject["fisher"]; fisher.Username = (string)jFisher["Username"]; fisher.id = id; fisher.IsActive = (bool)jFisher["IsActive"]; fisher.Email = (string)jFisher["Email"]; fisher.Gender = (string)jFisher["Gender"]; fisher.PersonSexualityId = (int)jFisher["PersonSexualityId"]; fisher.FirstName = (string)jFisher["FirstName"]; fisher.Age = (int)jFisher["Age"]; fisher.Description = (string)jFisher["Description"]; return(fisher); }
public void CalculateFishSizesRandomizesWithSteppedWeights() { var fisher = new Fisher(); var fish = new Fish() { MinimumWeight = 1, MaximumWeight = 10, MinimumLength = 11, MaximumLength = 20, }; fisher.Hooked = fish; var minWeightGroup = (fisher.Hooked.MaximumWeight - fisher.Hooked.MinimumWeight) / 5 + fisher.Hooked.MinimumWeight; var minLengthGroup = (fisher.Hooked.MaximumLength - fisher.Hooked.MinimumLength) / 5 + fisher.Hooked.MinimumLength; var maxWeightGroup = (fisher.Hooked.MaximumWeight - fisher.Hooked.MinimumWeight) / 5 * 4 + fisher.Hooked.MinimumWeight; var maxLengthGroup = (fisher.Hooked.MaximumLength - fisher.Hooked.MinimumLength) / 5 * 4 + fisher.Hooked.MinimumLength; var sampleSize = 10000; var samples = new List <Catch>(); for (var i = 0; i < sampleSize; i++) { samples.Add(System.CalculateFishSizes(fisher)); } var minGroupSize = samples.Count(x => x.Length <= minLengthGroup && x.Weight <= minWeightGroup); var maxGroupSize = samples.Count(x => x.Length >= maxLengthGroup && x.Weight >= maxWeightGroup); Assert.IsTrue(minGroupSize > sampleSize * 0.39 && minGroupSize < sampleSize * 0.41); Assert.IsTrue(maxGroupSize > 0 && maxGroupSize < sampleSize * 0.02); }
public static void FishingMain() { try { Console.Clear(); Console.WriteLine("Kalastusta"); Fisher kalstaja1 = new Fisher("Kirsi Kernel", "020 - 12345678"); kalstaja1.goFishing(3); foreach (Fish f in kalstaja1.Fishes)// ennen järjestelyä { Console.WriteLine("{0} Lenght {1}cm Weight {2}g {3} {4}", f.Species, f.Length, f.Weight, f.Location, f.Place); } Console.WriteLine(""); kalstaja1.sortFishes(); foreach (Fish f in kalstaja1.Fishes)// järjestelyn jälkeen { Console.WriteLine("{0} Lenght {1}cm Weight {2}g {3} {4}", f.Species, f.Length, f.Weight, f.Location, f.Place); } } catch (Exception e) { Console.WriteLine(e); } }
/// <summary> /// Deletes a fish from a user's records. /// </summary> /// <param name="fisher">The fisher object for the user.</param> /// <param name="fish">The catch data for the record to remove.</param> public void DeleteFish(Fisher fisher, Catch fish) { if (fisher != null && fish != null) { fisher.Records?.Remove(fish); Fishers.Update(fisher); Fishers.Commit(); } }
public static List <decimal?> Fisher(this IEnumerable <ICandle> candles, int?period = null) { period ??= 10; IIndicatorOptions options = new AdxOptions(period.Value); Fisher sma = new Fisher(); return(sma.Get(candles, options)); }
static void Main() { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Fisher.Set_ConnectionString(Globals.SqlConnectionString); Application.Run(new Form_Main()); }
private void btn_SignleRow_Click(object sender, EventArgs e) { int id = FisherUtil.ParseInt(tbx_Get_ConfigurationID.Text); if (id > 0) { TSysConfiguration configuration = Fisher.SignleRow <TSysConfiguration>(id); Fisher.SignleRow <TSysConfiguration>("", true); } }
public void AddTournamentPointsDoesNothingIfNoTournamentRunning() { var fisher = new Fisher() { Id = 0, UserId = "00" }; var points = System.AddTournamentPoints(fisher.UserId, 10); Assert.AreEqual(-1, points); Assert.IsNull(System.CurrentTournament); }
private void Form1_Load(object sender, EventArgs e) { //Список персонажей Fisher fs = new Fisher { firstName = "Рыбак", Id = 1, pathSpeaksFile = "SpeaksFisher.xml" }; comboCharacters.Items.Add(fs); comboCharacters.DisplayMember = "firstName"; comboCharacters.ValueMember = "Id"; }
public override bool checkProceduralPrecondition(GameObject agent) { // Find lake Fisher fisher = (Fisher)agent.GetComponent(typeof(Fisher)); if (fisher.actualLakePosition != null) { targetLakePosition = fisher.actualLakePosition; if (targetLakePosition != null) { target = targetLakePosition.gameObject; } } else { float localRadius = numTry * radius; numTry++; Collider2D[] colliders = Physics2D.OverlapCircleAll(agent.transform.position, localRadius); LakeEntity lakeClose = null; if (colliders == null) { return(false); } foreach (Collider2D hit in colliders) { if (hit.tag != "Lake") { continue; } LakeEntity lake = (LakeEntity)hit.gameObject.GetComponent(typeof(LakeEntity)); if (lake.full) { continue; } lakeClose = lake; break; } bool isClosest = lakeClose != null; if (isClosest) { targetLakePosition = lakeClose.addFisher(); fisher.actualLakePosition = targetLakePosition; target = targetLakePosition; numTry = 1; } } return(targetLakePosition != null); }
void Awake() { mTotalMass = 0; if ((anchor != null) && (bait != null)) { SpringJoint joint = anchor.gameObject.AddComponent <SpringJoint>(); joint.spring = springStrength; joint.connectedBody = bait.GetComponent <Rigidbody>(); AddPoint(bait); } msInstance = this; Screen.lockCursor = true; }
public void StartTournamentCancelsFishingUsers() { var fisher = new Fisher() { Id = 0, UserId = "00", IsFishing = true, Hooked = new Fish(), HookedTime = DateTime.Now }; Fishers.Data.Add(fisher); System.StartTournament(); Assert.IsNotNull(System.CurrentTournament); Assert.IsFalse(fisher.IsFishing); Assert.IsNull(fisher.Hooked); Assert.IsNull(fisher.HookedTime); }
private void search3_Click(object sender, EventArgs e) { string index = ""; int min; try { min = Convert.ToInt32(min1.Text); } catch { min = searchword3.TextLength; } foreach (string s in list) { int distance = Fisher.DemLevinstain(searchword3.Text, s); if ((distance < min) && (distance <= min)) { min = distance; index = s; } } bool flag = false; foreach (string i in listBox3.Items) { if (i == index) { flag = true; } } if (index == "") { MessageBox.Show("Слово не найдено!"); } else if (!flag) { listBox3.BeginUpdate(); listBox3.Items.Add(index); listBox3.EndUpdate(); } else { MessageBox.Show("Слово уже найдено!"); } }
public void AddTournamentPointsAddsUserIfNoEntryExists() { var fisher = new Fisher() { Id = 0, UserId = "00" }; System.CurrentTournament = new TournamentResult(); var points = System.AddTournamentPoints(fisher.UserId, 10); Assert.AreEqual(10, points); Assert.AreEqual(1, System.CurrentTournament.Entries.Count); Assert.AreEqual(fisher.UserId, System.CurrentTournament.Entries[0].UserId); Assert.AreEqual(points, System.CurrentTournament.Entries[0].Points); }
private static void SeedFishers(AuthContext context) { if (context.Fishers.Any()) { return; } var fishers = new Fisher[] { new Fisher { Age = 19, Description = "FunnyDays", Email = "*****@*****.**", FirstName = "Chris", Gender = "M", IsActive = true, PersonSexualityId = 1 }, new Fisher { Age = 20, Description = "FunnyDays2", Email = "*****@*****.**", FirstName = "Peter", Gender = "M", IsActive = true, PersonSexualityId = 2 }, new Fisher { Age = 21, Description = "FunnyDays3", Email = "*****@*****.**", FirstName = "Andrew", Gender = "M", IsActive = true, PersonSexualityId = 3 }, new Fisher { Age = 22, Description = "FunnyDays4", Email = "*****@*****.**", FirstName = "Keisha", Gender = "F", IsActive = true, PersonSexualityId = 1 }, new Fisher { Age = 23, Description = "FunnyDays5", Email = "*****@*****.**", FirstName = "Tasha", Gender = "F", IsActive = true, PersonSexualityId = 2 }, new Fisher { Age = 24, Description = "FunnyDays6", Email = "*****@*****.**", FirstName = "Maria", Gender = "F", IsActive = true, PersonSexualityId = 3 }, }; foreach (Fisher fisher in fishers) { context.Add(fisher); } context.SaveChanges(); }
public void AddsTournamentPoints() { var fisher = new Fisher() { Id = 0, UserId = "00" }; Fishers.Data.Add(fisher); System.CurrentTournament = new TournamentResult(); System.CurrentTournament.Entries.Add(new TournamentEntry(fisher.UserId, 10)); var points = System.AddTournamentPoints(fisher.UserId, 10); Assert.AreEqual(20, points); Assert.AreEqual(1, System.CurrentTournament.Entries.Count); Assert.AreEqual(points, System.CurrentTournament.Entries[0].Points); }
public CommandResult DebugCatch(string data) { var fisher = new Fisher(); var output = new List <string>(); for (var i = 0; i < 50; i++) { FishingSystem.HookFish(fisher); var fish = FishingSystem.CalculateFishSizes(fisher); output.Add($"{fish.Fish.Name} ({fish.Fish.Rarity.Name}) caght."); } return(new CommandResult() { Processed = true, Debug = output }); }
private void button2_Click(object sender, EventArgs e) { Stopwatch extime = new Stopwatch(); string new_str = "\0"; Random rnd = new Random(); if (radioButton1.Checked == true) { extime.Start(); listBox1.BeginUpdate(); listBox1.Items.Clear(); for (int i = 0; i < word_list.Count; i++) { if (word_list[i].Contains(textBox3.Text)) { listBox1.Items.Add(word_list[i]); } } listBox1.EndUpdate(); } else if (radioButton2.Checked == true) { extime.Start(); int max_dist; if ((int.TryParse(textBox5.Text, out max_dist))) { listBox1.BeginUpdate(); listBox1.Items.Clear(); for (int i = 0; i < word_list.Count; i++) { if (Fisher.GetLen(word_list[i], textBox3.Text) <= max_dist && !listBox1.Items.Contains(word_list[i])) { listBox1.Items.Add(word_list[i]); } } listBox1.EndUpdate(); } } else { MessageBox.Show("Пожалуйста, выберите метод поиска слова!"); } extime.Stop(); textBox4.Text = extime.ElapsedMilliseconds.ToString(); }
public override bool perform(GameObject agent) { if (startTime == 0) { enableBubbleIcon(agent); startTime = Time.time; } if (Time.time - startTime > duration) { disableBubbleIcon(agent); Fisher fisher = (Fisher)agent.GetComponent(typeof(Fisher)); targetWarehouse.food += fisher.food; fisher.food = 0; droppedFood = true; } return(true); }
public FisherGPSWindow(Fisher fisher, bool readOnly = false, StartWindow parentWindow = null) { InitializeComponent(); _parentWindow = parentWindow; if (Entities.BSCEntities.GPSViewModel == null) { Entities.BSCEntities.GPSViewModel = new GPSViewModel(); } //BSCEntities.FisherGPSViewModel = new FisherGPSViewModel(fisher.FisherID); this.Loaded += Window_Loaded; lblFisher.Content = $"Fisher: {fisher.FisherName}"; lblLandingSite.Content = $"Landing site: {fisher.LandingSite.LandingSiteName}, {fisher.LandingSite.Municipality.ToString()}"; _fisher = fisher; _readOnly = readOnly; }
public override bool perform(GameObject agent) { if (startTime == 0) { enableBubbleIcon(agent); startTime = Time.time; } if (Time.time - startTime > duration) { disableBubbleIcon(agent); Fisher fisher = (Fisher)agent.GetComponent(typeof(Fisher)); fisher.food = Random.Range(1, 20); fisher.energy -= energyCost; fished = true; } return(true); }
private void btn_PageClicked(object sender, EventArgs e) { int pageSize = FisherUtil.ParseInt(tbx_PageSize.Text, 10); int pageIndex = FisherUtil.ParseInt(tbx_PageIndex.Text, 1); Button btn = (Button)sender; switch (btn.Name) { case "btn_FirstPage": pageIndex = 1; break; case "btn_PrevPage": pageIndex--; break; case "btn_NextPage": pageIndex++; break; case "btn_LastPage": pageIndex = totalPage; break; } if (pageIndex <= 0) { pageIndex = 1; } else if (pageIndex > totalPage && totalPage > 0) { pageIndex = totalPage; } //Fisher.Query<TSysConfiguration>(sqlWhere: "",pageSize: 1); FisherResult <TSysConfiguration> result = Fisher.Query <TSysConfiguration>(tbx_SqlCondition.Text, null, pageSize, pageIndex); dgv.DataSource = result.Result; tbx_PageIndex.Text = result.PageIndex.ToString(); tbx_RecordCount.Text = result.TotalRecord.ToString(); tbx_TotalPage.Text = result.TotalPage.ToString(); totalPage = result.TotalPage; }
public void CalculatesFishSizes() { var fisher = new Fisher { Hooked = new Fish() { MinimumWeight = 1, MaximumWeight = 10, MinimumLength = 11, MaximumLength = 20, } }; var catchData = System.CalculateFishSizes(fisher); Assert.IsTrue(fisher.Hooked.MinimumWeight <= catchData.Weight); Assert.IsTrue(fisher.Hooked.MaximumWeight >= catchData.Weight); Assert.IsTrue(fisher.Hooked.MinimumLength <= catchData.Length); Assert.IsTrue(fisher.Hooked.MaximumLength >= catchData.Length); }
/// <summary> /// Catches the fish a user has hooked. If no fish is hooked, the user /// will reel in the empty line. /// </summary> /// <param name="fisher">The fisher that is trying to catch.</param> /// <returns>The catch data for this fish.</returns> public Catch CatchFish(Fisher fisher) { var catchData = default(Catch); if (fisher != null) { catchData = CalculateFishSizes(fisher); if (catchData != null && Tournament.IsRunning) { UpdatePersonalLeaderboard(fisher, catchData); UpdateGlobalLeaderboard(catchData); Tournament.AddTournamentPoints(fisher.UserId, catchData.Points); } fisher.IsFishing = false; fisher.Hooked = null; fisher.HookedTime = null; } return(catchData); }
private static void SeedUsers(WebAppContext context) { if (context.Users.Any()) { return; } var fishers = new Fisher[] { new Fisher() { Username = "******", Password = "******", Email = "*****@*****.**", Gender = 'M', SexPref = 'F', PicRef = "rasr2", Age = 12, IsActive = true }, }; foreach (Fisher fisher in fishers) { context.Add(fisher); } context.SaveChanges(); }
/// <summary> /// Calculates the exact length, weight, and point value of a fish /// being caught. /// </summary> /// <param name="fisher">The fisher object for the user catching the /// fish.</param> /// <returns>The catch object with the calculated data values.</returns> public Catch CalculateFishSizes(Fisher fisher) { if (fisher == null || fisher.Hooked == null) { return(null); } var fish = fisher.Hooked; var catchData = new Catch { UserId = fisher.UserId, Fish = fish }; if (Settings.FishingUseNormalSizes) { catchData.Weight = (float)Random.NextNormalBounded(fish.MinimumWeight, fish.MaximumWeight); catchData.Length = (float)Random.NextNormalBounded(fish.MinimumLength, fish.MaximumLength); var weightRange = fish.MaximumWeight - fish.MinimumWeight; var lengthRange = fish.MaximumLength - fish.MinimumLength; catchData.Points = (int)Math.Round( (catchData.Weight - fish.MinimumWeight) / weightRange * 50f + (catchData.Length - fish.MinimumLength) / lengthRange * 50f); } else { var weightRange = (fish.MaximumWeight - fish.MinimumWeight) / 5; var lengthRange = (fish.MaximumLength - fish.MinimumLength) / 5; var weightVariance = Random.NextDouble() * weightRange; var lengthVariance = Random.NextDouble() * lengthRange; var size = Random.NextDouble() * 100; var category = Chances.Where(x => size > x).Count(); catchData.Length = (float)Math.Round(fish.MinimumLength + lengthRange * category + lengthVariance, 2); catchData.Weight = (float)Math.Round(fish.MinimumWeight + weightRange * category + weightVariance, 2); catchData.Points = (int)Math.Max(Math.Round(size), 1); } return(catchData); }