Hold back live chance statistics until the result of the chance
Prepare verified release / draft (push) Canceled after 0s
Prepare verified release / draft (push) Canceled after 0s
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
09b92c9b2a
commit
93ca832c71
5 files changed
+44
-5
No files matched your search
@@ -28,6 +28,10 @@ compared with the engine; every difference found was ported and documented.
|
|||||||
was inverted in the port (older players were recycled the wrong way round);
|
was inverted in the port (older players were recycled the wrong way round);
|
||||||
this is fixed.
|
this is fixed.
|
||||||
- **Season end.** Retirement and leave rules for the player slots.
|
- **Season end.** Retirement and leave rules for the player slots.
|
||||||
|
- **Live match statistics.** The chance counters at the bottom of the live
|
||||||
|
matchday screen counted a chance as soon as the engine logged it, before the
|
||||||
|
presentation started. They are now held back like the score and appear with
|
||||||
|
the result of the chance.
|
||||||
|
|
||||||
## What was measured, what was derived
|
## What was measured, what was derived
|
||||||
|
|
||||||
@@ -47,9 +51,9 @@ in the source as a known gap).
|
|||||||
|
|
||||||
## Open points
|
## Open points
|
||||||
|
|
||||||
Reported by the Diamond author and not changed here: bug in "fetch player from
|
Reported by the Diamond author and not changed here: the bug in "fetch player
|
||||||
transfer market / check offers", and the chance counters at the bottom of the
|
from transfer market / check offers" (exact steps still to be reproduced).
|
||||||
match screen count up slightly too early. Earlier open points remain: the
|
Earlier open points remain: the
|
||||||
"player card: original atlas bounds" error (#77), sporadic double clicks (#58)
|
"player card: original atlas bounds" error (#77), sporadic double clicks (#58)
|
||||||
and the macOS match scene speed (#70).
|
and the macOS match scene speed (#70).
|
||||||
|
|
||||||
|
|||||||
+4
-1
@@ -3291,7 +3291,10 @@ int main(int argc, char** argv) {
|
|||||||
}, [&](const LiveChanceEvent& event, const std::vector<MatchGroup>& groups,
|
}, [&](const LiveChanceEvent& event, const std::vector<MatchGroup>& groups,
|
||||||
const GameState& state) {
|
const GameState& state) {
|
||||||
if (!running || live_skipped) return;
|
if (!running || live_skipped) return;
|
||||||
const auto frame = ui::live_matchday_frame(event.minute, groups, state);
|
// Preview: the chance is already in the event log, but its statistics must not count yet.
|
||||||
|
const auto frame = event.stage == LiveChanceStage::preview
|
||||||
|
? ui::live_matchday_frame_before_chance(event.minute, groups, state, event)
|
||||||
|
: ui::live_matchday_frame(event.minute, groups, state);
|
||||||
live_score_reveal.observe(event.stage, frame);
|
live_score_reveal.observe(event.stage, frame);
|
||||||
if (frame.matches.empty()) return;
|
if (frame.matches.empty()) return;
|
||||||
const auto chance = ui::live_chance_projection(event, groups, state, season_exe);
|
const auto chance = ui::live_chance_projection(event, groups, state, season_exe);
|
||||||
|
|||||||
@@ -140,6 +140,18 @@ LiveMatchdayFrame live_matchday_frame(int minute, const std::vector<MatchGroup>&
|
|||||||
return frame;
|
return frame;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
LiveMatchdayFrame live_matchday_frame_before_chance(int minute, const std::vector<MatchGroup>& groups,
|
||||||
|
const GameState& state, const LiveChanceEvent& event) {
|
||||||
|
// MatchEngine::chance writes two log pairs (outcome, then kind/distance) = 4 words before the preview hook.
|
||||||
|
// The copy is small: chances are rare and only the log of one group is shortened.
|
||||||
|
if (event.group < 0 || size_t(event.group) >= groups.size() || groups[size_t(event.group)].log.size() < 4)
|
||||||
|
return live_matchday_frame(minute, groups, state);
|
||||||
|
std::vector<MatchGroup> before = groups;
|
||||||
|
auto& log = before[size_t(event.group)].log;
|
||||||
|
log.resize(log.size() - 4);
|
||||||
|
return live_matchday_frame(minute, before, state);
|
||||||
|
}
|
||||||
|
|
||||||
LiveChanceProjection live_chance_projection(const LiveChanceEvent& event,
|
LiveChanceProjection live_chance_projection(const LiveChanceEvent& event,
|
||||||
const std::vector<MatchGroup>& groups, const GameState& state, const LeImage& exe) {
|
const std::vector<MatchGroup>& groups, const GameState& state, const LeImage& exe) {
|
||||||
if (event.group < 0 || size_t(event.group) >= groups.size() || event.match < 0 ||
|
if (event.group < 0 || size_t(event.group) >= groups.size() || event.match < 0 ||
|
||||||
|
|||||||
@@ -51,8 +51,14 @@ struct LiveMatchdayFrame {
|
|||||||
LiveMatchdayFrame live_matchday_frame(int minute, const std::vector<MatchGroup>& groups,
|
LiveMatchdayFrame live_matchday_frame(int minute, const std::vector<MatchGroup>& groups,
|
||||||
const GameState& state);
|
const GameState& state);
|
||||||
|
|
||||||
|
// Frame of the matchday as it looked before the chance of the event was written to the event log. The engine
|
||||||
|
// logs a chance (two log pairs) before its preview hook, so the statistics rows (chances, shots, ...) would
|
||||||
|
// otherwise count it before the presentation has even started.
|
||||||
|
LiveMatchdayFrame live_matchday_frame_before_chance(int minute, const std::vector<MatchGroup>& groups,
|
||||||
|
const GameState& state, const LiveChanceEvent& event);
|
||||||
|
|
||||||
// The engine commits a chance before its ball/set-piece/shot presentation. Keep
|
// The engine commits a chance before its ball/set-piece/shot presentation. Keep
|
||||||
// the observed preview scores until the result hook, without delaying simulation.
|
// the observed preview scores and statistics until the result hook, without delaying simulation.
|
||||||
class LiveScoreReveal {
|
class LiveScoreReveal {
|
||||||
public:
|
public:
|
||||||
void observe(LiveChanceStage stage, const LiveMatchdayFrame& frame) {
|
void observe(LiveChanceStage stage, const LiveMatchdayFrame& frame) {
|
||||||
@@ -66,6 +72,8 @@ public:
|
|||||||
row.home_goals = before.home_goals;
|
row.home_goals = before.home_goals;
|
||||||
row.away_goals = before.away_goals;
|
row.away_goals = before.away_goals;
|
||||||
row.score_known = before.score_known;
|
row.score_known = before.score_known;
|
||||||
|
row.home_stats = before.home_stats;
|
||||||
|
row.away_stats = before.away_stats;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return frame;
|
return frame;
|
||||||
|
|||||||
@@ -26,6 +26,18 @@ int main() {
|
|||||||
reveal.observe(bmh::LiveChanceStage::result,resolved);
|
reveal.observe(bmh::LiveChanceStage::result,resolved);
|
||||||
if(reveal.project(resolved)!=resolved)throw std::runtime_error("result did not reveal goal");
|
if(reveal.project(resolved)!=resolved)throw std::runtime_error("result did not reveal goal");
|
||||||
}
|
}
|
||||||
|
// Statistics (chances, shots, ...) count a chance only at its result, like the score.
|
||||||
|
{
|
||||||
|
LiveScoreReveal stats_reveal;
|
||||||
|
stats_reveal.observe(bmh::LiveChanceStage::preview,frame);
|
||||||
|
auto counted=frame;counted.matches[0].home_stats={11,4,2,1};counted.matches[0].away_stats={11,3,0,0};
|
||||||
|
counted.matches[0].home_stats[1]++;
|
||||||
|
const auto shown=stats_reveal.project(counted);
|
||||||
|
if(shown.matches[0].home_stats!=frame.matches[0].home_stats||shown.matches[0].away_stats!=frame.matches[0].away_stats||
|
||||||
|
shown.matches[1]!=counted.matches[1])throw std::runtime_error("statistics counted before the result");
|
||||||
|
stats_reveal.observe(bmh::LiveChanceStage::result,counted);
|
||||||
|
if(stats_reveal.project(counted)!=counted)throw std::runtime_error("result did not reveal statistics");
|
||||||
|
}
|
||||||
reveal.observe(bmh::LiveChanceStage::preview,frame);
|
reveal.observe(bmh::LiveChanceStage::preview,frame);
|
||||||
if(reveal.project(frame)!=frame)throw std::runtime_error("miss changed score");
|
if(reveal.project(frame)!=frame)throw std::runtime_error("miss changed score");
|
||||||
auto next=frame;next.minute++;
|
auto next=frame;next.minute++;
|
||||||
|
|||||||
Reference in new issue
Block a user