Exemplo n.º 1
0
        private void button1_Click(object sender, EventArgs e)
        {
            Uzytkownik u1 = new Uzytkownik();
            int        ID;
            string     l, h;

            l  = textBox1.Text;
            h  = textBox2.Text;
            ID = u1.zweryfikuj_login(l, h);
            if (ID == -1)
            {
                label3.Visible = true;
            }
            else
            {
                Gracz G = new Gracz(ID);
                if (G.czy_administrator())
                {
                    Administrator A    = new Administrator(G);
                    Rozgrywka     obj3 = new Rozgrywka(A);
                    this.Hide();
                    obj3.ShowDialog();
                }
                else
                {
                    Rozgrywka obj3 = new Rozgrywka(G);
                    this.Hide();
                    obj3.ShowDialog();
                }
            }
        }
Exemplo n.º 2
0
 public Administrator(Gracz G)
 {
     this.ID_logowania    = G.ID_logowania;
     this.nazwa_gracza    = G.nazwa_gracza;
     this.punkty          = G.punkty;
     this.ostatnia_wizyta = G.ostatnia_wizyta;
 }
Exemplo n.º 3
0
        public bool zaloz_konto(string l, string n, string h, ref Gracz G)
        {
            this.login = l;
            this.haslo = h;
            bool ok = true;
            Baza_danych_uzytkownika B = new Baza_danych_uzytkownika();

            for (int i = 0; i < B.liczba_graczy; i++)
            {
                if (login == B.dane[i].login)
                {
                    ok = false;
                    break;
                }
            }
            Ranking_kl R = new Ranking_kl();

            for (int i = 0; i < R.liczba_graczy; i++)
            {
                if (n == R.dane[i].nazwa_gracza)
                {
                    ok = false;
                }
            }
            if (ok)
            {
                Dane_logowania_uzytkownika d = new Dane_logowania_uzytkownika();
                d.login            = login;
                d.haslo            = haslo;
                d.data_rejestracji = DateTime.Now.Ticks;
                Informacje_gracza ig = new Informacje_gracza(n, B.liczba_graczy);
                G.nazwa_gracza    = ig.nazwa_gracza;
                G.punkty          = ig.punkty;
                G.ID_logowania    = ig.ID_logowania;
                G.ostatnia_wizyta = ig.ostatnia_wizyta;
                B.dane.Add(d);
                B.liczba_graczy++;
                R.dane.Add(ig);
                R.liczba_graczy++;
                StreamWriter pout, rout;
                pout = new StreamWriter("baza.csv");
                rout = new StreamWriter("ranking.csv");
                for (int i = 0; i < B.liczba_graczy; i++)
                {
                    pout.WriteLine("{0},{1},{2}\n", B.dane[i].login, B.dane[i].haslo, B.dane[i].data_rejestracji);
                }
                for (int i = 0; i < R.liczba_graczy; i++)
                {
                    rout.WriteLine("{0},{1},{2},{3}\n", R.dane[i].nazwa_gracza, R.dane[i].punkty, R.dane[i].ID_logowania, R.dane[i].ostatnia_wizyta);
                }
                pout.Close();
                rout.Close();
                return(true);
            }
            else
            {
                return(false);
            }
        }
Exemplo n.º 4
0
 public Rozgrywka(Gracz G)
 {
     this.G = G;
     InitializeComponent(G);
     timer1.Start();
     label1.Text = G.nazwa_gracza;
     label3.Text = Convert.ToString(G.punkty);
 }
Exemplo n.º 5
0
 public Ranking(Form obj4,Gracz G)
 {
     obj = obj4;
     InitializeComponent(G);
     this.G = G;
     //
     //TODO: W tym miejscu dodaj kod konstruktora
     //
 }
