Example #1
0
        public static ZendoKoan Load(XElement pXml)
        {
            ZendoKoan pKoan = new ZendoKoan();

            pKoan.Xml = pXml;
            return(pKoan);
        }
Example #2
0
        public string SubmitMondo(string sGameID, string sClanName, string sUserName, string sUserPassPhrase, string sKoan)
        {
            string sResult = this.Prepare(sGameID, sClanName, sUserName, sUserPassPhrase, AuthenticationType.Student);

            if (sResult != "")
            {
                return(sResult);
            }

            // make sure the state is open
            if (m_sStateStatus != "open")
            {
                if (m_sStateStatus == "pending master")
                {
                    return(Master.MessagifyError("The master has not analyzed the current pending koan"));
                }
                if (m_sStateStatus == "pending students")
                {
                    return(Master.MessagifyError("Mondo has been called on the pending koan"));
                }
                if (m_sStateStatus == "pending disproval")
                {
                    return(Master.MessagifyError("The master is currently attempting to disprove the current guess"));
                }
                return(Master.MessagifyError("The game is not currently accepting koan submissions"));
            }

            m_pPendingKoan      = new ZendoKoan(m_lKoans.Count, sKoan, sUserName);
            m_bMondo            = true;
            m_dMondoPredictions = new Dictionary <string, bool>();

            // set the game status
            m_sStateStatus = "pending students";

            // notify all students and create an event log
            //foreach (string sUser in m_lStudents)
            foreach (ZendoUser pUser in m_lStudents)
            {
                if (pUser.UserName == sUserName)
                {
                    continue;
                }
                m_pServer.AddNotification(m_sClanName, pUser.UserName, sUserName + " has called mondo on a koan. Hurry and make your prediction!", m_sGameID, m_sGameName);
            }
            m_lEventLog.Add(new ZendoLogEvent(sUserName + " has called mondo on their koan", m_pPendingKoan.Xml));

            this.Save();
            return("");
        }
Example #3
0
        public string SubmitInitialKoans(string sGameID, string sClanName, string sUserName, string sUserPassPhrase, string sRule, string sBuddhaNatureKoan, string sNonBuddhaNatureKoan)
        {
            string sResult = this.Prepare(sGameID, sClanName, sUserName, sUserPassPhrase, AuthenticationType.Master);

            if (sResult != "")
            {
                return(sResult);
            }

            // are we actually at this stage?
            if (m_sStateStatus != "initial")
            {
                if (m_sStateStatus == "setup")
                {
                    return(Master.MessagifyError("The game hasn't been started yet"));
                }
                return(Master.MessagifyError("The game is no longer in the initial stage"));
            }

            // set the rule
            m_sRule = sRule;

            // add the two koans
            ZendoKoan pBuddhaKoan    = new ZendoKoan(0, sBuddhaNatureKoan, "master", true);
            ZendoKoan pNonBuddhaKoan = new ZendoKoan(1, sNonBuddhaNatureKoan, "master", false);

            m_lKoans.Add(pBuddhaKoan);
            m_lKoans.Add(pNonBuddhaKoan);

            // open up the game status
            m_sStateStatus = "open";

            // send notifications to all the students and add to the event log
            //foreach (string sUser in m_lStudents) { m_pServer.AddNotification(m_sClanName, sUser, "The game has started and the master has built the initial koans!"); }
            foreach (ZendoUser pUser in m_lStudents)
            {
                m_pServer.AddNotification(m_sClanName, pUser.UserName, "The game has started and the master has built the initial koans!", m_sGameID, m_sGameName);
            }
            m_lEventLog.Add(new ZendoLogEvent("The master has built the initial koans"));

            this.Save();
            return("");
        }
Example #4
0
        public string SubmitPendingKoanAnalysis(string sGameID, string sClanName, string sUserName, string sUserPassPhrase, bool bHasBuddhaNature)
        {
            string sResult = this.Prepare(sGameID, sClanName, sUserName, sUserPassPhrase, AuthenticationType.Master);

            if (sResult != "")
            {
                return(sResult);
            }

            // make sure the state is 'pending master'
            if (m_sStateStatus != "pending master")
            {
                return(Master.MessagifyError("There is no pending koan for you to analyze"));
            }

            // get the specified koan
            ZendoKoan pKoan = m_pPendingKoan;

            // set the koans buddha-nature and add it to the list
            pKoan.HasBuddhaNature = bHasBuddhaNature;
            pKoan.Koan            = pKoan.StringKoan;
            m_lKoans.Add(pKoan);

            // handle if the koan was a mondo
            if (m_bMondo)
            {
                foreach (string sUser in m_dMondoPredictions.Keys)
                {
                    if (m_dMondoPredictions[sUser] == bHasBuddhaNature)
                    {
                        ZendoUser pUser = this.GetStudentByName(sUser);
                        if (pUser == null) /* fail silently for now, we don't want this to stop execution. */ } {
                        pUser.GuessingStones++;

                        m_pServer.AddNotification(sClanName, sUser, "The master has answered the mondo, your prediction was correct!", m_sGameID, m_sGameName);
                }
                else
                {
                    m_pServer.AddNotification(sClanName, sUser, "The master has answered the mondo, your prediction was incorrect.", m_sGameID, m_sGameName);
                }
            }
Example #5
0
        public string SubmitKoan(string sGameID, string sClanName, string sUserName, string sUserPassPhrase, string sKoan)
        {
            string sResult = this.Prepare(sGameID, sClanName, sUserName, sUserPassPhrase, AuthenticationType.Student);

            if (sResult != "")
            {
                return(sResult);
            }

            // make sure the state is open
            if (m_sStateStatus != "open")
            {
                if (m_sStateStatus == "pending master")
                {
                    return(Master.MessagifyError("The master has not analyzed the current pending koan"));
                }
                if (m_sStateStatus == "pending students")
                {
                    return(Master.MessagifyError("Mondo has been called on the pending koan"));
                }
                if (m_sStateStatus == "pending disproval")
                {
                    return(Master.MessagifyError("The master is currently attempting to disprove the current guess"));
                }
                return(Master.MessagifyError("The game is not currently accepting koan submissions"));
            }

            m_pPendingKoan = new ZendoKoan(m_lKoans.Count, sKoan, sUserName);

            // set the game status
            m_sStateStatus = "pending master";

            // send a notification to the master and add to the event log
            m_pServer.AddNotification(m_sClanName, m_sMaster, "A student has built a new koan for you to analyze.", m_sGameID, m_sGameName);
            m_lEventLog.Add(new ZendoLogEvent(sUserName + " has built a new koan", m_pPendingKoan.Xml));

            this.Save();
            return("");
        }