// throws a card public Karta BaciKartu(int index) { Karta k = ruka[index]; ruka.RemoveAt(index); return(k); }
// deals a card public Karta PodeliKartu() { if (indeksi.Count == 0) { return(null); } int sindex = indeksi[rnd.Next(indeksi.Count)]; Karta pkarta = karte[sindex]; indeksi.Remove(sindex); return(pkarta); }
// all the card drawing goes here private void Form1_Paint(object sender, PaintEventArgs e) { int clientSizeHeight = this.ClientSize.Height - statusStrip1.Height; e.Graphics.DrawString(nazivIgre.ToString(), SystemFonts.DefaultFont, Brushes.White, 20, 20); e.Graphics.DrawString(igraci[0].Ime, SystemFonts.DefaultFont, Brushes.White, (this.ClientSize.Width - 277) / 2 - igraci[0].Ime.Length * 10, clientSizeHeight - 115); e.Graphics.DrawString(igraci[1].Ime, SystemFonts.DefaultFont, Brushes.White, this.ClientSize.Width - 87, (clientSizeHeight - 305) / 2 - 20); e.Graphics.DrawString(igraci[2].Ime, SystemFonts.DefaultFont, Brushes.White, (this.ClientSize.Width - 277) / 2 - igraci[2].Ime.Length * 10, 20); e.Graphics.DrawString(igraci[3].Ime, SystemFonts.DefaultFont, Brushes.White, 20, (clientSizeHeight - 305) / 2 - 20); for (int j = 0; j < igraci[0].Ruka.Count; j++) { int x = (this.ClientSize.Width - 277) / 2 + j * 30; int y = clientSizeHeight - 115; int width = 30; e.Graphics.DrawImage(igraci[0].Ruka[j].Slika, x, y); if (j == igraci[0].Ruka.Count - 1) { width = igraci[0].Ruka[j].Slika.Width; } igraci[0].Ruka[j].Rectangle = new Rectangle(x, y, width, igraci[0].Ruka[j].Slika.Height); } for (int j = 0; j < igraci[1].Ruka.Count; j++) { if (igraci[1].Ruka[j].Prikazi) { e.Graphics.DrawImage(igraci[1].Ruka[j].Slika, this.ClientSize.Width - 87, (clientSizeHeight - 305) / 2 + j * 30); } else { e.Graphics.DrawImage(spil.Pozadina, this.ClientSize.Width - 87, (clientSizeHeight - 305) / 2 + j * 30); } } for (int j = 0; j < igraci[2].Ruka.Count; j++) { if (igraci[2].Ruka[j].Prikazi) { e.Graphics.DrawImage(igraci[2].Ruka[j].Slika, (this.ClientSize.Width - 277) / 2 + j * 30, 20); } else { e.Graphics.DrawImage(spil.Pozadina, (this.ClientSize.Width - 277) / 2 + j * 30, 20); } } for (int j = 0; j < igraci[3].Ruka.Count; j++) { if (igraci[3].Ruka[j].Prikazi) { e.Graphics.DrawImage(igraci[3].Ruka[j].Slika, 20, (clientSizeHeight - 305) / 2 + j * 30); } else { e.Graphics.DrawImage(spil.Pozadina, 20, (clientSizeHeight - 305) / 2 + j * 30); } } if (timer2.Enabled) { e.Graphics.DrawImage(odigraneKarte[0].Slika, odigraneKarte0); e.Graphics.DrawImage(odigraneKarte[1].Slika, odigraneKarte1); e.Graphics.DrawImage(odigraneKarte[2].Slika, odigraneKarte2); e.Graphics.DrawImage(odigraneKarte[3].Slika, odigraneKarte3); } else { //1 Karta karta = trenutnaIgra.OdigraneKarte[0]; if (karta != null) { e.Graphics.DrawImage(karta.Slika, (this.ClientSize.Width - 67) / 2, clientSizeHeight / 2 + 5); } //2 karta = trenutnaIgra.OdigraneKarte[1]; if (karta != null) { e.Graphics.DrawImage(karta.Slika, this.ClientSize.Width / 2 + 23, (clientSizeHeight - 95) / 2); } //3 karta = trenutnaIgra.OdigraneKarte[2]; if (karta != null) { e.Graphics.DrawImage(karta.Slika, (this.ClientSize.Width - 67) / 2, clientSizeHeight / 2 - 100); } //4 karta = trenutnaIgra.OdigraneKarte[3]; if (karta != null) { e.Graphics.DrawImage(karta.Slika, this.ClientSize.Width / 2 - 90, (clientSizeHeight - 95) / 2); } } }
// add a card public void DodajKartu(Karta karta) { ruka.Add(karta); }