Exemplo n.º 6
0
        private void button1_Click(object sender, EventArgs e)
        {
            string l, n, h;

            l = textBox1.Text;
            h = textBox2.Text;
            n = textBox3.Text;

            Uzytkownik u1 = new Uzytkownik();
            bool       ok = true;
            Regex      r  = new Regex("^[a-zA-Z0-9]*$");

            if (l.Length < 3 || l.Length > 10)
            {
                ok = false;
            }
            if (!r.IsMatch(l))
            {
                ok = false;
            }
            if (n.Length < 3 || n.Length > 10)
            {
                ok = false;
            }
            if (!r.IsMatch(n))
            {
                ok = false;
            }
            if (h.Length < 8 || h.Length > 20)
            {
                ok = false;
            }
            if (!r.IsMatch(h))
            {
                ok = false;
            }
            Gracz G = new Gracz();

            if (ok)
            {
                ok = u1.zaloz_konto(l, n, h, ref G);
            }
            if (!ok)
            {
                label7.Visible = true;
            }
            if (ok)
            {
                this.Hide();
                Rozgrywka obj3 = new Rozgrywka(G);
                obj3.ShowDialog();
            }
        }
        /// <summary>
        /// Required method for Designer support - do not modify
        /// the contents of this method with the code editor.
        /// </summary>
        private void InitializeComponent(Gracz G)
        {
            this.button1           = new System.Windows.Forms.Button();
            this.button2           = new System.Windows.Forms.Button();
            this.tableLayoutPanel1 = new System.Windows.Forms.TableLayoutPanel();
            this.label1            = new System.Windows.Forms.Label();
            this.label2            = new System.Windows.Forms.Label();
            this.label3            = new System.Windows.Forms.Label();
            this.label4            = new System.Windows.Forms.Label();
            this.label5            = new List <System.Windows.Forms.Label>();
            this.label6            = new List <System.Windows.Forms.Label>();
            this.label7            = new List <System.Windows.Forms.Label>();
            this.label8            = new List <System.Windows.Forms.Label>();
            this.tableLayoutPanel1.SuspendLayout();
            this.SuspendLayout();
            Ranking_kl R = new Ranking_kl();

            for (int i = 0; i < R.liczba_graczy; i++)
            {
                label5.Add(new System.Windows.Forms.Label());
                label6.Add(new System.Windows.Forms.Label());
                label7.Add(new System.Windows.Forms.Label());
                label8.Add(new System.Windows.Forms.Label());
            }
            //
            // button1
            //
            this.button1.Location = new System.Drawing.Point(214, 302);
            this.button1.Name     = "button1";
            this.button1.Size     = new System.Drawing.Size(94, 23);
            this.button1.TabIndex = 0;
            this.button1.Text     = "Powrót do gry";
            this.button1.UseVisualStyleBackColor = true;
            this.button1.Click += new System.EventHandler(this.button1_Click);
            //
            // tableLayoutPanel1
            //
            this.tableLayoutPanel1.ColumnCount = 5;
            this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 40F));
            this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 150F));
            this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 100F));
            this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 200F));
            this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 100F));
            this.tableLayoutPanel1.Controls.Add(this.label1, 0, 0);
            this.tableLayoutPanel1.Controls.Add(this.label2, 1, 0);
            this.tableLayoutPanel1.Controls.Add(this.label3, 2, 0);
            this.tableLayoutPanel1.Controls.Add(this.label4, 3, 0);
            for (int i = 0; i < R.liczba_graczy; i++)
            {
                this.tableLayoutPanel1.Controls.Add(this.label5[i], 0, 1 + i);
                this.tableLayoutPanel1.Controls.Add(this.label6[i], 1, 1 + i);
                this.tableLayoutPanel1.Controls.Add(this.label7[i], 2, 1 + i);
                this.tableLayoutPanel1.Controls.Add(this.label8[i], 3, 1 + i);
            }
            this.tableLayoutPanel1.Location = new System.Drawing.Point(26, 16);
            this.tableLayoutPanel1.Name     = "tableLayoutPanel1";
            this.tableLayoutPanel1.RowCount = R.liczba_graczy + 1;
            this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 30F));
            for (int i = 0; i < R.liczba_graczy; i++)
            {
                this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 30F));
            }
            this.tableLayoutPanel1.Size     = new System.Drawing.Size(490, (R.liczba_graczy + 1) * 30);
            this.tableLayoutPanel1.TabIndex = 1;
            //
            // label1
            //
            this.label1.AutoSize = true;
            this.label1.Font     = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(238)));
            this.label1.Location = new System.Drawing.Point(3, 0);
            this.label1.Name     = "label1";
            this.label1.Size     = new System.Drawing.Size(31, 20);
            this.label1.TabIndex = 0;
            this.label1.Text     = "Lp.";
            //
            // label2
            //
            this.label2.AutoSize = true;
            this.label2.Font     = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(238)));
            this.label2.Location = new System.Drawing.Point(43, 0);
            this.label2.Name     = "label2";
            this.label2.Size     = new System.Drawing.Size(57, 20);
            this.label2.TabIndex = 1;
            this.label2.Text     = "Nazwa";
            //
            // label3
            //
            this.label3.AutoSize = true;
            this.label3.Font     = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(238)));
            this.label3.Location = new System.Drawing.Point(193, 0);
            this.label3.Name     = "label3";
            this.label3.Size     = new System.Drawing.Size(57, 20);
            this.label3.TabIndex = 2;
            this.label3.Text     = "Punkty";
            //
            // label4
            //
            this.label4.AutoSize = true;
            this.label4.Font     = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(238)));
            this.label4.Location = new System.Drawing.Point(293, 0);
            this.label4.Name     = "label4";
            this.label4.Size     = new System.Drawing.Size(116, 20);
            this.label4.TabIndex = 3;
            this.label4.Text     = "Ostatnia wizyta";
            for (int i = 0; i < R.liczba_graczy; i++)
            {
                //
                // label5
                //
                this.label5[i].AutoSize = true;
                this.label5[i].Font     = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(238)));
                this.label5[i].Location = new System.Drawing.Point(3, (1 + i) * 30);
                this.label5[i].Name     = "label5";
                this.label5[i].Size     = new System.Drawing.Size(29, 20);
                this.label5[i].TabIndex = 4 + 4 * i;
                label5[i].Text          = Convert.ToString(i + 1);
                //
                // label6
                //
                this.label6[i].AutoSize = true;
                this.label6[i].Font     = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(238)));
                this.label6[i].Location = new System.Drawing.Point(43, (1 + i) * 30);
                this.label6[i].Name     = "label6";
                this.label6[i].Size     = new System.Drawing.Size(35, 20);
                this.label6[i].TabIndex = 5 + 4 * i;
                label6[i].Text          = R.dane[i].nazwa_gracza;
                //
                // label7
                //
                this.label7[i].AutoSize = true;
                this.label7[i].Font     = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(238)));
                this.label7[i].Location = new System.Drawing.Point(193, (1 + i) * 30);
                this.label7[i].Name     = "label7";
                this.label7[i].Size     = new System.Drawing.Size(35, 20);
                this.label7[i].TabIndex = 6 + 4 * i;
                label7[i].Text          = Convert.ToString(R.dane[i].punkty);
                //
                // label8
                //
                this.label8[i].AutoSize = true;
                this.label8[i].Font     = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(238)));
                this.label8[i].Location = new System.Drawing.Point(293, (1 + i) * 30);
                this.label8[i].Name     = "label8";
                this.label8[i].Size     = new System.Drawing.Size(35, 20);
                this.label8[i].TabIndex = 7 + 4 * i;
                DateTime czas = new DateTime(R.dane[i].ostatnia_wizyta);
                label8[i].Text = Convert.ToString(czas);

                if (R.dane[i].ID_logowania == G.ID_logowania)
                {
                    this.label5[i].Font   = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Underline, System.Drawing.GraphicsUnit.Point, ((byte)(238)));
                    this.label6[i].Font   = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Underline, System.Drawing.GraphicsUnit.Point, ((byte)(238)));
                    this.label7[i].Font   = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Underline, System.Drawing.GraphicsUnit.Point, ((byte)(238)));
                    this.label8[i].Font   = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Underline, System.Drawing.GraphicsUnit.Point, ((byte)(238)));
                    this.button2.Location = new System.Drawing.Point(515, (i + 1) * 30 + 16);
                    this.button2.Name     = "button2";
                    this.button2.Size     = new System.Drawing.Size(94, 23);
                    this.button2.TabIndex = 1;
                    this.button2.Text     = "Usuń gracza";
                    this.button2.UseVisualStyleBackColor = true;
                    this.button2.Click += new System.EventHandler(this.button2_Click);
                }
            }
            //
            // Ranking
            //
            this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
            this.AutoScaleMode       = System.Windows.Forms.AutoScaleMode.Font;
            this.ClientSize          = new System.Drawing.Size(700, 500);
            this.Controls.Add(this.tableLayoutPanel1);
            this.Controls.Add(this.button1);
            this.Controls.Add(this.button2);
            this.Name = "Ranking";
            this.Text = "Ranking";
            this.tableLayoutPanel1.ResumeLayout(false);
            this.tableLayoutPanel1.PerformLayout();
            this.ResumeLayout(false);
        }
Exemplo n.º 8
0
 public Ranking(Gracz G)
 {
     InitializeComponent(G);
     this.G = G;
 }