Files

52 lines
1.8 KiB
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# satranc.js — handler() (satır 411)
[← satranc.js](index.md) · [← Master](../../wiki.md)
Parça 2/3 · [önceki](handler.md) · [sonraki](handler-3.md)
```javascript
var hamleler = gecerliHamleler(tahta, tikPos, enPasant);
var sahRenk = sahTehdit(tahta, "B") ? "B" : "";
tahtaCiz(uiContext, tahta, tikPos, hamleler, sahRenk);
}
}
else
{
var hamleler = gecerliHamleler(tahta, secili, enPasant);
var hamleGecerli = false;
for (var h = 0; h < hamleler.length; h++)
if (hamleler[h] === tikPos) { hamleGecerli = true; break; }
if (hamleGecerli)
{
var tas = tahta[secili];
var yeniEnPasant = -1;
if (tas.charAt(1) === "P" && tikPos === enPasant)
{
var yon = 1;
tahta[idx(row(tikPos) + yon, col(tikPos))] = "";
}
if (tas.charAt(1) === "P" && Math.abs(row(secili) - row(tikPos)) === 2)
{
yeniEnPasant = idx(row(tikPos) + 1, col(tikPos));
}
tahta[tikPos] = tas;
tahta[secili] = "";
if (tas === "BP" && row(tikPos) === 0) tahta[tikPos] = "BV";
states.setString("enPasant", "" + yeniEnPasant);
states.setString("tahta", tahtaToString(tahta));
states.setString("secili", "-1");
// AI hamlesi
statusCiz(uiContext, "S", "ai");
tahtaCiz(uiContext, tahta, -1, [], "");
var aiH = aiHamle(tahta, yeniEnPasant);
if (aiH !== null)
{
tahta = hamleYap(tahta, aiH.den, aiH.e);
```