public void fixPos(int pos, int team) { List <Ficha> coins = coinsAt(pos, team); if (coins.Count == 1) { if (coins[0].atHome()) { int inPos = (coins[0].pos / 100) - 1; coins[0].img.Location = Const.winPaths[coins[0].team, inPos]; } else { coins[0].img.Location = Const.cells[(coins[0].pos - 1)]; } } else if (coins.Count == 2) { Ficha first = coins[0]; Ficha second = coins[1]; int posX = first.img.Location.X; int posY = first.img.Location.Y; // At home if (first.atHome() && second.atHome()) { if (first.team == Const.GREEN || first.team == Const.BLUE) { first.img.Location = new Point(posX, posY + 20); second.img.Location = new Point(posX, posY - 20); } if (first.team == Const.RED || first.team == Const.YELLOW) { first.img.Location = new Point(posX + 20, posY); second.img.Location = new Point(posX - 20, posY); } } // Normal horizontal else if ((first.pos >= 52 && first.pos <= 59) || (first.pos >= 9 && first.pos <= 17) || (first.pos >= 18 && first.pos <= 25) || (first.pos >= 43 && first.pos <= 51)) { first.img.Location = new Point(posX, posY + 20); second.img.Location = new Point(posX, posY - 20); } // Normal vertical else { first.img.Location = new Point(posX + 20, posY); second.img.Location = new Point(posX - 20, posY); } } else { return; } }
public bool canMoveFicha(Ficha f, int amount, Ficha previewFicha) { if (f.atHome()) { return(canMoveHome(f, ((f.pos / 100) + amount), previewFicha)); } // Console.WriteLine("Moving coin of team " + f.team + " with " + amount + " moves."); int prev = f.pos; int newPos = (f.pos + amount - 1) % Const.cells.Length; previewFicha.pos = newPos + 1; previewFicha.img.Location = Const.cells[newPos]; // Entering home if ((f.team == Const.RED && prev <= 34 && previewFicha.pos > 34) || (f.team == Const.BLUE && prev <= 17 && previewFicha.pos > 17) || (f.team == Const.YELLOW && prev > 40 && prev <= 68 && (prev + amount) > 68) || (f.team == Const.GREEN && prev <= 51 && previewFicha.pos > 51)) { int amountCasa = (prev + amount - Const.preWinCells[f.team]); // Check bridges for path outside home if (isBridges(f, Const.preWinCells[f.team])) { return(false); } return(canMoveHome(f, amountCasa, previewFicha)); } // Si hay puentes (y no en casa), devolver null (false) if (isBridges(f, newPos + 1)) { return(false); } return(true); }
public Ficha testPosition(Ficha f, int amount) { if (f.atHome()) { return(moveAtHome(f, ((f.pos / 100) + amount))); } int prev = f.pos; int newPos = (f.pos + amount - 1) % Const.cells.Length; previewFicha.pos = newPos + 1; previewFicha.img.Location = Const.cells[newPos]; // Entering home if ((f.team == Const.RED && prev <= 34 && previewFicha.pos > 34) || (f.team == Const.BLUE && prev <= 17 && previewFicha.pos > 17) || (f.team == Const.YELLOW && prev > 40 && prev <= 68 && (prev + amount) > 68) || (f.team == Const.GREEN && prev <= 51 && previewFicha.pos > 51)) { int amountCasa = (prev + amount - Const.preWinCells[f.team]); // Check bridges for path outside home if (isBridges(f, Const.preWinCells[f.team])) { return(null); } return(moveAtHome(f, amountCasa)); } // Si hay puentes (y no en casa), devolver null (false) if (isBridges(f, newPos + 1)) { return(null); } return(this.previewFicha); }