public void setWinner(Match match, string winner) { match.m_status = "finished"; match.m_cp = winner; Dictionary <string, object> matchUpdate = MatchManager.I.getDictionaryMatch(match, null, true, winner); GamedoniaData.Update("matches", matchUpdate); Save(); }
public void ChangeLastTurn(Turn turn, bool finish, bool directlyNinth = false) { Debug.Log("In last turn"); Dictionary <string, object> matchUpdate = null; Match match = GetMatch(currentMatchID); string winner = ""; if (directlyNinth) { Debug.Log("added last turn"); AddTurn(turn); } else { for (int i = 0; i < match.m_trns.Count; i++) { if (match.m_trns [i].p_ID == PlayerManager.I.player.playerID && match.m_trns [i].t_ID == turn.t_ID) { match.m_trns [i] = turn; } } } if (finish) { match.m_status = "finished"; Debug.Log("Set status to finished"); match.m_cp = GetOppenentId(match); winner = getWinner(match); // Gamedonia server script handles opponent push message } if (turn.t_st == 0) { match.m_cp = GetOppenentId(match); } if (finish) { matchUpdate = MatchManager.I.getDictionaryMatch(match, null, true, winner); } else { matchUpdate = MatchManager.I.getDictionaryMatch(match, null, true); } GamedoniaData.Update("matches", matchUpdate); Save(); }
public void AddTurn(Turn turn, string match_ID = "") { if (match_ID == "") { match_ID = currentMatchID; } Match match = GetMatch(match_ID); if (match.m_trns == null) { match.m_trns = new List <Turn> (); if (match.m_trns.Count == 0 && match.m_status != "inviteStart") { createGameQueueObject(); } } if (!match.m_trns.Contains(turn)) { match.AddTurn(turn); if (turn.t_st == 0) { if (match.m_status != "waiting") { match.m_cp = GetOppenentId(match); } else { match.m_cp = ""; } // Update match to gamedonia if (match.m_status == "inviteStart") { match.m_status = "invite"; } match.m_date = RuntimeData.I.getCorrectDateTime(System.DateTime.Now); Dictionary <string, object> matchUpdate = MatchManager.I.getDictionaryMatch(match, null, true); GamedoniaData.Update("matches", matchUpdate); } else { } } // Save locally Save(); }
public void SetQuestionState(string questionID, int stateId) { Dictionary <string, object> question = new Dictionary <string, object>(); question["_id"] = questionID; question["qAp"] = stateId; GamedoniaData.Update("questions", question, delegate(bool success, IDictionary data){ if (success) { //TODO Your success processing } else { //TODO Your fail processing } }); }
public void DenyMatch(Match match) { match.m_status = "deny"; match.m_cp = GetOppenentId(match); currentMatchID = match.m_ID; Dictionary <string, object> matchUpdate = MatchManager.I.getDictionaryMatch(match, "", true); GamedoniaData.Update("matches", matchUpdate, delegate(bool success, IDictionary data){ if (success) { matches.Remove(match); Save(); GameObject.FindObjectOfType <CurrentMatches> ().showInvites(); GameObject.FindObjectOfType <CurrentMatches> ().deleteRow(match.m_ID); GameObject.FindObjectOfType <CurrentMatches> ().checkMatchCount(); } else { //TODO Your fail processing } }); }
public void SubmitQuestion() { Loader.I.enableLoader(); string correctAnswer = ""; if (correctAnswerId.value == 0) { correctAnswer = "A"; } else if (correctAnswerId.value == 1) { correctAnswer = "B"; } else if (correctAnswerId.value == 2) { correctAnswer = "C"; } else if (correctAnswerId.value == 3) { correctAnswer = "D"; } Dictionary <string, object> question = new Dictionary <string, object>(); if (QuestionBackend.I.changeQuestion) { question["_id"] = QuestionBackend.I.currentQuestion.q_Id; } question["cId"] = (categoryId.value + 1); question["qT"] = QuestionTitleText.text; question["qA"] = AnswerAText.text; question["qB"] = AnswerBText.text; question["qC"] = AnswerCText.text; question["qD"] = AnswerDText.text; question["qCA"] = correctAnswer; question["sID"] = PlayerManager.I.player.playerID; question["qAp"] = 0; // Add 50 exp to the player if (!QuestionBackend.I.changeQuestion) { PlayerManager.I.player.playerXP = PlayerManager.I.player.playerXP += 50; } // Make the request to store the entity inside the desired collection if (!QuestionBackend.I.changeQuestion) { GamedoniaData.Create("questions", question, delegate(bool success, IDictionary data){ if (success) { Loader.I.LoadScene("QuestionAddedSuccess"); //TODO Your success processing } else { //TODO Your fail processing } }); } else { QuestionBackend.I.changeQuestion = false; QuestionBackend.I.currentQuestion = null; GamedoniaData.Update("questions", question, delegate(bool success, IDictionary data){ if (success) { Loader.I.LoadScene("MyQuestions"); } else { //TODO Your fail processing } }); } }