public void create(int ulog, bool model, PictureBox[] slike) { if (model) { _model = new Standard(); } else { _model = new francuz(); } _model.create(); _stanje = ulog; _list = new List <karta>(); for (int i = 0; i < 7; i++) { if (i < 3) { karta blank = new karta(); blank.Broj = -1; blank.Slika = new Bitmap(Application.StartupPath + "/cards/back.jpg"); _list.Add(blank); } else { _list.Add(_model.draw()); } Bitmap x = new Bitmap(_list[i].Slika, slike[i].Width, slike[i].Height); slike[i].Image = x; slike[i].Tag = _list[i]; } _ulog = 0; }
public void restart(PictureBox[] slike) { _model.create(); _list = new List <karta>(); for (int i = 0, j = -1; i < 7; i++) { if (i < 3) { karta blank = new karta(); blank.Broj = -1; blank.Slika = new Bitmap(Application.StartupPath + "/cards/back.jpg"); _list.Add(blank); } else { _list.Add(_model.draw()); j++; } Bitmap x = new Bitmap(_list[i].Slika, slike[i].Width, slike[i].Height); slike[i].Image = x; slike[i].Tag = _list[i]; } Dodatnimul = 5; swaps = 0; }
private void pictureBox5_Click(object sender, EventArgs e) { if (selected != null) { PictureBox x = sender as PictureBox; karta tag = x.Tag as karta; tag.IsSelected = !tag.IsSelected; if (tag.IsSelected) { if (selected.Count == 3) { MessageBox.Show("maksimalno tri slike"); } else { x.BorderStyle = BorderStyle.FixedSingle; selected.Add(x); } } else { x.BorderStyle = BorderStyle.None; selected.Remove(x); } } }
private int find(karta x) { for (int i = 0; i < _list.Count; i++) { if (_list[i] == x) { return(i); } } return(-1); }
private ICollection <karta> sufel(List <karta> g) { List <karta> temp = g; Random r = new Random(Environment.TickCount); for (int i = 0; i < temp.Count * temp.Count; i++) { int x2 = r.Next(0, temp.Count - 1); karta tmp = temp[i % temp.Count]; temp[i % temp.Count] = temp[x2]; temp[x2] = tmp; } return(temp); }
public static int compare(karta a, karta b) { if (a.Broj < b.Broj) { return(-1); } else if (a.Broj == b.Broj) { return(0); } else { return(1); } }
private void button1_Click(object sender, EventArgs e) { con.swap(ref selected); for (int i = 0; i < selected.Count; i++) { karta x = selected[i].Tag as karta; selected[i].Image = new Bitmap(x.Slika, selected[i].Width, selected[i].Height); selected[0].BorderStyle = BorderStyle.None; selected[i].Update(); } if (con.GetType() == typeof(Clasic)) { selected = null; button1.Enabled = false; } else { selected = new List <PictureBox>(); } label1.Text = "stanje: " + con.Stanje.ToString(); label2.Text = "ulog: " + con.Ulog; }
public void swap(ref List <PictureBox> krt) { if (krt.Count == 1) { if (((karta)krt[0].Tag).Broj == -1) { int i = find((karta)krt[0].Tag); //_list.Add(_model.draw()); karta nov = _model.draw(); Bitmap x = new Bitmap(_list[i].Slika, krt[0].Width, krt[0].Height); krt[0].Image.Dispose(); krt[0].Image = new Bitmap(_list[i].Slika, krt[0].Width, krt[0].Height); _list[i] = nov; krt[0].Tag = _list[i]; krt[0].Update(); switch (swaps) { case 0: Dodatnimul = 2; break; case 1: int g = Stanje - _ulog; _ulog += g; Stanje -= g; break; case 2: int s = _ulog * 2; Stanje -= s; _ulog += s; break; } swaps++; } } }