1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51: 52: 53: 54: 55: 56: 57: 58: 59: 60:
| function TAboutForm.Gewonnen: Boolean; var i, j: Integer; begin Result := False;
for i := 0 to 6 do for j := 0 to 4 do if Felder[i, j].Tag = CurrPlayer then if CheckForVictory(i, j) then begin Result := True; Exit; end; end;
function TAboutForm.CheckForVictory(Col, Row: Integer): Boolean; begin Result := False;
if (Col + 3 in [0..6]) and (Row + 0 in [0..4]) and (Felder[Col + 1, Row + 0].Tag = CurrPlayer) and (Felder[Col + 2, Row + 0].Tag = CurrPlayer) and (Felder[Col + 3, Row + 0].Tag = CurrPlayer) then begin Result := True; Exit; end;
if (Col + 3 in [0..6]) and (Row + 3 in [0..4]) and (Felder[Col + 1, Row + 1].Tag = CurrPlayer) and (Felder[Col + 2, Row + 2].Tag = CurrPlayer) and (Felder[Col + 3, Row + 3].Tag = CurrPlayer) then begin Result := True; Exit; end;
if (Col + 0 in [0..6]) and (Row + 3 in [0..4]) and (Felder[Col + 0, Row + 1].Tag = CurrPlayer) and (Felder[Col + 0, Row + 2].Tag = CurrPlayer) and (Felder[Col + 0, Row + 3].Tag = CurrPlayer) then begin Result := True; Exit; end;
if (Col - 3 in [0..6]) and (Row + 3 in [0..4]) and (Felder[Col - 1, Row + 1].Tag = CurrPlayer) and (Felder[Col - 2, Row + 2].Tag = CurrPlayer) and (Felder[Col - 3, Row + 3].Tag = CurrPlayer) then begin Result := True; Exit; end; end; |