public void undo() { Coups c = played[played.Count - 1]; played.Remove(c); if (c.getValue() > 0) { //les blancs jouent if (c.prise.getColor()) { yours.Add(c.prise); Piece p = tab[c.xArrivee, c.yArrivee]; p.x = c.xDepart; p.y = c.yDepart; tab[c.xDepart, c.yDepart] = p; tab[c.xArrivee, c.yArrivee] = c.prise; c.prise.x = c.xArrivee; c.prise.y = c.yArrivee; } //les noirs jouent else { mine.Add(c.prise); Piece p = tab[c.xArrivee, c.yArrivee]; p.x = c.xDepart; p.y = c.yDepart; tab[c.xDepart, c.yDepart] = p; tab[c.xArrivee, c.yArrivee] = c.prise; c.prise.x = c.xArrivee; c.prise.y = c.yArrivee; } } else { Piece p = tab[c.xDepart, c.yDepart]; tab[c.xDepart, c.yDepart] = tab[c.xArrivee, c.yArrivee]; tab[c.xArrivee, c.yArrivee] = p; p.x = c.xArrivee; p.y = c.yArrivee; tab[c.xDepart, c.yDepart].x = c.xDepart; tab[c.xDepart, c.yDepart].y = c.xDepart; } }
public void playMove(Coups c) { played.Add(c); if (c.getValue() > 0) { //les blancs jouent if (c.prise.getColor()) { yours.Remove(c.prise); Piece p = tab[c.xDepart, c.yDepart]; p.x = c.xArrivee; p.y = c.yArrivee; tab[c.xArrivee, c.yArrivee] = p; tab[c.xDepart, c.yDepart] = new Piece(0, true, c.xDepart, c.yDepart, this); } //les noirs jouent else { mine.Remove(c.prise); Piece p = tab[c.xDepart, c.yDepart]; p.x = c.xArrivee; p.y = c.yArrivee; tab[c.xArrivee, c.yArrivee] = p; tab[c.xDepart, c.yDepart] = new Piece(0, true, c.xDepart, c.yDepart, this); } } else { Piece p = tab[c.xDepart, c.yDepart]; tab[c.xDepart, c.yDepart] = tab[c.xArrivee, c.yArrivee]; tab[c.xArrivee, c.yArrivee] = p; p.x = c.xArrivee; p.y = c.yArrivee; tab[c.xDepart, c.yDepart].x = c.xDepart; tab[c.xDepart, c.yDepart].y = c.xDepart; } }