private static void AssertSurvival(IWebDriver driver, Gender gender, int birthYear, int weeklyPlaytime, PlayStyle playStyle, bool expectSurvival) { SignInHelper.SignInWithId(driver, UserConstants.SampleSteamId); SurvivalHelper.CalculateSurvival(driver, gender, birthYear, weeklyPlaytime, playStyle); Console.WriteLine("Parsing backlog completion date..."); var backlogCompletion = TestUtil.ParseBrowserDate(driver, driver.FindElement(By.Id(SiteConstants.SurvivalBacklogCompletionLabelId)).Text); Console.WriteLine("Parsing time of death date..."); var timeOfDeath = TestUtil.ParseBrowserDate(driver, driver.FindElement(By.Id(SiteConstants.SurvivalTimeOfDeathLabelId)).Text); Console.WriteLine("Asserting expected results..."); bool survival = timeOfDeath >= backlogCompletion; if (expectSurvival) { Assert.IsTrue(survival, "Expected time of death to come after backlog completion"); Assert.IsTrue(driver.FindElement(By.Id(SiteConstants.SurvivalSuccessImgId)).Displayed, "Expected backlog completion success"); } else { Assert.IsFalse(survival, "Expected time of death to come before backlog completion"); Assert.IsTrue(driver.FindElement(By.Id(SiteConstants.SurvivalFailureImgId)).Displayed, "Expected backlog completion failure"); } }
private static void AssertNoShareLinks(IWebDriver driver) { Assert.IsFalse(driver.FindElement(By.Id(SiteConstants.SocialSharingHeaderId)).Displayed, "Expected hidden social sharing section in non-user games page"); SurvivalHelper.CalculateSurvival(driver, Gender.Female, DateTime.Now.Year - 20, 10, PlayStyle.Extras); Assert.IsFalse(driver.FindElement(By.Id(SiteConstants.SurvivalSocialSharingHeaderId)).Displayed, "Expected hidden survival social sharing section in non-user games page"); }
internal static bool NotifyGetCanSleep(Player player) { if (DayNightCycle.main.IsInSkipTimeMode()) { return(false); } if (player.GetMode() != Player.Mode.Normal) { return(false); } if (player.isPiloting) { return(false); } if (player.movementSpeed != 0f) { return(false); } if (player.IsUnderwater() || player.IsSwimming() || player.IsUnderwaterForSwimming()) { ErrorMessage.AddWarning("You can not sleep in the water."); return(false); } if (SurvivalHelper.IsSurvival() && (StatManager.sleep.RealValue >= 100 || StatManager.tiredness.RealValue < 25 || StatManager.coffee.RealValue >= 20)) { if (StatManager.coffee.RealValue >= 20) { ErrorMessage.AddWarning("You shouldn't drink coffee before going to sleep!"); } else if (StatManager.sleep.RealValue >= 100 || StatManager.tiredness.RealValue < 25) { ErrorMessage.AddWarning("You aren't tired enough!"); } return(false); } Survival pSurvival = player.GetComponent <Survival>(); if (SurvivalHelper.IsSurvival() && (pSurvival.food <= 20f || pSurvival.water <= 20f)) { if (pSurvival.food <= 20f && pSurvival.water <= 20f) { ErrorMessage.AddWarning("You need to eat and drink something before going to sleep!"); } else if (pSurvival.food <= 20f) { ErrorMessage.AddWarning("You need to eat something before going to sleep!"); } else if (pSurvival.water <= 20f) { ErrorMessage.AddWarning("You need to drink something before going to sleep!"); } return(false); } return(true); }
public void TestShareLinks() { SeleniumExtensions.ExecuteOnMultipleBrowsers(driver => { var isInternetExplorer = driver is InternetExplorerDriver; SignInHelper.SignInWithId(driver); LinkHelper.AssertExternalLink(driver, SiteConstants.FacebookShareAnchorId, FacebookShareTitle, newWindow: true, dismissAlertOnClose: isInternetExplorer); LinkHelper.AssertExternalLink(driver, SiteConstants.TwitterShareAnchorId, TwitterShareTitle, newWindow: true); LinkHelper.AssertExternalLink(driver, SiteConstants.RedditShareAnchorId, RedditShareTitle, newWindow: true); SurvivalHelper.CalculateSurvival(driver, Gender.Female, DateTime.Now.Year - 20, 10, PlayStyle.Extras); LinkHelper.AssertExternalLink(driver, SiteConstants.SurvivalFacebookShareAnchorId, FacebookShareTitle, newWindow: true, dismissAlertOnClose: isInternetExplorer); LinkHelper.AssertExternalLink(driver, SiteConstants.SurvivalTwitterShareAnchorId, TwitterShareTitle, newWindow: true); LinkHelper.AssertExternalLink(driver, SiteConstants.SurvivalRedditShareAnchorId, RedditShareTitle, newWindow: true); }); }
public void Update() { if (SceneManager.isIngame) { if (StatManager.sleep == null) { return; } if (StatManager.tiredness == null) { return; } if (StatManager.coffee == null) { return; } if (StatManager.vision == null) { return; } if (sleeping) { if (sleepLocation == SleepLocation.Floor && !DayNightCycle.main.IsInSkipTimeMode()) { StopSleep(Player.main, false); } } if (InputHelper.IsKeyDown(SettingsManager.keySleepStart) && !keySleepStartDown) { keySleepStartDown = true; if (!sleeping) { if (NotifyGetCanSleep(Player.main)) { if (SettingsManager.keySleepStart == SettingsManager.keySleepStop) { keySleepStopDown = true; } StartSleep(Player.main); } } } else if (!InputHelper.IsKeyDown(SettingsManager.keySleepStart) && keySleepStartDown) { keySleepStartDown = false; } if (InputHelper.IsKeyDown(SettingsManager.keySleepStop) && !keySleepStopDown) { keySleepStopDown = true; if (sleeping) { if (SettingsManager.keySleepStart == SettingsManager.keySleepStop) { keySleepStartDown = true; } StopSleep(Player.main, false); } } else if (!InputHelper.IsKeyDown(SettingsManager.keySleepStop) && keySleepStopDown) { keySleepStopDown = false; } float oldTime = lastTime; float newTime = SurvivalHelper.GetTime(); float timePassed = newTime - oldTime; float timePassedHours = (float)(timePassed / (1d / 24)); float timePassedMinutes = (float)(timePassedHours * 60); if (timePassedMinutes >= 1) { lastTime = newTime; if (SurvivalHelper.IsSurvival()) { StatManager.coffee.Value += SurvivalHelper.GetChangeValue(timePassedMinutes, coffeeFactor); float oldCoffeeMod = StatManager.tiredness.GetModifier("coffee"); float newCoffeeMod = (StatManager.coffee.RealValue / 100) * -30f; if (Math.Abs(oldCoffeeMod - newCoffeeMod) >= 0.5f) { StatManager.tiredness.SetModifier("coffee", Stat.ModifierType.ValueAbsolute, newCoffeeMod); } } else { float oldCoffeeMod = StatManager.tiredness.GetModifier("coffee"); if (oldCoffeeMod != 0f) { StatManager.tiredness.SetModifier("coffee", Stat.ModifierType.ValueAbsolute, 0f); } } if (sleeping) { if (sleepLocation == SleepLocation.Bed) { float hpOut = Player.main.liveMixin.health + SurvivalHelper.GetChangeValue(timePassedMinutes, healthFactorSleepingEfficient); hpOut = hpOut > 100 ? 100 : hpOut < 0 ? 0 : hpOut; Player.main.liveMixin.health = hpOut; if (SurvivalHelper.IsSurvival()) { StatManager.sleep.Value += SurvivalHelper.GetChangeValue(timePassedMinutes, sleepFactorSleepingEfficient); StatManager.tiredness.Value += SurvivalHelper.GetChangeValue(timePassedMinutes, tirednessFactorSleepingEfficient); if (StatManager.sleep.RealValue >= 100) { StopSleep(Player.main, false); } } } else { float hpOut = Player.main.liveMixin.health + SurvivalHelper.GetChangeValue(timePassedMinutes, healthFactorSleepingInefficient); hpOut = hpOut > 100 ? 100 : hpOut < 0 ? 0 : hpOut; Player.main.liveMixin.health = hpOut; if (SurvivalHelper.IsSurvival()) { StatManager.sleep.Value += SurvivalHelper.GetChangeValue(timePassedMinutes, sleepFactorSleepingInefficient); StatManager.tiredness.Value += SurvivalHelper.GetChangeValue(timePassedMinutes, tirednessFactorSleepingInefficient); if (StatManager.sleep.RealValue >= 100) { StopSleep(Player.main, false); } } } if (SurvivalHelper.IsSurvival()) { Survival pSurvival = Player.main.GetComponent <Survival>(); pSurvival.food += SurvivalHelper.GetChangeValue(timePassedMinutes, foodFactorSleeping); pSurvival.water += SurvivalHelper.GetChangeValue(timePassedMinutes, waterFactorSleeping); if (pSurvival.food <= 10f || pSurvival.water <= 10f) { StopSleep(Player.main, false); if (pSurvival.food <= 10f) { pSurvival.foodWarningSounds[1].Play(); } else if (pSurvival.water <= 10f) { pSurvival.waterWarningSounds[1].Play(); } } } } else if (sitting) { if (SurvivalHelper.IsSurvival()) { StatManager.sleep.Value += SurvivalHelper.GetChangeValue(timePassedMinutes, sleepFactorNormal); } // TODO Find a good way to replenish stamina (TBD) and tiredness. } else { if (SurvivalHelper.IsSurvival()) { StatManager.sleep.Value += SurvivalHelper.GetChangeValue(timePassedMinutes, sleepFactorNormal); StatManager.tiredness.Value += SurvivalHelper.GetChangeValue(timePassedMinutes, tirednessFactorNormal); } } if (SurvivalHelper.IsSurvival()) { if (StatManager.sleep.RealValue <= 0) { Player.main.liveMixin.TakeDamage(-SurvivalHelper.GetChangeValue(timePassedMinutes, healthFactorDying), default, DamageType.Starve);