public async Task ResetPasswordAsync(Guid tenantCode, Guid idUser, string emails) { var repoUser = _uow.GetRepository <IUserRepository>(); var user = await repoUser.FindByIdAsync(idUser); if (user == null) { throw new Exception("Tài khoản không tồn tại"); } var password = RandomExtension.Random(10); user.PasswordHash = _passwordHasher.HashPassword(user, password); repoUser.Update(user); await _uow.CommitAsync(); ////gửi mail //var db = _redis.GetDatabase(); //await db.ListLeftPushAsync(KeyQueueBackground.SendMail, JsonConvert.SerializeObject(new //{ // Action = "ResetPassword", // Datas = JsonConvert.SerializeObject(new // { // Emails = emails, // Password = password, // TenantCode = tenantCode, // IdUser = user.Id // }) //})); }
public void LeaveComment(IEnumerable <Comment> comments) { foreach (var comment in comments) { if (comment.Email == "RandomMail") { //Place where you should change end of the email comment.Email = $"{RandomExtension.RandomString(5)}{"@putYourFakeDomain.me"}"; } if (comment.Content == "RandomText") { comment.Content = RandomExtension.RandomString(10); } if (comment.Author == "RandomText") { comment.Author = RandomExtension.RandomString(10); } Driver.ClickOnElement(homePageLocators.LeaveComment); Driver.WaitForClickable(homePageLocators.CommentTextBox); Driver.FindElement(homePageLocators.CommentTextBox).SendKeys(comment.Content); Driver.WaitForClickable(homePageLocators.Author); Driver.FindElement(homePageLocators.Author).SendKeys(comment.Author); Driver.WaitForClickable(homePageLocators.Email); Driver.FindElement(homePageLocators.Email).SendKeys(comment.Email); Driver.ClickOnElement(homePageLocators.PostComment); } }
public async Task ShiaDoIt(CommandContext context) { string shiaLine = RandomExtension.Choose(new List <string> { "Yesterday, you said tomorrow... So just... DO IT", "Just... DO IT!", "Don't let your dreams be dreams!", "Some people dream success, but you're going to get out there, and you're going to work HARD AT IT!", "NOTHING IS IMPOSSIBLE" }); await context.Channel.SendFileAsync(Path.Combine(Directory.GetCurrentDirectory(), $"Images{Path.DirectorySeparatorChar}shiadoit.gif"), shiaLine); }
public void ProcessRestart() { Nodes.Clear(); foreach (Transform node in NodeParent.transform) { Destroy(node.gameObject); } Targets.Clear(); for (int i = 0; i < 3; i++) { Targets.Add(RandomExtension.RangeExcluded((int)InitialTargetInterval.x, (int)InitialTargetInterval.y, Targets.ToArray())); } for (int x = 0; x < GridSize.x; x++) { for (int y = 0; y < GridSize.y; y++) { var node = (Instantiate(NodePrefab) as GameObject).GetComponent <Node>(); node.Position = new Vector2(x, y); node.transform.parent = NodeParent.transform; Nodes.Add(node); } } for (int i = 0; i < InitialNumberCount; i++) { Nodes.FindAll(n => n.Number == 0).Random().Number = Random.Range((int)InitialNumberInterval.x, (int)InitialNumberInterval.y + 1); } OnRestartGame(); }
public async Task CsiMiami(CommandContext context) { string csiLine = RandomExtension.Choose(new List <string> { "Looks like you aren't letting your memes... be dreams.", "Looking at the scene I'm convinced our suspect is will smith. He left some... fresh prints", "Fool me once, shame on you. Fool me twice...", "I don't always listen to the Who, but when I do I like to scream...", "CSI Miami was cancelled. I guess it was time for miami to go into... retirement." }); await context.Channel.SendFileAsync(Path.Combine(Directory.GetCurrentDirectory(), $"Images{Path.DirectorySeparatorChar}csimiami.png"), csiLine); }
IEnumerator WaitAndFly() { yield return(new WaitForSeconds(ChangePositionIdleInterval + Random.Range(-ChangePositionIdleTolerance, ChangePositionIdleTolerance))); switch (RandomExtension.WeightedRandom(new float[] { DragonManager.Instance.waypoints.Length, DragonManager.Instance.nests.Length, DragonManager.Instance.sitpoints.Length })) { case 0: DB.targetPoint = DragonManager.Instance.waypoints [Random.Range(0, DragonManager.Instance.waypoints.Length)].position; DB.targetType = DragonTargetType.Flypoint; sit = false; break; case 1: DB.targetPoint = DragonManager.Instance.nests [Random.Range(0, DragonManager.Instance.nests.Length)].position; DB.targetType = DragonTargetType.Nestpoint; sit = true; break; case 2: Transform tar = DragonManager.Instance.sitpoints [Random.Range(0, DragonManager.Instance.sitpoints.Length)]; DB.targetPoint = tar.position; DB.targetRotation = tar.rotation; DB.targetType = DragonTargetType.Sitpoint; sit = true; break; } DB.setTarget = true; }
private Vector2 RandomPosition() { int side = Random.Range(0, 4); Vector2 result; do // FIXME This is a really lazy way to solve the problem... { result = RandomExtension.Range(Vector2.zero, spawnRangeMax); } while (result.x < spawnRangeMin.x && result.y < spawnRangeMin.y); switch (side) { case 0: break; case 1: result.x *= -1.0f; break; case 2: result.y *= -1.0f; break; case 3: result *= -1.0f; break; } Debug.Log($"Spawned at ({result.x:F2}, {result.y:F2})"); return(result); }
private IEnumerator OnStartAimAtCoroutine(TargetEffect effect) { Vector3 ps, up, dest, dir; float force = 0f; Rigidbody rb; if (!this.target) { yield break; } // Initialize force = 5f; up = this.myTransform.up; ps = this.target.position + (RandomExtension.OnUnitAxisCircle(up) * AIM_TARGET_APPEAR_RADIUS); // Set effect effect.SetOrientation(ps + (up * AIM_TARGET_HEIGHT), up); effect.Launch(this.turret.turretData.aimTargetSmooth, AIM_TARGET_FADE_SPEED); rb = effect.GetComponent <Rigidbody>(); while (this.target) { dest = this.target.position + (up * AIM_TARGET_HEIGHT); dir = dest - rb.position; rb.AddForce(dir * force, ForceMode.Acceleration); if (force < AIM_TARGET_SMOOTH_LIMIT) { force += 25f * Time.deltaTime; } yield return(Yielders.fixedUpdate); } }
public async Task <IActionResult> PostAsync([FromBody] UserModel model) { var tenantCode = await _workcontext.GetTenantCodeAsync(); //Nếu ko nhập pasword sẽ tự động random if (string.IsNullOrEmpty(model.Password)) { model.Password = RandomExtension.Random(10); } var idUser = await _identityService.CreateAsync(tenantCode, new CreateUserModel { Username = model.UserName, Password = model.Password, FullName = model.Infos.FullName, PhoneNumber = model.PhoneNumber, Email = model.Email, Metadata = model.Metadata }); var repoUser = _uow.GetRepository <IUserRepository>(); foreach (var idRole in model.IdRoles) { await repoUser.AssignRoleToUserAsync(idUser, idRole); } await _uow.CommitAsync(); //Tạo job send mail return(Ok()); }
public bool OnHit(CharacterStateControl attacker, CharacterStateControl target) { if (SkillStatus.onHitRate100Percent) { return(true); } float num = this.hitRate; if (Tolerance.OnInfluenceToleranceAffectEffect(this.type)) { Tolerance tolerance = target.tolerance; Strength affectEffectStrength = tolerance.GetAffectEffectStrength(this.type); if (affectEffectStrength == Strength.Strong) { num *= 0.5f; } else if (affectEffectStrength == Strength.Weak) { num *= 1.5f; } else if (affectEffectStrength == Strength.Invalid) { num *= 0f; } } else if (attacker != null) { num += this.GetSkillHitRateCorrectionValue(attacker); } return(RandomExtension.Switch(Mathf.Clamp01(num))); }
public void ShuffleWordLists() { System.Random rnd = new System.Random(); RandomExtension.Shuffle(rnd, Level1WordList); Debug.Log("Shuffled Level 1 Word List."); RandomExtension.Shuffle(rnd, Level2WordList); Debug.Log("Shuffled Level 2 Word List."); }
public void NextNumberTest() { Random random = new Random(); int length = 5; string actual; actual = RandomExtension.NextNumber(random, length); Assert.AreEqual(actual.Length, length); }
float RandomGaussianTolerance(float tolerance) { float result = Mathf.Abs(RandomExtension.NextGaussianFloat() * tolerance / 3f); if (result > tolerance) { result = tolerance; } return(result); }
public void NextBytesTest() { Random random = _Rnd; int length = 8; byte[] actual; actual = RandomExtension.NextBytes(random, length); actual.Length.AreEqualWith(length); }
/// <summary> ///NextItem 的测试 ///</summary> public void NextItemTestHelper <T>() { Random random = null; IList <T> etor = null; T expected = default(T); T actual; actual = RandomExtension.NextItem <T>(random, etor); Assert.AreEqual(expected, actual); Assert.Inconclusive("验证此测试方法的正确性。"); }
/// <summary> ///NextEnum 的测试 ///</summary> public void NextEnumTestHelper <T>() where T : struct { Random random = null; T expected = new T(); T actual; actual = RandomExtension.NextEnum <T>(random); Assert.AreEqual(expected, actual); Assert.Inconclusive("验证此测试方法的正确性。"); }
public void NextStringTest() { Random random = null; int length = 0; string expected = string.Empty; string actual; actual = RandomExtension.NextString(random, length); Assert.AreEqual(expected, actual); Assert.Inconclusive("验证此测试方法的正确性。"); }
protected override IEnumerator MainRoutine() { CharacterStateControl attacker = base.battleStateData.currentSelectCharacterState; if ((!attacker.isEnemy && !RandomExtension.Switch(base.hierarchyData.playerPursuitPercentage)) || (attacker.isEnemy && !RandomExtension.Switch(base.hierarchyData.enemyPursuitPercentage))) { yield break; } if (!attacker.currentSkillStatus.ThisSkillIsAttack) { yield break; } bool isConfusion = false; SufferStateProperty confusionSuffer = attacker.currentSufferState.GetSufferStateProperty(SufferStateProperty.SufferType.Confusion); if (confusionSuffer.isActive && confusionSuffer.GetOccurrenceFreeze()) { isConfusion = true; } CharacterStateControl[] targets; if (!isConfusion) { targets = ((!attacker.isEnemy) ? base.battleStateData.enemies : base.battleStateData.playerCharacters); } else { targets = (attacker.isEnemy ? base.battleStateData.enemies : base.battleStateData.playerCharacters); } int count = 0; for (int i = 0; i < targets.Length; i++) { if (targets[i].isDied) { count++; } } if (count == targets.Length) { yield break; } do { attacker.targetCharacter = targets[UnityEngine.Random.Range(0, targets.Length)]; }while (attacker.targetCharacter.isDied); attacker.isSelectSkill = attacker.SkillIdToIndexOf(base.stateManager.publicAttackSkillId); base.SetState(typeof(SubStatePvPSkillDetailsFunction)); while (base.isWaitState) { yield return(null); } yield break; }
public void Setup() { bytes_ = RandomExtension.RandomBytes(1024); file_ = new FileStream("HDF5Benchmark_FileIO.dat", FileMode.Create, FileAccess.ReadWrite); fileRows_ = 0; h5file_ = H5F.create("HDF5Benchmark_FileIO.h5", H5F.ACC_TRUNC); dataSet_ = HDF5Helper.CreateDataSet(h5file_, "data", H5T.NATIVE_UINT8, new ulong[] { 0 }, new ulong[] { H5S.UNLIMITED }, new ulong[] { (ulong)bytes_.Length }); dataSetRows_ = 0; }
private void Generate(Dictionary <string, Texture2D> allTextures) { int length = allImages.Count; var shuffled = RandomExtension.ShuffledArray(length); List <string> namesOfTextures = new List <string>(allTextures.Keys); Texture2D texture = null; for (int i = 0, j = 0; i < length; i += 2, j++) { texture = allTextures[namesOfTextures[j]]; allImages[shuffled[i]].id = shuffled[i]; allImages[shuffled[i + 1]].id = shuffled[i + 1]; allImages[shuffled[i]].image.texture = texture; allImages[shuffled[i + 1]].image.texture = texture; allImages[shuffled[i]].paired = allImages[shuffled[i + 1]].id; allImages[shuffled[i + 1]].paired = allImages[shuffled[i]].id; } texture = null; foreach (var item in allImages) { AnimationOn(item.image, true); } foreach (var item in allImages) { item.button.onClick.AddListener(() => { var myself = item; // clojure from item AnimationOn(myself.image, true); if (first == null) { first = myself; } else { if (myself.paired == first.id) { RightGuess(new ValueTuple <int, int>(myself.id, first.id)); } else { WrongGuess(new ValueTuple <int, int>(myself.id, first.id)); } first = null; } }); } }
public Furniture GetRandomWordInFurniture(Topic topic) { IRandomExtension _rndExtension = new RandomExtension(); var words = topic.Furnitures; if (words.Count == 0) { return(null); } var randomNumber = _rndExtension.Random(0, words.Count); return(words[randomNumber]); }
public LTCity GetRandomWordInLTCity(Topic topic) { IRandomExtension _rndExtension = new RandomExtension(); var words = topic.LTCities; if (words.Count == 0) { return(null); } var randomNumber = _rndExtension.Random(0, words.Count); return(words[randomNumber]); }
private static int CompareHate(CharacterStateControl x, CharacterStateControl y) { if (x == y) { return(0); } int num = CharacterStateControlSorter.CompareHateBase(x, y); if (Mathf.Abs(num) == 1) { return(num); } return(RandomExtension.IntPlusMinus()); }
public bool GetSleepGetupOccurrenceDamage() { foreach (List <SufferStateProperty.Data> list in this.dataDictionary.Values) { foreach (SufferStateProperty.Data data in list) { if (data.isActive && RandomExtension.Switch(data.damageGetupIncidenceRate)) { return(true); } } } return(false); }
private bool GetEscapeResult() { foreach (List <SufferStateProperty.Data> list in this.dataDictionary.Values) { foreach (SufferStateProperty.Data data in list) { if (data.isActive && RandomExtension.Switch(data.escapeRate)) { return(true); } } } return(false); }
DifficultyLevel CurrentDifficulty = DifficultyLevel.Level1; //This determines the list that is pulled from to generate the random words. void Start() { //Cache the word lists here. //WordBox = GameObject.Find("txtWordBox"); Level1WordList = File.ReadAllLines(Directory.GetCurrentDirectory() + "/Assets/WordLibraries/Level1.txt"); Debug.Log("Cached Level 1 Word List. Number of words loaded: " + Level1WordList.Length.ToString()); Level2WordList = File.ReadAllLines(Directory.GetCurrentDirectory() + "/Assets/WordLibraries/Level2.txt"); Debug.Log("Cached Level 2 Word List. Number of words loaded: " + Level2WordList.Length.ToString()); CooldownRound1WordList = File.ReadAllLines(Directory.GetCurrentDirectory() + "/Assets/WordLibraries/CooldownRoundList.txt"); Debug.Log("Cached Cooldown Round 1 Word List. Number of words loaded: " + CooldownRound1WordList.Length.ToString()); System.Random rnd = new System.Random(); RandomExtension.Shuffle(rnd, Level1WordList); Debug.Log("Shuffled Level 1 Word List."); }
public void NextBoolTest() { Random random = _Rnd; bool expected = false; bool actual; actual = RandomExtension.NextBool(random); if (actual) { actual.IsTrue(); } else { Assert.AreEqual(expected, actual); } }
private static void Main(string[] args) { RandomExtension myRandom = new RandomExtension(); ; for (int index = 1; index <= 10; index++) { Console.WriteLine(myRandom.NextDouble(1.2, 3.3)); } Random random = new Random(); for (int index = 1; index <= 10; index++) { Console.WriteLine(random.NextDouble(1.2, 3.3)); } }
private void ClearTolerance(CharacterStateControl target, AffectEffectProperty affectEffectProperty) { Dictionary <SufferStateProperty.SufferType, float> dictionary = null; if (affectEffectProperty.toleranceClearType == 0) { dictionary = new Dictionary <SufferStateProperty.SufferType, float> { { SufferStateProperty.SufferType.ChangeToleranceUp, affectEffectProperty.clearPoisonIncidenceRate }, { SufferStateProperty.SufferType.ChangeToleranceDown, affectEffectProperty.clearPoisonIncidenceRate } }; } else if (affectEffectProperty.toleranceClearType == 73) { dictionary = new Dictionary <SufferStateProperty.SufferType, float> { { SufferStateProperty.SufferType.ChangeToleranceUp, affectEffectProperty.clearPoisonIncidenceRate } }; } else if (affectEffectProperty.toleranceClearType == 74) { dictionary = new Dictionary <SufferStateProperty.SufferType, float> { { SufferStateProperty.SufferType.ChangeToleranceDown, affectEffectProperty.clearPoisonIncidenceRate } }; } foreach (KeyValuePair <SufferStateProperty.SufferType, float> keyValuePair in dictionary) { if (RandomExtension.Switch(keyValuePair.Value) && target.currentSufferState.FindSufferState(keyValuePair.Key)) { target.currentSufferState.RemoveSufferState(keyValuePair.Key, false); } } }
public void nextBoolTest() { Random r = new Random(0xb00b1e5); int trueCount = 0; int count = 1000000; for (int i = 0; i < count; i++) { if (RandomExtension.nextBool(r)) { trueCount++; } } double diffRatio = Math.Abs(((count / 2.0) - trueCount)) / (double)count; Assert.IsTrue(diffRatio < 0.0005); //0.005% }