Started a leaderboard

This commit is contained in:
Anthony 2020-09-27 13:32:24 +01:00
parent e09fe683c5
commit 03e58205b1
5 changed files with 17 additions and 8 deletions

View File

@ -28,3 +28,9 @@ CREATE TABLE pwdreset (
pwd_token LONGTEXT NOT NULL, #Where the hashed token is stored pwd_token LONGTEXT NOT NULL, #Where the hashed token is stored
pwd_expires TEXT NOT NULL #When the token expires pwd_expires TEXT NOT NULL #When the token expires
); );
CREATE TABLE money_spent(
user_id int(11) PRIMARY KEY NOT NULL,
user_spent int(11) NOT NULL,
FOREIGN KEY (user_id) REFERENCES users(user_id)
);

View File

@ -9,6 +9,7 @@ using Newtonsoft.Json;
class LoginInformation class LoginInformation
{ {
public int id;
public string user; public string user;
public bool success; public bool success;
public string errors; public string errors;
@ -24,12 +25,13 @@ public class Login : MonoBehaviour
private bool CheckIsEmpty() //This checks if the strings are empty. private bool CheckIsEmpty() //This checks if the strings are empty.
{ {
var strings = new List<string> {username.text, password.text}; //This puts all of the text boxes into an array. var strings = new List<string> {username.text, password.text}; //This puts all of the text boxes into an array.
string check = ""; //This is used for the check, the ZWSP is TMP's way of identifying nothing as null. string check = ""; //This is used for the check, the ZWSP is TMP's way of identifying nothing as null.
if (strings.Contains(check)) //If any of the inputs are null. if (strings.Contains(check)) //If any of the inputs are null.
{ {
//Debug.Log("yes");
return true; return true;
} }
//Debug.Log("false");
return false; return false;
} }
@ -84,16 +86,15 @@ public class Login : MonoBehaviour
{ {
string status = www.downloadHandler.text; //This downloads the data from the server. string status = www.downloadHandler.text; //This downloads the data from the server.
LoginInformation information = JsonConvert.DeserializeObject<LoginInformation>(status); //This deserializes the JSON string to a class. LoginInformation information = JsonConvert.DeserializeObject<LoginInformation>(status); //This deserializes the JSON string to a class.
Debug.Log(status);
if (information.success) //If the user has successfully logged in. if (information.success) //If the user has successfully logged in.
{ {
UserManager.userID = information.id;
UserManager.username = information.user; //This sets the logged in username. UserManager.username = information.user; //This sets the logged in username.
UnityEngine.SceneManagement.SceneManager.LoadScene(1); //Loads the menu scene. UnityEngine.SceneManagement.SceneManager.LoadScene(1); //Loads the menu scene.
} }
InteractableForm(true); // This enables the form again.
} }
InteractableForm(true); // This enables the form again.
} }
} }

View File

@ -4,6 +4,7 @@ using UnityEngine;
public static class UserManager public static class UserManager
{ {
public static int userID;
public static string username; public static string username;
public static bool LoggedIn => username != null; public static bool LoggedIn => username != null;

View File

@ -14,6 +14,7 @@ public class MainMenu : MonoBehaviour
private string existingCards; private string existingCards;
void Start() { void Start() {
Debug.Log("User ID: " + UserManager.userID);
Debug.Log("Username: " + UserManager.username); Debug.Log("Username: " + UserManager.username);
if (!PropertiesHandler.CheckPropertyExists()) //Checks if the properties file doesn't exist. if (!PropertiesHandler.CheckPropertyExists()) //Checks if the properties file doesn't exist.
{ {

View File

@ -1,2 +1,2 @@
m_EditorVersion: 2020.1.5f1 m_EditorVersion: 2020.1.6f1
m_EditorVersionWithRevision: 2020.1.5f1 (e025938fdedc) m_EditorVersionWithRevision: 2020.1.6f1 (fc477ca6df10)