예제 #1
0
        static string CreateZendoGame()
        {
            Zendo      z  = new Zendo();
            ClanServer cs = new ClanServer();

            return(z.CreateNewGame("Testing Clan", "WildfireXIII", cs.Sha256Hash("testing"), "Testing game"));
        }
예제 #2
0
        static string GetGameBoard()
        {
            Zendo      z  = new Zendo();
            ClanServer cs = new ClanServer();

            return(z.GetUserBoard("g_Zendo_636178417101133079", "Testing Clan", "WildfireXIII", cs.Sha256Hash("testing")));
        }
예제 #3
0
        static string GrantEnlightenment()
        {
            Zendo      z  = new Zendo();
            ClanServer cs = new ClanServer();

            return(z.GrantEnlightenment("g_Zendo_636182346200902367", "The Martindale Clan", "WildfireXIII", cs.Sha256Hash("testing")));
        }
예제 #4
0
        public void BuildDashboard()
        {
            // clear everything out from the games panel
            stkActiveGames.Children.Clear();
            if (Master.GetActiveClan() == "")
            {
                return;
            }

            // query the server
            string   sResponse = WebCommunications.SendPostRequest("http://dwlapi.azurewebsites.net/api/reflection/GameClansServer/GameClansServer/ClanServer/ListActiveGames", Master.BuildCommonBody(), true);
            XElement pResponse = Master.ReadResponse(sResponse);

            // handle the games list
            m_lGames     = new List <string>();
            m_lGameIDs   = new List <string>();
            m_lGameNames = new List <string>();
            m_lDisplay   = new List <string>();

            if (pResponse.Element("Data").Element("Games") != null)
            {
                foreach (XElement pGame in pResponse.Element("Data").Element("Games").Elements("Game"))
                {
                    m_lGameIDs.Add(pGame.Value);
                    m_lGames.Add(pGame.Attribute("GameType").Value);
                    m_lGameNames.Add(pGame.Attribute("GameName").Value);

                    m_lDisplay.Add(pGame.Attribute("GameName").Value + " (" + pGame.Attribute("GameType").Value + ")");
                }
            }
            for (int i = 0; i < m_lGames.Count; i++)
            {
                int   iIndex = i;
                Label pLabel = new Label();
                pLabel.Padding    = new Thickness(10);
                pLabel.Margin     = new Thickness(2, 0, 2, 2);
                pLabel.Background = Master.BUTTON_NORMAL;
                pLabel.Foreground = new SolidColorBrush(Colors.White);
                pLabel.Content    = m_lDisplay[i];

                pLabel.MouseEnter += delegate { pLabel.Background = Master.BUTTON_HOVER; };
                pLabel.MouseLeave += delegate { pLabel.Background = Master.BUTTON_NORMAL; };
                pLabel.MouseUp    += delegate
                {
                    if (m_lGames[iIndex] == "Zendo")
                    {
                        Zendo pWindow = new Zendo(m_lGameIDs[iIndex], m_lGameNames[iIndex]);
                        pWindow.Show();
                    }
                };

                stkActiveGames.Children.Add(pLabel);
            }

            // fill notifications list
            sResponse = WebCommunications.SendPostRequest(Master.GetBaseURL() + Master.GetServerURL() + "GetUnreadNotifications", Master.BuildCommonBody(), true);
            pResponse = Master.ReadResponse(sResponse);

            stkNotifications.Children.Clear();
            XElement pNotificationsXml = pResponse.Element("Data").Element("Notifications");

            if (pNotificationsXml != null)
            {
                foreach (XElement pNotification in pNotificationsXml.Elements("Notification"))
                {
                    // get the data from the element
                    string sMessage  = pNotification.Value;
                    string sGameID   = pNotification.Attribute("GameID").Value;
                    string sGameName = pNotification.Attribute("GameName").Value;

                    // make the gui elements
                    Border pBorder = new Border();
                    pBorder.BorderBrush     = new SolidColorBrush(Color.FromRgb(68, 68, 68));
                    pBorder.BorderThickness = new Thickness(2, 0, 2, 2);
                    pBorder.Padding         = new Thickness(10);

                    TextBlock pLabel = new TextBlock();
                    pLabel.Foreground   = new SolidColorBrush(Colors.White);
                    pLabel.Text         = sGameName + " - " + sMessage;
                    pLabel.TextWrapping = TextWrapping.Wrap;

                    pLabel.MouseEnter += delegate { pBorder.Background = new SolidColorBrush(Color.FromRgb(100, 100, 100)); };
                    pLabel.MouseLeave += delegate { pBorder.Background = new SolidColorBrush(Colors.Transparent); };

                    // on click, open up that game window
                    pLabel.MouseUp += delegate
                    {
                        if (sGameID.Contains("Zendo"))
                        {
                            Zendo pWindow = new Zendo(sGameID, sGameName);
                            pWindow.Show();
                        }
                    };

                    // add the gui elements to the stack
                    pBorder.Child = pLabel;
                    stkNotifications.Children.Add(pBorder);
                }
            }

            // build scoreboard
            sResponse = WebCommunications.SendPostRequest(Master.GetBaseURL() + Master.GetServerURL() + "GetClanLeaderboard", Master.BuildCommonBody(), true);
            pResponse = Master.ReadResponse(sResponse);

            if (pResponse.Element("Data").Element("Leaderboard") != null)
            {
                XElement pLeaderboard = pResponse.Element("Data").Element("Leaderboard");
                stkScoreBoard.Children.Clear();

                lblUserName.Content   = Master.GetActiveUserName();
                lblPlaceScore.Content = pLeaderboard.Attribute("Place").Value + " - " + pLeaderboard.Attribute("Score").Value + " points";
                foreach (XElement pScoreXml in pLeaderboard.Elements("Score"))
                {
                    Border pBorder = new Border();
                    pBorder.BorderBrush     = new SolidColorBrush(Color.FromRgb(68, 68, 68));
                    pBorder.BorderThickness = new Thickness(2, 0, 2, 2);
                    pBorder.Padding         = new Thickness(10);

                    // thanks to http://stackoverflow.com/questions/9803710/programmatically-setting-the-width-of-a-grid-column-with-in-wpf
                    Grid             pGrid = new Grid();
                    ColumnDefinition c1    = new ColumnDefinition();
                    c1.Width = new GridLength(3, GridUnitType.Star);
                    ColumnDefinition c2 = new ColumnDefinition();
                    c2.Width = new GridLength(2, GridUnitType.Star);
                    ColumnDefinition c3 = new ColumnDefinition();
                    c3.Width = new GridLength(2, GridUnitType.Star);

                    pGrid.ColumnDefinitions.Add(c1);
                    pGrid.ColumnDefinitions.Add(c2);
                    pGrid.ColumnDefinitions.Add(c3);

                    Label pName = new Label();
                    pName.Foreground = new SolidColorBrush(Colors.White);
                    pName.Content    = pScoreXml.Attribute("User").Value;
                    Grid.SetColumn(pName, 0);

                    Label pPlace = new Label();
                    pPlace.Foreground = new SolidColorBrush(Colors.White);
                    pPlace.Content    = pScoreXml.Attribute("Place").Value;
                    Grid.SetColumn(pPlace, 1);

                    Label pScore = new Label();
                    pScore.Foreground = new SolidColorBrush(Colors.White);
                    pScore.Content    = pScoreXml.Attribute("Score").Value;
                    Grid.SetColumn(pScore, 2);

                    pGrid.Children.Add(pName);
                    pGrid.Children.Add(pPlace);
                    pGrid.Children.Add(pScore);

                    pBorder.Child = pGrid;
                    stkScoreBoard.Children.Add(pBorder);
                }
            }
        }
예제 #5
0
        static string JoinGame(string sUserName, string sPassword, string sGameID)
        {
            Zendo z = new Zendo();

            return(z.JoinGame(sGameID, "Testing Clan", sUserName, sPassword));
        }
예제 #6
0
        static string StartZendoGame()
        {
            Zendo z = new Zendo();

            return(z.StartGame("g_Zendo_636178400449774608"));
        }
예제 #7
0
        static string StartGame(string sGameID)
        {
            Zendo z = new Zendo();

            return(z.StartGame(sGameID));
        }