wip: add some security
This commit is contained in:
parent
2de1611c4d
commit
6454b54dc6
@ -467,6 +467,7 @@ public void OnClickSubmitSignIn()
|
|||||||
|
|
||||||
public void onClickSamePlayers()
|
public void onClickSamePlayers()
|
||||||
{
|
{
|
||||||
|
Debug.Log("Play with same players !", this);
|
||||||
Room newRoom = myRoom;
|
Room newRoom = myRoom;
|
||||||
newRoom.currentState = (int)GameState.Explanation;
|
newRoom.currentState = (int)GameState.Explanation;
|
||||||
newRoom.questions.Clear();
|
newRoom.questions.Clear();
|
||||||
@ -484,11 +485,13 @@ public void onClickSamePlayers()
|
|||||||
}
|
}
|
||||||
public void onClickNewPlayers()
|
public void onClickNewPlayers()
|
||||||
{
|
{
|
||||||
myRoom.currentState = (int)GameState.EnteringName;
|
Debug.Log("Play with new players !", this);
|
||||||
myRoom.currentQuestionId = 0;
|
Room newRoom = myRoom;
|
||||||
myRoom.questions = null;
|
newRoom.currentState = (int)GameState.EnteringName;
|
||||||
myRoom.players = null;
|
newRoom.currentQuestionId = 0;
|
||||||
string json = JsonConvert.SerializeObject(myRoom);
|
newRoom.questions = null;
|
||||||
|
newRoom.players = null;
|
||||||
|
string json = JsonConvert.SerializeObject(newRoom);
|
||||||
|
|
||||||
myOnlineRoom.SetRawJsonValueAsync(json).ContinueWithOnMainThread(task =>
|
myOnlineRoom.SetRawJsonValueAsync(json).ContinueWithOnMainThread(task =>
|
||||||
{
|
{
|
||||||
@ -502,6 +505,9 @@ public void onClickNewPlayers()
|
|||||||
|
|
||||||
private void OnCurrentQuestionChanged(object sender, ValueChangedEventArgs onlineValue)
|
private void OnCurrentQuestionChanged(object sender, ValueChangedEventArgs onlineValue)
|
||||||
{
|
{
|
||||||
|
if (onlineValue == null || onlineValue.Snapshot == null || onlineValue.Snapshot.Value == null)
|
||||||
|
return;
|
||||||
|
|
||||||
int questionId = onlineValue.Snapshot.Value.ConvertTo<int>();
|
int questionId = onlineValue.Snapshot.Value.ConvertTo<int>();
|
||||||
Debug.Log($"new question ! Q{(onlineValue.Snapshot.Value.ConvertTo<int>())}");
|
Debug.Log($"new question ! Q{(onlineValue.Snapshot.Value.ConvertTo<int>())}");
|
||||||
|
|
||||||
|
@ -12,7 +12,7 @@ public class QuestionHandler : MonoBehaviour
|
|||||||
public PromptList promptList;
|
public PromptList promptList;
|
||||||
|
|
||||||
private GameManager gameManager;
|
private GameManager gameManager;
|
||||||
private List<Question> questionsToAnswer;
|
private List<Question> questionsToAnswer = new List<Question>();
|
||||||
private int activeAnsweredQuestionIndex = 0;
|
private int activeAnsweredQuestionIndex = 0;
|
||||||
|
|
||||||
private const int FirstQuestionIndex = 0;
|
private const int FirstQuestionIndex = 0;
|
||||||
@ -25,21 +25,14 @@ public class QuestionHandler : MonoBehaviour
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
void OnEnable()
|
void OnEnable()
|
||||||
{
|
{
|
||||||
|
activeAnsweredQuestionIndex = FirstQuestionIndex;
|
||||||
|
submitButton.interactable = true;
|
||||||
|
submitButton.GetComponent<TextMeshProUGUI>().text = "Submit";
|
||||||
gameManager = managers.GetComponent<GameManager>();
|
gameManager = managers.GetComponent<GameManager>();
|
||||||
questionsToAnswer = gameManager.myRoom.GetQuestionsByPlayer(gameManager.currentPlayer);
|
questionsToAnswer = gameManager.myRoom.GetQuestionsByPlayer(gameManager.currentPlayer);
|
||||||
Redraw(activeAnsweredQuestionIndex);
|
Redraw(activeAnsweredQuestionIndex);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Called when the script is disabled.
|
|
||||||
/// Cleans up resources and resets the activeAnsweredQuestionIndex.
|
|
||||||
/// </summary>
|
|
||||||
void OnDisable()
|
|
||||||
{
|
|
||||||
questionsToAnswer = null;
|
|
||||||
activeAnsweredQuestionIndex = FirstQuestionIndex;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Redraws the UI with the information from the current question.
|
/// Redraws the UI with the information from the current question.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
Loading…
Reference in New Issue
Block a user