public void InsertNewPersonalBestFindingCallNumbers(ModelLeaderBoard modelLeaderBoard, string cs) { using (IDbConnection cnn = new SQLiteConnection(cs)) { var cmd = cnn.Query <ModelLeaderBoard>("Insert Into LEADERBOARD(USER_LIBRARY_CARD_ID,FINDING_CALL_NUMBERS_PERSONAL_BEST)Values" + $"('{modelLeaderBoard.USER_LIBRARY_CARD_ID}','{modelLeaderBoard.FINDING_CALL_NUMBERS_PERSONAL_BEST}')", new DynamicParameters()); } }
void ResiliencePoints(ModelLeaderBoard persona) { int satisf = persona.mySatisfaction; for (int x = 0; x < 4; x++) { if (satisf > 0) { switch (x) { case 0: persona.myEmotional = Random.Range(0, satisf + 1); satisf -= persona.myEmotional; break; case 1: persona.mySocial = Random.Range(0, satisf + 1); satisf -= persona.mySocial; break; case 2: persona.myPhysics = Random.Range(0, satisf + 1); satisf -= persona.myPhysics; break; case 3: persona.myMental = satisf; satisf -= persona.myMental; break; } } } }
public void UpdateNewPersonalBestIdentifyingAreas(ModelLeaderBoard modelLeaderBoard, string cs) { using (IDbConnection cnn = new SQLiteConnection(cs)) { var cmd = cnn.Query <ModelLeaderBoard>("UPDATE LEADERBOARD SET IDENTIFYING_AREAS_PERSONAL_BEST='" + modelLeaderBoard.IDENTIFYING_AREAS_PERSONAL_BEST + "'WHERE USER_LIBRARY_CARD_ID = '" + modelLeaderBoard.USER_LIBRARY_CARD_ID + "'", new DynamicParameters()); } }
public void InsertNewBlankLeaderboardRecord(ModelLeaderBoard modelLeaderBoard, string cs) { using (IDbConnection cnn = new SQLiteConnection(cs)) { var cmd = cnn.Query <ModelLeaderBoard>("Insert Into LEADERBOARD(USER_LIBRARY_CARD_ID,REPLACING_BOOKS_PERSONAL_BEST,IDENTIFYING_AREAS_PERSONAL_BEST,FINDING_CALL_NUMBERS_PERSONAL_BEST)Values" + $"('{modelLeaderBoard.USER_LIBRARY_CARD_ID}','{modelLeaderBoard.REPLACING_BOOKS_PERSONAL_BEST}','{modelLeaderBoard.IDENTIFYING_AREAS_PERSONAL_BEST}','{modelLeaderBoard.FINDING_CALL_NUMBERS_PERSONAL_BEST}')", new DynamicParameters()); } }
public void InsertNewPersonalBestIdentifyingAreas(ModelLeaderBoard modelLeaderBoard, string cs) { using (IDbConnection cnn = new SQLiteConnection(cs)) { var cmd = cnn.Query <ModelLeaderBoard>("Insert Into LEADERBOARD(USER_LIBRARY_CARD_ID,IDENTIFYING_AREAS_PERSONAL_BEST)Values" + $"('{modelLeaderBoard.USER_LIBRARY_CARD_ID}','{modelLeaderBoard.IDENTIFYING_AREAS_PERSONAL_BEST}')", new DynamicParameters()); } }
public void InsertNewPersonalBestReplacingBooks(ModelLeaderBoard modelLeaderBoard, string cs) { using (IDbConnection cnn = new SQLiteConnection(cs)) { var cmd = cnn.Query <ModelLeaderBoard>("Insert Into LEADERBOARD(USER_LIBRARY_CARD_ID,REPLACING_BOOKS_PERSONAL_BEST)Values" + $"('{modelLeaderBoard.USER_LIBRARY_CARD_ID}','{modelLeaderBoard.REPLACING_BOOKS_PERSONAL_BEST}')", new DynamicParameters()); } }
public void UpdateNewPersonalBestFindingCallNumbers(ModelLeaderBoard modelLeaderBoard, string cs) { using (IDbConnection cnn = new SQLiteConnection(cs)) { var cmd = cnn.Query <ModelLeaderBoard>("UPDATE LEADERBOARD SET FINDING_CALL_NUMBERS_PERSONAL_BEST='" + modelLeaderBoard.FINDING_CALL_NUMBERS_PERSONAL_BEST + "'WHERE USER_LIBRARY_CARD_ID = '" + modelLeaderBoard.USER_LIBRARY_CARD_ID + "'", new DynamicParameters()); } }
public void UpdateNewPersonalBestReplacingBooks(ModelLeaderBoard modelLeaderBoard, string cs) { using (IDbConnection cnn = new SQLiteConnection(cs)) { var cmd = cnn.Query <ModelLeaderBoard>("UPDATE LEADERBOARD SET REPLACING_BOOKS_PERSONAL_BEST='" + modelLeaderBoard.REPLACING_BOOKS_PERSONAL_BEST + "'WHERE USER_LIBRARY_CARD_ID = '" + modelLeaderBoard.USER_LIBRARY_CARD_ID + "'", new DynamicParameters()); } }
public List <ModelLeaderBoard> GetPersonalBestFindingCallNumbers(ModelLeaderBoard modelLeaderBoard, string cs) { using (IDbConnection cnn = new SQLiteConnection(cs)) { var list = cnn.Query <ModelLeaderBoard>("SELECT FINDING_CALL_NUMBERS_PERSONAL_BEST FROM LEADERBOARD WHERE USER_LIBRARY_CARD_ID = '" + modelLeaderBoard.USER_LIBRARY_CARD_ID + "'", new DynamicParameters()); return(list.ToList()); } }
public List <ModelLeaderBoard> GetPersonalBestIdentifyingAreas(ModelLeaderBoard modelLeaderBoard, string cs) { using (IDbConnection cnn = new SQLiteConnection(cs)) { var list = cnn.Query <ModelLeaderBoard>("SELECT IDENTIFYING_AREAS_PERSONAL_BEST FROM LEADERBOARD WHERE USER_LIBRARY_CARD_ID = '" + modelLeaderBoard.USER_LIBRARY_CARD_ID + "'", new DynamicParameters()); return(list.ToList()); } }
public List <ModelLeaderBoard> GetPersonalBestReplacingBooks(ModelLeaderBoard modelLeaderBoard, string cs) { using (IDbConnection cnn = new SQLiteConnection(cs)) { var list = cnn.Query <ModelLeaderBoard>("SELECT REPLACING_BOOKS_PERSONAL_BEST FROM LEADERBOARD WHERE USER_LIBRARY_CARD_ID = '" + modelLeaderBoard.USER_LIBRARY_CARD_ID + "'", new DynamicParameters()); return(list.ToList()); } }
public void SetCard(ModelLeaderBoard card) { //criacard avtar.sprite = card.myface; satisfidText.text = card.mySatisfaction.ToString(); emotional.text = card.myEmotional.ToString(); social.text = card.mySocial.ToString(); mental.text = card.myMental.ToString(); physic.text = card.myPhysics.ToString(); }
private void UpdateLeaderBoardPersonalBest() { try { LearningGames lg = new LearningGames(); RegisterLogin rl = new RegisterLogin(); ModelLeaderBoard mlb = new ModelLeaderBoard { USER_LIBRARY_CARD_ID = currentUser }; List <ModelLeaderBoard> getPersonalBest = lg.GetPersonalBestIdentifyingAreas(mlb, connectionString); tbPBSCore.Text = getPersonalBest[0].IDENTIFYING_AREAS_PERSONAL_BEST.ToString(); if (getPersonalBest.Count == 1) { tbPBSCore.Text = getPersonalBest[0].IDENTIFYING_AREAS_PERSONAL_BEST.ToString(); } getAllRecords = lg.GetIdentifyingAreasChampion(connectionString); if (getAllRecords[0].IDENTIFYING_AREAS_PERSONAL_BEST == 0) { tbChampionName.Text = "No Champion Yet !"; } else { tbChampScore.Text = getAllRecords[0].IDENTIFYING_AREAS_PERSONAL_BEST.ToString(); List <ModelLeaderBoard> getBestUserId = lg.GetChampionNameIdentifyingAreas(getAllRecords[0].IDENTIFYING_AREAS_PERSONAL_BEST.ToString(), connectionString); int id = getBestUserId[0].USER_LIBRARY_CARD_ID; if (id == currentUser) { isChamp = true; } List <ModelRegisterLogin> getBestUser = rl.GetUser(id, connectionString); tbChampionName.Text = getBestUser[0].USER_FNAME + " " + getBestUser[0].USER_LNAME; } } catch (Exception) { tbChampionName.Text = "No Champion Yet !"; } }
ModelLeaderBoard Player() { ModelLeaderBoard player = new ModelLeaderBoard(); player.isPlayer = true; player.myface = playerFace; player.myMental = GameManagerResilience.mentalTimes; player.myPhysics = GameManagerResilience.physicsTimes; player.mySocial = GameManagerResilience.socialTimes; player.myEmotional = GameManagerResilience.emotionaltimes; player.mySatisfaction = GameManagerResilience.GetInstance().TotalSatisfaction; return(player); }
void CreatePersonas() { if (otherPersonas != null) { ReShuffle(personasFace); int i = maxLeaderboards - 1; for (int x = 0; x < i; x++) { otherPersonas[x] = new ModelLeaderBoard(); otherPersonas[x].myface = personasFace[x]; otherPersonas[x].myPersona = (ModelLeaderBoard.Persona)x; } } }
//This method inputs new user data into the database public void RegisterNewUser() { LearningGames lg = new LearningGames(); try { var login = Int32.Parse(tbUsername.Text); var password = tbPassword.Password; var fName = tbFName.Text; var lName = tbLName.Text; var c = new ModelRegisterLogin { USER_LIBRARY_CARD_ID = login, USER_PASSWORD = password, USER_FNAME = fName, USER_LNAME = lName }; cl.InsertUserRegData(c, connectionString); var ml = new ModelLeaderBoard { USER_LIBRARY_CARD_ID = login, REPLACING_BOOKS_PERSONAL_BEST = "Not Set", IDENTIFYING_AREAS_PERSONAL_BEST = 0, FINDING_CALL_NUMBERS_PERSONAL_BEST = 0 }; lg.InsertNewBlankLeaderboardRecord(ml, connectionString); MessageBox.Show($"Registration Successful!" + "\nYou may now Login, " + tbFName.Text + " !"); tabLoginRegister.SelectedIndex = 1; } catch (System.Exception) { MessageBox.Show("User already exists or the input for LIBRARY CARD ID is not a number\nPlease try again", "Error"); tbUsername.Text = ""; tbPassword.Password = ""; } }
private void InsertUpdateRecords() { LearningGames lg = new LearningGames(); ModelLeaderBoard mlb = new ModelLeaderBoard { USER_LIBRARY_CARD_ID = currentUser, IDENTIFYING_AREAS_PERSONAL_BEST = userCurrentScore }; List <ModelLeaderBoard> rec = lg.GetPersonalBestIdentifyingAreas(mlb, connectionString); if (rec.Count == 0) { lg.InsertNewPersonalBestIdentifyingAreas(mlb, connectionString); } else { lg.UpdateNewPersonalBestIdentifyingAreas(mlb, connectionString); } }
private void InsertUpdateRecords() { LearningGames lg = new LearningGames(); ModelLeaderBoard mlb = new ModelLeaderBoard { USER_LIBRARY_CARD_ID = currentUser, FINDING_CALL_NUMBERS_PERSONAL_BEST = currentGameScore }; List <ModelLeaderBoard> rec = lg.GetPersonalBestFindingCallNumbers(mlb, connectionString); if (rec.Count == 0) { lg.InsertNewPersonalBestFindingCallNumbers(mlb, connectionString); } else { lg.UpdateNewPersonalBestFindingCallNumbers(mlb, connectionString); } }
//Updates labels related to personal best score and champion private void UpdateLeaderBoardPersonalBest() { try { LearningGames lg = new LearningGames(); RegisterLogin rl = new RegisterLogin(); ModelLeaderBoard mlb = new ModelLeaderBoard { USER_LIBRARY_CARD_ID = currentUser }; List <ModelLeaderBoard> getPersonalBest = lg.GetPersonalBestReplacingBooks(mlb, connectionString); if (getPersonalBest.Count == 1) { lbPersonalBest.Text = getPersonalBest[0].REPLACING_BOOKS_PERSONAL_BEST.ToString(); pb = getPersonalBest[0].REPLACING_BOOKS_PERSONAL_BEST.ToString(); } getAllRecords = lg.GetAllLeadBoardRecords(connectionString); SelectionSortBestTime(); lbChampTime.Text = getAllRecords[0].REPLACING_BOOKS_PERSONAL_BEST; List <ModelLeaderBoard> getBestUserId = lg.GetChampionNameReplacingBooks(getAllRecords[0].REPLACING_BOOKS_PERSONAL_BEST.ToString(), connectionString); int id = getBestUserId[0].USER_LIBRARY_CARD_ID; List <ModelRegisterLogin> getBestUser = rl.GetUser(id, connectionString); tbChampionName.Text = getBestUser[0].USER_FNAME + " " + getBestUser[0].USER_LNAME; ChampTime = getAllRecords[0].REPLACING_BOOKS_PERSONAL_BEST; } catch (Exception) { tbChampionName.Text = "No Champion Yet !"; } }
private void btStartStop_Click(object sender, RoutedEventArgs e) { if (btStartStop.Content.Equals("START") || btStartStop.Content.Equals("TRY AGAIN?")) { stopwatch.Reset(); tbTimeDisplay.Text = startTimeDisplay; btStartStop.Content = "STOP"; btDown.IsEnabled = true; btUp.IsEnabled = true; unsortedListString.Clear(); usersList.Clear(); userOrderLinkedList.Clear(); sortedList.Clear(); for (int i = 0; i < 10; i++) { randomNumber = GenerateRandomNumber(); author = GenerateRandomAuthor(); callNumber = randomNumber + " " + author; DataGridBind dgb = new DataGridBind { CALL_NUMBER = callNumber }; unsortedListString.Insert(i, dgb); usersList.Insert(i, dgb); } dgCallNumbers.Items.Clear(); foreach (var callNumber in unsortedListString) { DataGridBind dgb = new DataGridBind { CALL_NUMBER = callNumber.CALL_NUMBER }; dgCallNumbers.Items.Add(dgb); } stopwatch.Start(); timer.Start(); } else if (btStartStop.Content.Equals("STOP")) { LearningGames lg = new LearningGames(); string timeScore = tbTimeDisplay.Text; stopwatch.Stop(); timer.Stop(); for (int i = 0; i < 10; i++) { DataGridBind dgb = new DataGridBind { CALL_NUMBER = usersList[i].CALL_NUMBER }; userOrderLinkedList.AddLast(usersList[i].CALL_NUMBER.ToString()); } SelectionSortUserBooks(); foreach (var item in unsortedListString) { sortedList.Add(item.CALL_NUMBER); } bool equal = userOrderLinkedList.SequenceEqual(sortedList); if (equal) { ModelLeaderBoard ml = new ModelLeaderBoard { USER_LIBRARY_CARD_ID = currentUser, REPLACING_BOOKS_PERSONAL_BEST = timeScore }; List <ModelLeaderBoard> getPersonalBest = lg.GetPersonalBestReplacingBooks(ml, connectionString); if (pb.Equals("Not Set")) { List <ModelLeaderBoard> getLeaderBoardRecords = lg.GetAllLeadBoardRecords(connectionString); if (getLeaderBoardRecords.Count == 0) { lg.UpdateNewPersonalBestReplacingBooks(ml, connectionString); MessageBox.Show("Congratulations ! You won, set your first PERSONAL BEST and are the first CHAMPION for this game mode ! It took you " + timeScore + " to complete the game! Try again to beat your PERSONAL BEST !"); } else if (TimeSpan.Compare(TimeSpan.Parse(timeScore), TimeSpan.Parse(ChampTime.ToString())) == -1) { lg.UpdateNewPersonalBestReplacingBooks(ml, connectionString); MessageBox.Show("Congratulations ! You won, set your first PERSONAL BEST and are the new CHAMPION for this game mode ! It took you " + timeScore + " to complete the game! Try again to beat your PERSONAL BEST !"); } else { lg.UpdateNewPersonalBestReplacingBooks(ml, connectionString); MessageBox.Show("Congratulations ! You won and set your first PERSONAL BEST ! It took you " + timeScore + " to complete the game! Try again to beat your PERSONAL BEST !"); } UpdateLeaderBoardPersonalBest(); } else if (TimeSpan.Compare(TimeSpan.Parse(timeScore), TimeSpan.Parse(ChampTime.ToString())) == -1) { if (TimeSpan.Compare(TimeSpan.Parse(timeScore), TimeSpan.Parse(getPersonalBest[0].REPLACING_BOOKS_PERSONAL_BEST.ToString())) == -1) { lg.UpdateNewPersonalBestReplacingBooks(ml, connectionString); MessageBox.Show("Congratulations ! You WON, beat your PERSONAL BEST time and are the new CHAMPION ! It took you " + timeScore + " to complete the game! Try again to beat your PERSONAL BEST for this game mode!"); UpdateLeaderBoardPersonalBest(); } else { lg.UpdateNewPersonalBestReplacingBooks(ml, connectionString); MessageBox.Show("Congratulations ! You WON and are the new CHAMPION ! It took you " + timeScore + " to complete the game! Try again to beat your PERSONAL BEST for this game mode!"); UpdateLeaderBoardPersonalBest(); } } else if (TimeSpan.Compare(TimeSpan.Parse(timeScore), TimeSpan.Parse(getPersonalBest[0].REPLACING_BOOKS_PERSONAL_BEST.ToString())) == -1) { lg.UpdateNewPersonalBestReplacingBooks(ml, connectionString); MessageBox.Show("Congratulations ! You WON and beat your PERSONAL BEST time ! It took you " + timeScore + " to complete the game! Try again to beat your PERSONAL BEST or to become library CHAMPION for this game mode!"); UpdateLeaderBoardPersonalBest(); } else { MessageBox.Show("Congratulations ! You WON ! It took you " + timeScore + " to complete the game! Try again to beat your PERSONAL BEST or to become library CHAMPION for this game mode!"); } } else { MessageBox.Show("SORRY You LOSE ! Unfortunately the CALL NUMBER order was INCORRECT! TRY AGAIN to have another chance at WINNING this game mode !"); } btStartStop.Content = "TRY AGAIN?"; } }