Added battles in networking

This commit is contained in:
Vladislav Khorev committed 2026-11-07 14:27:22 +06:00
1 parent be8ee31f03
commit 40527f10ac
8 files changed
+302 -36

No files matched your search

+20 -1
View File
@@ -177,6 +177,16 @@ void WebsocketGameClient::submit(const GameCommand& command)
std::get_if<SetCharacterDestinationCommand>(&command)) {
impl_->send(makeDestinationInputMessage(
{nextClientSequence_++, destination->target}));
} else if (const auto* target =
std::get_if<SetCharacterTargetCommand>(&command)) {
impl_->send(makeCharacterActionInputMessage(
{nextClientSequence_++, "set_target", target->targetId}));
} else if (std::holds_alternative<ClearCharacterAttackTargetCommand>(command)) {
impl_->send(makeCharacterActionInputMessage(
{nextClientSequence_++, "clear_attack_target", {}}));
} else if (std::holds_alternative<TryCharacterAttackComboCommand>(command)) {
impl_->send(makeCharacterActionInputMessage(
{nextClientSequence_++, "try_attack_combo", {}}));
}
}
@@ -259,9 +269,18 @@ void WebsocketGameClient::update(std::int64_t)
if constexpr (std::is_same_v<T, ScheduledDestinationCommand>) {
replica_.submit(SetCharacterDestinationCommand{
locationId, command.playerId, command.target, {}});
} else {
} else if constexpr (std::is_same_v<T, ScheduledCharacterEnabledCommand>) {
replica_.submit(SetCharacterEnabledCommand{
command.locationId, command.characterId, command.enabled});
} else if (command.action == "set_target") {
replica_.submit(SetCharacterTargetCommand{
locationId, command.playerId, command.targetId});
} else if (command.action == "clear_attack_target") {
replica_.submit(ClearCharacterAttackTargetCommand{
locationId, command.playerId});
} else if (command.action == "try_attack_combo") {
replica_.submit(TryCharacterAttackComboCommand{
locationId, command.playerId});
}
}, scheduled);
}