Exemplo n.º 1
0
        public void usun_gracza(int ID, Ranking_kl R)
        {
            Baza_danych_uzytkownika B = new Baza_danych_uzytkownika();
            int ID_logowania          = R.dane[ID].ID_logowania;

            B.dane.RemoveAt(ID_logowania);
            R.dane.RemoveAt(ID);
            R.liczba_graczy--;
            B.liczba_graczy--;
            for (int i = 0; i < R.liczba_graczy; i++)
            {
                if (R.dane[i].ID_logowania > ID_logowania)
                {
                    R.dane[i].ID_logowania--;
                }
            }
            StreamWriter pout;

            pout = new StreamWriter("baza.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);
            }
            pout.Close();
        }
Exemplo n.º 2
0
        public void zapisz_dane()
        {
            Ranking_kl R = new Ranking_kl();

            for (int i = 0; i < R.liczba_graczy; i++)
            {
                if (R.dane[i].ID_logowania == ID_logowania)
                {
                    R.dane[i].punkty          = punkty;
                    R.dane[i].ostatnia_wizyta = DateTime.Now.Ticks;
                    for (int j = 0; j < i; j++)
                    {
                        if (R.dane[i].punkty > R.dane[j].punkty)
                        {
                            R.dane.Insert(j, R.dane[i]);
                            R.dane.RemoveAt(i + 1);
                        }
                    }
                    break;
                }
            }
            StreamWriter rout;

            rout = new StreamWriter("ranking.csv");
            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);
            }
            rout.Close();
        }
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 void zmien_liczbe_punktow_gracza(int ID, int punkty, Ranking_kl R)
 {
     R.dane[ID].punkty = punkty;
     if (R.dane[ID].ID_logowania == this.ID_logowania)
     {
         this.punkty = punkty;
     }
 }
Exemplo n.º 5
0
        public Gracz(int id)
        {
            Ranking_kl R = new Ranking_kl();

            for (int i = 0; i < R.liczba_graczy; i++)
            {
                if (id == R.dane[i].ID_logowania)
                {
                    nazwa_gracza    = R.dane[i].nazwa_gracza;
                    punkty          = R.dane[i].punkty;
                    ID_logowania    = R.dane[i].ID_logowania;
                    ostatnia_wizyta = DateTime.Now.Ticks;
                }
            }
        }
Exemplo n.º 6
0
        private void button1_ClickA(object sender, EventArgs e)
        {
            tick = 120;
            Ranking_kl R = new Ranking_kl();

            if (!A.dodaj_punkt())
            {
                A.zapisz_dane();
                this.Hide();
                Application.Exit();
            }
            string ss = Convert.ToString(A.punkty);

            label3.Text = ss;
            label4.Text = "120";
        }
Exemplo n.º 7
0
        public void zapisz_dane(Ranking_kl R)
        {
            Baza_danych_uzytkownika B = new Baza_danych_uzytkownika();
            StreamWriter            rout;

            rout = new StreamWriter("ranking.csv");
            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);
            }
            rout.Close();
            StreamWriter pout;

            pout = new StreamWriter("baza.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);
            }
            pout.Close();
        }
Exemplo n.º 8
0
 private void button3_Click(object sender, EventArgs e)
 {
     Ranking_kl R=new Ranking_kl();
     int usuwanie = 0;
     for (int i = 0; i < R.liczba_graczy; i++)
     {
         if (checkbox1[i].Checked)
         {
             A.usun_gracza(i - usuwanie, R);
             usuwanie++;
         }
         else
         {
             A.zmien_liczbe_punktow_gracza(i - usuwanie, Convert.ToInt32(textbox7[i].Text), R);
         }
     }
     R.Sortuj(0,R.liczba_graczy-1);
     A.zapisz_dane(R);
     this.Hide();
     obj.Show();
 }
Exemplo n.º 9
0
        public void usun_gracza()
        {
            Ranking_kl R = new Ranking_kl();
            Baza_danych_uzytkownika B = new Baza_danych_uzytkownika();

            for (int i = 0; i < R.liczba_graczy; i++)
            {
                if (R.dane[i].ID_logowania == this.ID_logowania)
                {
                    R.dane.RemoveAt(i);
                    B.dane.RemoveAt(this.ID_logowania);
                    R.liczba_graczy--;
                    B.liczba_graczy--;
                    break;
                }
            }
            for (int i = 0; i < R.liczba_graczy; i++)
            {
                if (R.dane[i].ID_logowania > this.ID_logowania)
                {
                    R.dane[i].ID_logowania--;
                }
            }
            StreamWriter rout;

            rout = new StreamWriter("ranking.csv");
            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);
            }
            rout.Close();
            StreamWriter pout;

            pout = new StreamWriter("baza.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);
            }
            pout.Close();
        }
Exemplo n.º 10
0
        public int zweryfikuj_login(string l, string h)
        {
            Baza_danych_uzytkownika B = new Baza_danych_uzytkownika();
            Ranking_kl R = new Ranking_kl();

            login = l;
            haslo = h;
            for (int i = 0; i < B.liczba_graczy; i++)
            {
                if (login == B.dane[i].login && haslo == B.dane[i].haslo)
                {
                    for (int j = 0; j < R.liczba_graczy; j++)
                    {
                        if (i == R.dane[j].ID_logowania)
                        {
                            return(i);
                        }
                    }
                }
            }
            return(-1);
        }
Exemplo n.º 11
0
        /// <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);
        }