Files
Dreierpack-Manager/src/game/reality_ball.hpp
T
ClaudeandClaude Sonnet 5.5 287b5a9251 Add header comments to the source files
Every source file in ui, app, game, formats, cli, audio and launch that had none
now starts with a short English comment: what it implements, what state it owns
and how it relates to its neighbours (request/acknowledge flow, pairs of files,
random generator use). Comment lines only; the full build and the runnable
tests are unchanged.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-06 09:15:23 +01:00

50 lines
2.6 KiB
C++

// SPDX-License-Identifier: GPL-3.0-only
// Interface of the Reality scene ball logic: ball history, decision and outcome types and the
// decide/apply functions implemented in reality_ball.cpp. The functions take WatcomRandom (and
// GameRandom where declared).
#pragma once
#include "game/rating.hpp"
#include "game/reality_space.hpp"
namespace bmh {
struct RealityBallHistory {
int current_actor = 0xfff, previous_actor = 0xfff; // afb08/afb06
uint8_t airborne = 0; // afb72
};
enum class RealityBallBoundary { direct_move, dribble_or_duel };
struct RealityBallDecision {
RealityBallBoundary boundary = RealityBallBoundary::direct_move;
int actor = 0, side = 0, previous_actor = 0xfff;
int action = 0, score = 0, dribble_score = 0; // afb7a:0 shot,1 pass; source shorts
int goal_distance = 0, shooting = 0, passing = 0, teamplay = 0;
int original_x = 0, original_y = 0, goal_blockers = 0, speed_ability = 0;
uint8_t actor_duel = 0, opponent_duel = 0;
int receiver = -1, receiver_player = 0xfff, target_x = 0, target_y = 0;
uint8_t airborne = 0, opponent_at_actor = 0, opponent_nearby = 0;
std::array<uint8_t,2> line_selected{}; // afaec, one-based occupancy IDs
int scatter_x = 0, scatter_y = 0, receiver_nearby = 0;
bool intercepted = false, inaccurate = false, blocked_attempt = false;
bool receiver_offside = false, leading_run = false;
};
// ApplyRealityBall prefix through the shot/pass-vs-dribble decision. Caller must clear
// the actor's old occupancy, as DecideRealityBall does. Uses Source rating context/RNG;
// no fabricated foul/dribble outcome and no reporter text draws.
RealityBallDecision decide_reality_ball(const GameState&, const RealitySetup&, int actor,
const RealityBallHistory&, const RatingContext&, WatcomRandom&);
struct RealityBallOutcome {
int action = 0, scene_status = 0, restart = 0, shooter = 0xfff, assistant = 0xfff;
int shooter_row = 0xfff, assistant_row = 0xfff;
bool received = false, shot_ready = false, needs_reporter = true;
bool event_stops_scene = false, lost_duel = false;
};
// ApplyRealityBall's common tail for a selected shot/pass. Source Game/Watcom calls
// for airborne reception, boundary handling and pass offside are preserved.
// A dribble/duel decision is rejected before any mutation or additional draws.
RealityBallOutcome apply_reality_ball(const GameState&, RealitySetup&, const RealityBallDecision&,
RealityBallHistory&, const RatingContext&, uint8_t referee,
WatcomRandom&, GameRandom&);
} // namespace bmh