//--------------------------------------------------- public void AddScore(Score.Type scoreType) { if (!this.isRunning) { return; } int additionalScore = Score.GetScore(scoreType); this.score = Mathf.Clamp(this.score + additionalScore, Score.MinScore, Score.MaxScore); this.UpdateScoreText(this.score); SIGVerseLogger.Info("Score (grasp) add [" + Score.GetScore(scoreType) + "], Challenge " + HumanNaviConfig.Instance.numberOfTrials + " Score=" + this.score); // Send the Score Notification ScoreStatus scoreStatus = new ScoreStatus(additionalScore, this.score, HumanNaviConfig.Instance.GetTotalScore()); foreach (GameObject scoreNotificationDestination in this.scoreNotificationDestinations) { ExecuteEvents.Execute <IScoreHandler> ( target: scoreNotificationDestination, eventData: null, functor: (reciever, eventData) => reciever.OnScoreChange(scoreStatus) ); } }
public new void AsJson(JsonWriter writer, string baseUrl) { writer.WriteStartObject(); base.AsJson(writer, baseUrl); writer.WritePropertyName("lineItem"); LineItem.AsJsonReference(writer, baseUrl); writer.WritePropertyName("student"); Student.AsJsonReference(writer, baseUrl); writer.WritePropertyName("scoreStatus"); writer.WriteValue(ScoreStatus.ToString().Replace('_', ' ')); writer.WritePropertyName("score"); writer.WriteValue(Score.ToString()); writer.WritePropertyName("scoreDate"); writer.WriteValue(ScoreDate.ToString("yyyy-MM-dd")); if (!string.IsNullOrEmpty(Comment)) { writer.WritePropertyName("comment"); writer.WriteValue(Comment); } writer.WriteEndObject(); writer.Flush(); }
public override ScoreStatus CalculateScoreStatus(List <EDMscore> scores) { if (this.ColorStatus != ScoreStatus.None) { return(this.ColorStatus); } //this one just returns its score color //RED, YELLOW, or GREEN ScoreStatus score = ScoreStatus.None; switch (Answer) { case "Y": score = ScoreStatus.Green; break; case "N": score = ScoreStatus.Red; break; default: score = ScoreStatus.Yellow; break; } this.ColorStatus = score; scores.Add(new EDMscore() { Title_Id = this.Title_Id, Color = this.ColorStatus.ToString() }); return(score); }
public List <ScoreStatus> GetWinner() //kan vara fler än en vinnare { List <Scores> ScoresList = new List <Scores>(); List <Game> GamesList = new List <Game>(); List <ScoreStatus> ScoresStatusList = new List <ScoreStatus>(); ScoreCollection.Reading(); //läser in användarna GameCollection.Reading(); //läser in alla matcher PersonCollection.Reading(); var getScores = ScoreCollection.GetEnumerator(); var getGames = GameCollection.GetEnumerator(); var getAllPersons = PersonCollection.GetEnumerator(); foreach (var items in getScores) { ScoresList.Add(items); } foreach (var items in getGames) { GamesList.Add(items); } var percentage = 0.0; var amountScores = 0; //Hur många gånger en person återkommer i Gamesfilen var amountGames = 0; foreach (var items in getAllPersons) { var text = $"{items.ContestNumber} {items.FirstName} {items.LastName}"; amountScores = ScoresList.Where(x => x.Winner == text).Count(); amountGames = GamesList.Where(x => x.PersonOne == text || x.PersonTwo == text).Count(); // Create math proxy MathProxy proxy = new MathProxy(); if (amountGames >= 10) { if (amountScores == 0) { percentage = proxy.Mul(amountScores, amountGames); } percentage = proxy.Div((amountScores * 100), amountGames); var ScoresStatus = new ScoreStatus(amountGames, amountScores, items.FirstName, items.LastName, percentage, items.ContestNumber); ScoresStatusList.Add(ScoresStatus); } } Builder.Append($"\n{DateTime.Now} - Användaren får den slutgiltiga vinnaren utskriven "); File.AppendAllText(FilePath, Builder.ToString()); Builder.Clear(); return(ScoresStatusList); }
private void AddToScore(Game game, string playerId, ScoreStatus scoreStatus) { this.Data.Scores.Add(new Score() { GameId = game.GameId, PlayerId = Guid.Parse(playerId), ScoreStatus = scoreStatus }); }
public void CreateScore(Guid gameId, string userId, ScoreStatus status) { var score = new Score() { GameId = gameId, UserId = userId, Status = status }; context.Scores.Add(score); context.SaveChanges(); }
//--------------------------------------------------- public void AddScore(Score.ScoreType scoreType) { if (!this.isRunning) { return; } int additionalScore = Score.GetScore(scoreType); this.score = Mathf.Clamp(this.score + additionalScore, Score.MinScore, Score.MaxScore); this.UpdateScoreText(this.score); SIGVerseLogger.Info("Score (" + scoreType.ToString() + ") add [" + Score.GetScore(scoreType) + "], Challenge " + HumanNaviConfig.Instance.numberOfTrials + " Score=" + this.score); // Send the Score Notification ScoreStatus scoreStatus = new ScoreStatus(additionalScore, this.score, HumanNaviConfig.Instance.GetTotalScore()); foreach (GameObject scoreNotificationDestination in this.scoreNotificationDestinations) { ExecuteEvents.Execute <IScoreHandler> ( target: scoreNotificationDestination, eventData: null, functor: (reciever, eventData) => reciever.OnScoreChange(scoreStatus) ); } if (scoreType == Score.ScoreType.IncorrectObjectIsGrasped) { this.wrongObjectGraspCount++; } if (this.maxWrongObjectGraspCount > 0) { if (this.wrongObjectGraspCount >= this.maxWrongObjectGraspCount) { foreach (GameObject reachMaxWrongObjectGraspCountDestination in this.reachMaxWrongObjectGraspCountDestinations) { ExecuteEvents.Execute <IReachMaxWrongObjectGraspCountHandler> ( target: reachMaxWrongObjectGraspCountDestination, eventData: null, functor: (reciever, eventData) => reciever.OnReachMaxWrongObjectGraspCount() ); } } } }
public void CheckCupWinner(string cupName) { List <ScoreStatus> ScoresStatusList = new List <ScoreStatus>(); GamePersonTesting getGameAndUser = new GamePersonTesting(); var getAllPersons = getGameAndUser.PersonData(); var returned = ""; int amountScores = 0; int amountGames = 0; double percentage = 0; var ScoresList = getGameAndUser.ScoresData(); var GamesList = getGameAndUser.GamesData(); var getOutGames = GamesList.Where(x => x.Name == cupName); foreach (var items in getAllPersons) { var text = $"{items.ContestNumber} {items.FirstName} {items.LastName}"; amountScores = ScoresList.Where(x => x.Winner == text).Count(); amountGames = getOutGames.Where(x => x.PersonOne == text || x.PersonTwo == text).Count(); MathProxy proxy = new MathProxy(); if (amountGames >= 10) { if (amountScores == 0) { percentage = proxy.Mul(amountScores, amountGames); } percentage = proxy.Div((amountScores * 100), amountGames); var ScoresStatus = new ScoreStatus(amountGames, amountScores, items.FirstName, items.LastName, percentage, items.ContestNumber); ScoresStatusList.Add(ScoresStatus); } } var sort = ScoresStatusList.OrderByDescending(x => x.Percentage).FirstOrDefault(); returned = $"{sort.ContestNumber} {sort.FirstName} {sort.LastName}"; Assert.True(sort.ContestNumber == 1 && sort.FirstName == "Emma" && sort.LastName == "Pestin"); }
public override ScoreStatus CalculateScoreStatus(List <EDMscore> scores) { //if (this.ColorStatus != ScoreStatus.None) // return this.ColorStatus; //this one looks at all its children and //return red if they are all red //yellow if anything is not red but not all green //green if they are all green ScoreStatus score = basicScore(scores); this.ColorStatus = score; scores.Add(new EDMscore() { Title_Id = this.Title_Id, Color = this.ColorStatus.ToString() }); return(score); }
private void CreateScoreAndHistory(Game game, string userId, ScoreStatus status) { var score = new Score() { GameId = game.GameId, UserId = userId, Status = status }; var history = new History() { GameId = game.GameId, UserId = userId, Status = status, Date = DateTime.Now }; context.Scores.Add(score); context.Histories.Add(history); }
public ScoreStatus basicScore(List <EDMscore> scores) { bool yellow = false; bool green = false; bool red = false; foreach (ScoringNode n in this.Children) { switch (n.CalculateScoreStatus(scores)) { case ScoreStatus.Green: green = true; break; case ScoreStatus.Yellow: yellow = true; break; case ScoreStatus.Red: red = true; break; } } ScoreStatus temp = ScoreStatus.None; //its all red if (!green && !yellow) { temp = ScoreStatus.Red; } //all green else if (green && (!red && !yellow)) { temp = ScoreStatus.Green; } // there is some kind of mix else { temp = ScoreStatus.Yellow; } return(temp); }
public void AddTimeScore(float elapsedTime, float timeLimit) { int additionalScore = Mathf.FloorToInt(Score.GetScore(Score.Type.CompletionTime) * ((timeLimit - elapsedTime) / timeLimit)); this.score = Mathf.Clamp(this.score + additionalScore, Score.MinScore, Score.MaxScore); this.UpdateScoreText(this.score); SIGVerseLogger.Info("Score (time) add [" + additionalScore + "], Challenge " + HumanNaviConfig.Instance.numberOfTrials + " Score=" + this.score); // Send the Score Notification ScoreStatus scoreStatus = new ScoreStatus(additionalScore, this.score, HumanNaviConfig.Instance.GetTotalScore()); foreach (GameObject scoreNotificationDestination in this.scoreNotificationDestinations) { ExecuteEvents.Execute <IScoreHandler> ( target: scoreNotificationDestination, eventData: null, functor: (reciever, eventData) => reciever.OnScoreChange(scoreStatus) ); } }
public frmWarning() { InitializeComponent(); // For Non-Blocking UI Application new Thread(new ThreadStart(() => { while (true) { if (!flag) { var Procs = Process.GetProcessesByName("th12"); if (Procs.Length > 0) { // Open TH12.exe with PROCESS_VM_READ (0x0010). _handle = OpenProcess(0x10, false, Procs.FirstOrDefault().Id); if (_handle != null) { flag = true; } } } else { if (!_flag_billion) { int bytesRead = 0; byte[] _buffer = new byte[4]; // Will read 4 bytes of memory /* * Read Level * * In TH12 ~ Undefined Fantastic Object, Level is stored in * [base address] + 0xAEBD0, as 4bytes int value. * */ var readLevel = ReadProcessMemory((int)_handle, 0x004AEBD0, _buffer, 2, ref bytesRead); if (!readLevel) { flag = false; continue; } /* * Level Codes * 0 - Easy; 1 - Normal; 2 - Hard; 3 - Lunatic; ? - Extra * */ if (BitConverter.ToInt16(_buffer, 0) != 3) { ProcStatus.Invoke(new MethodInvoker(() => { ProcStatus.Text = "NOT LUNATIC LEVEL!"; })); Thread.Sleep(100); continue; } else { ProcStatus.Invoke(new MethodInvoker(() => { ProcStatus.Text = "Process Working"; })); } /* * Read Score * * Once level is detected as LUNATIC, * rensenWare reads score from process. * * Score is stored in * [base address] + 0xAEBD0, as 4bytes int value. * */ var readScore = ReadProcessMemory((int)_handle, 0x004B0C44, _buffer, 4, ref bytesRead); if (!readScore) { flag = false; Thread.Sleep(100); continue; } ScoreStatus.Invoke(new MethodInvoker(() => { ScoreStatus.Text = (BitConverter.ToInt32(_buffer, 0) * 10).ToString(); })); /* * One interesting thing, * internally, touhou project process prints score as 10 times of original value. * I don't know why it is. */ if (BitConverter.ToInt32(_buffer, 0) > 20000000) // It is 20,000,000 { _flag_billion = true; } else { _buffer = null; } // Let CPU rest Thread.Sleep(100); } else // When scores 0.2 billion... { // Create Random Key/IV File in Desktop of Current User. File.WriteAllBytes(Program.KeyFilePath, Program.randomKey); File.WriteAllBytes(Program.IVFilePath, Program.randomIV); decryptProgress.Maximum = Program.encryptedFiles.Count; // There's no encrypted Files.... foreach (var path in Program.encryptedFiles) { try { DecryptStatus.Invoke(new MethodInvoker(() => { DecryptStatus.Text = Path.GetFileName(path); })); // Do Nothing! Program.Crypt(path, true); decryptProgress.Value++; // Let CPU rest (?) // Thread.Sleep(100); } catch { continue; } } this.Invoke(new MethodInvoker(() => { MessageBox.Show("Decryption Complete!\nIf there are encrypted files exists, use manual decrypter with key/IV files saved in desktop!"); ButtonManualDecrypt.Visible = true; ButtonExit.Visible = true; })); break; } } Thread.Sleep(100); } })).Start(); }
public string GetWinnerOfSpecificContest(string name) { List <Scores> ScoresList = new List <Scores>(); List <Game> GamesList = new List <Game>(); List <ScoreStatus> ScoresStatusList = new List <ScoreStatus>(); ScoreCollection.Reading(); //läser in användarna GameCollection.Reading(); //läser in alla matcher PersonCollection.Reading(); var getScores = ScoreCollection.GetEnumerator(); var getGames = GameCollection.GetEnumerator(); var getAllPersons = PersonCollection.GetEnumerator(); foreach (var items in getScores) { ScoresList.Add(items); } foreach (var items in getGames) { if (items.Name == name) { GamesList.Add(items); } } var percentage = 0.0; var amountScores = 0; //Hur många gånger en person återkommer i Gamesfilen var amountGames = 0; foreach (var items in getAllPersons) { var text = $"{items.ContestNumber} {items.FirstName} {items.LastName}"; amountScores = ScoresList.Where(x => x.Winner == text).Count(); amountGames = GamesList.Where(x => x.PersonOne == text || x.PersonTwo == text).Count(); // Create math proxy MathProxy proxy = new MathProxy(); if (amountGames >= 10) { if (amountScores == 0) { percentage = proxy.Mul(amountScores, amountGames); } percentage = proxy.Div((amountScores * 100), amountGames); var ScoresStatus = new ScoreStatus(amountGames, amountScores, items.FirstName, items.LastName, percentage, items.ContestNumber); ScoresStatusList.Add(ScoresStatus); } } if (ScoresStatusList.Count > 0) { var sort = ScoresStatusList.OrderByDescending(x => x.Percentage).FirstOrDefault(); //return $"Årets champion: {sort.FirstName} {sort.LastName} vinnar andel: {sort.Percentage}%"; return($"{sort.ContestNumber} {sort.FirstName} {sort.LastName}"); } else { return("Ingen användare har spelat mer än 10 matcher"); } }