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

@ -27,4 +27,10 @@ CREATE TABLE pwdreset (
pwd_selector TEXT NOT NULL, #Where the selector is stored in plaintext
pwd_token LONGTEXT NOT NULL, #Where the hashed token is stored
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
{
public int id;
public string user;
public bool success;
public string errors;
@ -24,12 +25,13 @@ public class Login : MonoBehaviour
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.
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.
{
//Debug.Log("yes");
return true;
}
//Debug.Log("false");
return false;
}
@ -84,16 +86,15 @@ public class Login : MonoBehaviour
{
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.
Debug.Log(status);
if (information.success) //If the user has successfully logged in.
{
UserManager.userID = information.id;
UserManager.username = information.user; //This sets the logged in username.
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 int userID;
public static string username;
public static bool LoggedIn => username != null;

View File

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

View File

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