Beispiel #1
0
        private void timerNtsynGetir_Tick(object sender, EventArgs e)
        {
            SatrancTahtasiController controller = new SatrancTahtasiController();

            SatrancTahtasiController.OdaKontrol odaKontrol = controller.odaKontrol(1);

            if (odaKontrol.odaSahibi && odaKontrol.rakipHamle || odaKontrol.odaRakip && odaKontrol.sahipHamle)
            {
                if (ntsyGetirKontrol)
                {
                    Models.satrancAlgoritmasi.NotasyonGetir hamleBilgisi = controller.notasyonGetir();

                    if (hamleBilgisi != null)
                    {
                        Control eskiTas = satrancTahtasiContainer.Controls.Find(hamleBilgisi.eskiPozisyon, true)[0];
                        Control yeniTas = satrancTahtasiContainer.Controls.Find(hamleBilgisi.yeniPozisyon, true)[0];

                        if (eskiTas.BackgroundImage != null && eskiTas.Tag != null)
                        {
                            yeniTas.BackgroundImage = (Image)Properties.Resources.ResourceManager.GetObject(eskiTas.Tag.ToString());
                            yeniTas.Tag             = eskiTas.Tag;
                        }

                        eskiTas.BackgroundImage = null;
                        eskiTas.Tag             = null;
                    }
                    ntsyGetirKontrol = false;
                }
            }
            else
            {
                ntsyGetirKontrol = true;
            }
        }
Beispiel #2
0
        private void notasyonOlustur(object sender, EventArgs e)
        {
            SatrancTahtasiController controller = new SatrancTahtasiController();
            Button btn = (sender as Button);

            if (!kontrol)
            {
                hamleVePozisyon.Clear();
                hamleVePozisyon.Add(btn.Tag);
                hamleVePozisyon.Add(btn.Name);

                SatrancTahtasiController.OdaKontrol odaKontrol = controller.odaKontrol(1);

                kontrol = true;

                if (btn.BackgroundImage == null)
                {
                    MessageBox.Show("BASTIĞINIZ HÜCREDE OYNATILACAK BİR TAŞ YOK!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    kontrol = false;
                }
                else if (odaKontrol.odaSahibi && !odaKontrol.odaRakip)
                {
                    if (!btn.Tag.ToString().Contains("beyaz")) // Beyaz taşa basmadıysanız
                    {
                        MessageBox.Show("SİYAH TAŞLARLA OYNAMA YETKİNİZ YOK!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        kontrol = false;
                    }
                    else if (!odaKontrol.hamleSirasi) // Sıra sizde değilse
                    {
                        MessageBox.Show("SIRA SİZDE DEĞİL!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        kontrol = false;
                    }
                }
                else if (!odaKontrol.odaSahibi && odaKontrol.odaRakip)
                {
                    if (btn.Tag.ToString().Contains("beyaz")) // Siyah taşa basmadıysanız
                    {
                        MessageBox.Show("BEYAZ TAŞLARLA OYNAMA YETKİNİZ YOK!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        kontrol = false;
                    }
                    else if (!odaKontrol.hamleSirasi) // Sıra sizde değilse
                    {
                        MessageBox.Show("SIRA SİZDE DEĞİL!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        kontrol = false;
                    }
                }
                else
                {
                    MessageBox.Show("İZLEYİCİ MODDA HAMLE YAPAMAZSINIZ", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    kontrol = false;
                }
            }
            else
            {
                hamleVePozisyon.Add(btn.Name);
                string notasyon = null, tasTuru = hamleVePozisyon.ToArray()[0].ToString(), pozisyon = hamleVePozisyon.ToArray()[1].ToString(), yeniPozisyon = hamleVePozisyon.ToArray()[2].ToString(), tasTuru2, yenenTas = "-";

                if (btn.Tag != null)
                {
                    tasTuru2 = btn.Tag.ToString();

                    if (tasTuru2 == "piyon" || tasTuru2 == "beyazPiyon")
                    {
                        yenenTas = "";
                    }
                    else if (tasTuru2 == "kale" || tasTuru2 == "beyazKale")
                    {
                        yenenTas = "K";
                    }
                    else if (tasTuru2 == "at" || tasTuru2 == "beyazAt")
                    {
                        yenenTas = "A";
                    }
                    else if (tasTuru2 == "fil" || tasTuru2 == "beyazFil")
                    {
                        yenenTas = "F";
                    }
                    else if (tasTuru2 == "sah" || tasTuru2 == "beyazSah")
                    {
                        yenenTas = "S";
                    }
                    else if (tasTuru2 == "vezir" || tasTuru2 == "beyazVezir")
                    {
                        yenenTas = "V";
                    }

                    if (tasTuru == "piyon" || tasTuru == "beyazPiyon")
                    {
                        notasyon = pozisyon + "x" + yeniPozisyon;
                    }
                    else if (tasTuru == "kale" || tasTuru == "beyazKale")
                    {
                        notasyon = "Kx" + yeniPozisyon;
                    }
                    else if (tasTuru == "at" || tasTuru == "beyazAt")
                    {
                        notasyon = "Ax" + yeniPozisyon;
                    }
                    else if (tasTuru == "fil" || tasTuru == "beyazFil")
                    {
                        notasyon = "Fx" + yeniPozisyon;
                    }
                    else if (tasTuru == "sah" || tasTuru == "beyazSah")
                    {
                        notasyon = "Sx" + yeniPozisyon;
                    }
                    else if (tasTuru == "vezir" || tasTuru == "beyazVezir")
                    {
                        notasyon = "Vx" + yeniPozisyon;
                    }
                }
                else
                {
                    if (tasTuru == "piyon" || tasTuru == "beyazPiyon")
                    {
                        notasyon = yeniPozisyon;
                    }
                    else if (tasTuru == "kale" || tasTuru == "beyazKale")
                    {
                        notasyon = "K" + yeniPozisyon;
                    }
                    else if (tasTuru == "at" || tasTuru == "beyazAt")
                    {
                        notasyon = "A" + yeniPozisyon;
                    }
                    else if (tasTuru == "fil" || tasTuru == "beyazFil")
                    {
                        notasyon = "F" + yeniPozisyon;
                    }
                    else if (tasTuru == "sah" || tasTuru == "beyazSah")
                    {
                        notasyon = "S" + yeniPozisyon;
                    }
                    else if (tasTuru == "vezir" || tasTuru == "beyazVezir")
                    {
                        notasyon = "V" + yeniPozisyon;
                    }
                }

                if (!controller.notasyonGonder(notasyon, pozisyon, yenenTas, 1))
                {
                    MessageBox.Show(notasyon + " Hatalı");
                }
                else
                {
                    Control eskiTas = satrancTahtasiContainer.Controls.Find(pozisyon, true)[0];

                    btn.Tag             = tasTuru;
                    btn.BackgroundImage = (Image)Properties.Resources.ResourceManager.GetObject(btn.Tag.ToString());

                    eskiTas.BackgroundImage = null;
                    eskiTas.Tag             = null;
                }

                kontrol = false;
            }
        }