mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 23:17:46 +00:00
LibChess: Add and use Square::{file,rank}_char() methods
This saves us having to build and allocate a String, just to then use one character of it.
This commit is contained in:
parent
c73c697f94
commit
5f6dd87163
4 changed files with 35 additions and 13 deletions
|
@ -1,5 +1,6 @@
|
|||
/*
|
||||
* Copyright (c) 2020, the SerenityOS developers.
|
||||
* Copyright (c) 2023, Sam Atkins <atkinssj@serenityos.org>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
@ -89,6 +90,9 @@ struct Square {
|
|||
|
||||
bool in_bounds() const { return rank >= 0 && file >= 0 && rank < 8 && file < 8; }
|
||||
bool is_light() const { return (rank % 2) != (file % 2); }
|
||||
|
||||
char file_char() const;
|
||||
char rank_char() const;
|
||||
DeprecatedString to_algebraic() const;
|
||||
};
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue