public override bool TryMove(Location target, Table table, out IStone willEated) { willEated = null; if (CheckMove(target, table) == false) { return(false); } var span = target - Location; // yatay - dikey hareket if (span.XDiff == 0 || span.YDiff == 0) { if (MovementRules.HorizontalOrVerticalCheck(Location, target, table) == false) { return(false); } } // çapraz else { if (MovementRules.DiagonalCheck(Location, target, table) == false) { return(false); } } willEated = table.Stones.GetFromLocation(target); return(true); }
public override bool TryMove(Location target, Table table, out IStone willEated) { willEated = default; if (CheckMove(target, table) == false) { return(false); } //int currentX = Location.X; //int currentY = Location.Y; //var span = target - Location; //for (int i = 1; i <= span.XDiff; i++) //{ // currentX += span.XMovement == MovementDirection.Forward ? 1 : -1; // currentY += span.YMovement == MovementDirection.Forward ? 1 : -1; // var checkLocation = table.GetLocation(currentX, currentY); // if (checkLocation == null) // { // return false; // } // var checkLocationStone = table.Stones.GetFromLocation(checkLocation); // if (checkLocationStone != null) // { // if (i != span.XDiff) // { // // son nokta değil arada taş var // return false; // } // else // { // willEated = checkLocationStone; // break; // } // } //} if (MovementRules.DiagonalCheck(Location, target, table) == false) { return(false); } willEated = table.Stones.GetFromLocation(target); if (willEated == this) { willEated = null; } return(true); }
public override bool TryMove(Location target, Table table, out IStone willEated) { willEated = default; if (CheckMove(target, table) == false) { return(false); } var targetLocationStone = table.Stones.GetFromLocation(target); var span = target - Location; // çapraz gidiş if (span.XDiff == span.YDiff) { var result = MovementRules.DiagonalCheck(Location, target, table); if (result == false) { return(result); } if (targetLocationStone != null) { willEated = targetLocationStone; } } // yatay || dikey gidiş if (span.XDiff == 0 || span.YDiff == 0) { var result = MovementRules.HorizontalOrVerticalCheck(Location, target, table); if (result == false) { return(result); } if (targetLocationStone != null) { willEated = targetLocationStone; } } return(true); }