mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-09-19 09:17:38 +03:00
LibChess: Add the UCI quit command
This commit is contained in:
parent
d2f9645cc0
commit
13dbc69c23
Notes:
sideshowbarker
2024-07-17 07:16:27 +09:00
Author: https://github.com/tcl3 Commit: https://github.com/SerenityOS/serenity/commit/13dbc69c23 Pull-request: https://github.com/SerenityOS/serenity/pull/18140 Issue: https://github.com/SerenityOS/serenity/issues/17427 Reviewed-by: https://github.com/LucasChollet Reviewed-by: https://github.com/petelliott
@ -333,4 +333,17 @@ DeprecatedString InfoCommand::to_deprecated_string() const
|
|||||||
return "info";
|
return "info";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QuitCommand QuitCommand::from_string([[maybe_unused]] StringView command)
|
||||||
|
{
|
||||||
|
auto tokens = command.split_view(' ');
|
||||||
|
VERIFY(tokens[0] == "quit");
|
||||||
|
VERIFY(tokens.size() == 1);
|
||||||
|
return QuitCommand();
|
||||||
|
}
|
||||||
|
|
||||||
|
DeprecatedString QuitCommand::to_deprecated_string() const
|
||||||
|
{
|
||||||
|
return "quit\n";
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -268,4 +268,16 @@ public:
|
|||||||
// FIXME: Add additional fields.
|
// FIXME: Add additional fields.
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class QuitCommand : public Command {
|
||||||
|
public:
|
||||||
|
explicit QuitCommand()
|
||||||
|
: Command(Command::Type::Quit)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
static QuitCommand from_string(StringView command);
|
||||||
|
|
||||||
|
virtual DeprecatedString to_deprecated_string() const override;
|
||||||
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -53,6 +53,8 @@ void Endpoint::event(Core::Event& event)
|
|||||||
return handle_bestmove(static_cast<BestMoveCommand const&>(event));
|
return handle_bestmove(static_cast<BestMoveCommand const&>(event));
|
||||||
case Command::Type::Info:
|
case Command::Type::Info:
|
||||||
return handle_info(static_cast<InfoCommand const&>(event));
|
return handle_info(static_cast<InfoCommand const&>(event));
|
||||||
|
case Command::Type::Quit:
|
||||||
|
return handle_quit();
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -97,6 +99,8 @@ NonnullOwnPtr<Command> Endpoint::read_command()
|
|||||||
return make<BestMoveCommand>(BestMoveCommand::from_string(line));
|
return make<BestMoveCommand>(BestMoveCommand::from_string(line));
|
||||||
} else if (line.starts_with("info"sv)) {
|
} else if (line.starts_with("info"sv)) {
|
||||||
return make<InfoCommand>(InfoCommand::from_string(line));
|
return make<InfoCommand>(InfoCommand::from_string(line));
|
||||||
|
} else if (line.starts_with("quit"sv)) {
|
||||||
|
return make<QuitCommand>(QuitCommand::from_string(line));
|
||||||
}
|
}
|
||||||
|
|
||||||
dbgln("command line: {}", line);
|
dbgln("command line: {}", line);
|
||||||
|
@ -30,6 +30,7 @@ public:
|
|||||||
virtual void handle_readyok() { }
|
virtual void handle_readyok() { }
|
||||||
virtual void handle_bestmove(BestMoveCommand const&) { }
|
virtual void handle_bestmove(BestMoveCommand const&) { }
|
||||||
virtual void handle_info(InfoCommand const&) { }
|
virtual void handle_info(InfoCommand const&) { }
|
||||||
|
virtual void handle_quit() { }
|
||||||
|
|
||||||
void send_command(Command const&);
|
void send_command(Command const&);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user