Exemplo n.º 1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            string getCmd;

            Label7.Text = Session["username"].ToString();

            GameManagement gm = new GameManagement();

            gm.grabStatsParams("@username", Label7.Text);

            getCmd = "GrabStatsHP";
            Label1.Text = gm.grabStats(getCon, getCmd).ToString();

            getCmd = "GrabStatsMoney";
            Label2.Text = gm.grabStats(getCon, getCmd).ToString();

            getCmd = "GrabStatsAttack";
            Label3.Text = gm.grabStats(getCon, getCmd).ToString();

            getCmd = "GrabStatsDefense";
            Label4.Text = gm.grabStats(getCon, getCmd).ToString();

            getCmd = "GrabStatsWins";
            Label5.Text = gm.grabStats(getCon, getCmd).ToString();

            getCmd = "GrabStatsLosses";
            Label6.Text = gm.grabStats(getCon, getCmd).ToString();
        }
Exemplo n.º 2
0
        protected void Button1_Click(object sender, EventArgs e)
        {
            try
            {
                GameManagement gm = new GameManagement();

                gm.grabStatsParams("@username", Session["username"].ToString());

                string getCmd = "GrabStatsMoney";
                string omoney = gm.grabStats(getCon, getCmd).ToString();
                int ownmoney;
                int.TryParse(omoney, out ownmoney);

                if (ownmoney < Convert.ToInt32(GridView1.SelectedRow.Cells[3].Text))
                {
                    Label5.Visible = true;
                    Label5.Text = "This purchase cannot continue.";

                    return;
                }

                gm.updateStatsParams("@username", Session["username"].ToString());

                gm.updateStatsParams("@getattack", TextBox2.Text);
                gm.updateStatsParams("@getdefense", TextBox3.Text);
                gm.updateStatsParams("@getprice", TextBox4.Text);
                // gm.updateStatsParams("@getitemid", GridView1.SelectedRow.Cells[1].Text);

                gm.updateStats(getCon);

                Label5.Visible = true;
                Label5.Text = "Purchase complete.";

            }
            catch (Exception ex)
            {
                Label5.Visible = true;
                Label5.Text = "An error occurred.";
            }
        }
Exemplo n.º 3
0
        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
                getuser = Session["username"].ToString();
            }

            catch (Exception)
            {
                Response.Redirect("~/Login.aspx");
            }

            try
            {
                gm.grabStatsParams("@username", getuser);

                string getCmd = "GrabStatsHP";
                string ohp = gm.grabStats(getCon, getCmd).ToString();
                int ownhp;
                int.TryParse(ohp, out ownhp);

                if (ownhp <= 0)
                {
                    Label1.Visible = true;
                    Label1.Text = "This battle cannot continue.";
                }

                GameManagement gm2 = new GameManagement();

                gm2.grabStatsParams("@username", getuser);

                string getCmd3 = "GrabStatsAttack";
                string atk = gm2.grabStats(getCon, getCmd3).ToString();

                int convatk;
                int.TryParse(atk, out convatk);

                Random rnd = new Random();

                int convdef = rnd.Next(10, convatk + 100);

                if (convatk > convdef)
                {
                    Label1.Visible = true;
                    Label1.Text = "You win vs CPU practice!";

                    FriendManagement fm = new FriendManagement();

                    fm.grabIDParams("@username", getuser);

                    int ownID = fm.grabID(getCon);

                    gm.logChallengeParams("@challenger", ownID);

                    gm.logChallengeParams("@challenged", -1); //cpu

                    string timestamp = GetUnixTimestamp().ToString();

                    gm.logChallengeParamsTime("@timestamp", timestamp);

                    gm.logChallengeParams("@iswin", 1);

                    gm.logChallengeParams("@isloss", 0);

                    gm.logChallenge(getCon);
                }
                else
                {
                    Label1.Visible = true;
                    Label1.Text = "You lose vs CPU practice!";

                    FriendManagement fm = new FriendManagement();

                    fm.grabIDParams("@username", getuser);

                    int ownID = fm.grabID(getCon);

                    gm.logChallengeParams("@challenger", ownID);

                    gm.logChallengeParams("@challenged", -1); //cpu

                    string timestamp = GetUnixTimestamp().ToString();

                    gm.logChallengeParamsTime("@timestamp", timestamp);

                    gm.logChallengeParams("@iswin", 0);

                    gm.logChallengeParams("@isloss", 1);

                    gm.logChallenge(getCon);
                }
            }
            catch (Exception ex)
            {
                Label1.Visible = true;
                Label1.Text = "An error has occurred";
            }
        }
Exemplo n.º 4
0
        protected void Button1_Click(object sender, EventArgs e)
        {
            try {
            if (getuser.Equals(TextBox1.Text))
            {
                Label2.Visible = true;
                Label2.Text = "You cannot fight yourself.";
                return;
            }

            gm.grabStatsParams("@username", getuser);

            string getCmd = "GrabStatsHP";
            string ohp = gm.grabStats(getCon, getCmd).ToString();
            int ownhp;
            int.TryParse(ohp, out ownhp);

            if (ownhp <= 0)
            {
                Label2.Visible = true;
                Label2.Text = "This battle cannot continue.";
            }

            if (TextBox1.Text.Length != 0)
            {
                GameManagement gm2 = new GameManagement();
                gm2.grabStatsParams("@username", TextBox1.Text);

                string getCmd2 = "GrabStatsHP";
                string ehp = gm2.grabStats(getCon, getCmd2).ToString();
                int enemyhp;
                int.TryParse(ehp, out enemyhp);

                if (enemyhp <= 0)
                {
                    Label2.Visible = true;
                    Label2.Text = "This battle cannot continue.";
                    return;
                }

                GameManagement gm3 = new GameManagement();

                gm3.grabStatsParams("@username", getuser);

                string getCmd3 = "GrabStatsAttack";
                string atk = gm3.grabStats(getCon, getCmd3).ToString();
                int convatk;
                int.TryParse(atk, out convatk);

                GameManagement gm4 = new GameManagement();

                gm4.grabStatsParams("@username", TextBox1.Text);

                string getCmd4 = "GrabStatsDefense";
                string def = gm4.grabStats(getCon, getCmd4).ToString();
                int convdef;
                int.TryParse(def, out convdef);

                if (convatk == convdef)
                {
                    Label2.Visible = true;
                    Label2.Text = "Draw match, routine not executed.";
                    return;
                }

                if (convatk > convdef)
                {
                    Label2.Visible = true;
                    Label2.Text = "You win! -15hp to enemy";

                    gm.minushpParams("@username", TextBox1.Text);

                    gm.minushp(getCon);

                    gm.addWinParams("@username", getuser);

                    gm.addWin(getCon);

                    gm.addLossParams("@username", TextBox1.Text);

                    gm.addLoss(getCon);

                    FriendManagement fm = new FriendManagement();

                    fm.grabIDParams("@username", getuser);

                    int ownID = fm.grabID(getCon);

                    FriendManagement fm2 = new FriendManagement();

                    fm2.grabIDParams("@username", TextBox1.Text);

                    int enemyID = fm2.grabID(getCon);

                    gm.logChallengeParams("@challenger", ownID);

                    gm.logChallengeParams("@challenged", enemyID);

                    string timestamp = GetUnixTimestamp().ToString();

                    gm.logChallengeParamsTime("@timestamp", timestamp);

                    gm.logChallengeParams("@iswin", 1);

                    gm.logChallengeParams("@isloss", 0);

                    gm.logChallenge(getCon);
                }
                else
                {
                    Label2.Visible = true;
                    Label2.Text = "You lose! -15 hp to you";

                    gm.minushpParams("@username", getuser);

                    gm.minushp(getCon);

                    gm.addWinParams("@username", TextBox1.Text);

                    gm.addWin(getCon);

                    gm.addLossParams("@username", getuser);

                    gm.addLoss(getCon);

                    FriendManagement fm = new FriendManagement();

                    fm.grabIDParams("@username", getuser);

                    int ownID = fm.grabID(getCon);

                    FriendManagement fm2 = new FriendManagement();

                    fm2.grabIDParams("@username", TextBox1.Text);

                    int enemyID = fm2.grabID(getCon);

                    gm.logChallengeParams("@challenger", ownID);

                    gm.logChallengeParams("@challenged", enemyID);

                    string timestamp = GetUnixTimestamp().ToString();

                    gm.logChallengeParamsTime("@timestamp", timestamp);

                    gm.logChallengeParams("@iswin", 0);

                    gm.logChallengeParams("@isloss", 1);

                    gm.logChallenge(getCon);
                } 
            }
            }
            catch (Exception ex) {
            
            Label2.Visible = true;
            Label2.Text = "An error has occurred";
            }
        }