event_field_transformation functions shouldn't need to be written
defensively against invalid inputs. So, pre-check the arguments and
don't call the function if an argument is invalid and non-empty.
We're already relying on them supporting empty arguments, so we can't
filter those out. Maybe in the future those empty arguments should be
replaced by null instead.
When building achievements_trackers for past_games_info, these
achievements_trackers were setting up their full-featured infrastructure
of watchers. This serves no purpose, because no new events will occur
for these past games, and we only really want these
achievements_trackers for their info about already-completed
achievements.
Add a new options to achievements_tracker to disable these watchers and
use it in this case.
* Make scent_map private in game
* Make timed events private in game.
* Make achievements tracker private in game
* Make memoial tracker private in game
* Make scenario variable private in game
Previously we kept only counts of events (partitioned by field values).
Convert that int to a new class event_summary, which also contains
time_points for the oldest and newest events in each partition.
We want the game_start event to record everything relevant about the
starting character (the sorts of things people expect to see in a
memorial log).
This adds some of those things:
* Name
* Grammatical gender
* Profession
* Game version
Centralizing this data in move modes makes maintenance and changes
easier.
Also, it cleans up the code (see avatar::set_movement_mode).
Move mode switching restrictions could use some more nuance, instead of
just being restricted to running.
The `movement_mode_is` function may seem redundant with the `is_x`
functions, but it returns true only if the move mode is the exact
provided move mode, where the `is_running` function returns true based
on type - this means a theoretical new sprinting mode satisfies
is_running, but fails `movement_mode_is( move_mode_running )`.
The move_mode_color function in panels was odd - it returned light_gray
if the mode was walking, but in the only place it was used, it wasn't
called if the move mode was walking, and white was used instead.
The vehicle follow distance was previously just 400 times the move speed
multiplier of the move mode. Let's future proof it and make it like
that, so that we don't get caught by it in the future adding a new move
mode.
Conducts (inspired by the NetHack concept of the same name) are
additional restrictions that can apply to a game. They tend to be
things which start true, but the player can violate at some point.
Examples are not killing, or being vegetarian.
The implementation of conducts is based on achievements, because they
are essentially the same, except that where achievements begin false,
and can become true at some point, conducts begin true and can become
false.
We don't want people to accidentally get achievements when they are
merely doing dev work or debugging issues.
Make it so that most debug menu functions disable achievements. Also,
add a new debug menu option to re-enable them (for cases where people
were just working around bugs, or when people want to debug achievements
themselves).
When achievements are disabled, the tracker still tracks them but
doesn't print any log messages when they are attained.
Longer-term, this will matter more. Once there is global tracking of
achievements across games the achievements attained while they were
disabled won't count towards that.
Fixes#39879.
We now stop tracking requirement values when the achievement is
completed or fails. Moreover, fixes a bug where a completed achievement
could be un-completed by further changes to the underlying statistics.
* Add Page Up / Down support to scrolling_text_view
And add keybindings for it in the scores_ui.
* Make scores_ui window taller
Rather than the "standard" terminal height (which is quite small), make
it the full window height minus two.
* Rename scores UI keybinding
Make it clear that this keybinding is about more than just scores.
* Support plurals for statistic descriptions
Allow for achievements to specify a minimum or maximum time bound within
which they must be completed.
Test this with a new "kill within the first minute" achievement.
With this change, achievements can now become "failed", meaning that it
is impossible to ever achieve them in this game. Failed achievements
get sorted to the bottom of the list, and get a new colour scheme.
As a side-effect, other requirements can also get a "<=" constraint,
which also means they can become impossible to satisfy, and can lead to
achievements being failed. To support this we need to track which
statistics are monotonic, so we know when such failures are
irreversible.
It makes more sense to name the statistics, since both scores and
achievements are based on them, and we would only end up writing the
same information twice.
So, if a score has no description, derive one from its statistic.
* Support PREV_TAB, NEXT_TAB in scores window
* Add achievements tab to scores window
Want the player to be able to see the achievements they are working
towards.
* Add achievements text unit test
* Helper script to run IWYU
* Run IWYU
* Update deprecated headers
* Run IWYU again
* Re-suppress cxxabi.h
This pragma got accidentally removed because it was deemed to be a
comment attached to a #include.
* Remove extra SDL header includes
* Fix ime.cpp headers
Some tweaks to help IWYU not break this file by messing with
platform-specific stuff not relevant on Linux.
* Update game.h
* Move new point.h includes inside #ifdef
* Re-add platform_win.h to mapsharing.cpp
* Apply suggestions from code review
Co-authored-by: ZhilkinSerg <ZhilkinSerg@users.noreply.github.com>
A minimal achievements implementation. This is built on top of the
stats_tracker and achievement requirements are defined in terms of
event_statistic values managed there.
As a proof of concept, added a single json-defined achievement when the
player kills their first zombie.
Currently the only UI manifestation of achievements is a message in the
log. In the long term I plan to add a new tab to the scores window.
Also, achievements are currently local to each save. In the future we
also want to have a permanent record of what achievements have been
obtained in each player's historical games.
Two new features for event_transformations: the ability to drop fields,
and the ability to add new fields using new event_field_transformation
functions.
The only such function currently implemented is extracting species from
monster types.
Prior to this change, each time the value of an event_statistic is
required, it must be recomputed entirely from scratch.
With this change, the stats_tracker can maintain objects which monitor
the transformations and stats involved, and automatically trigger
updates when relevant events occur.
The ultimate goal is to permit achievements to be triggered more
efficiently.
Change event_tracker into event_multiset, because we want it to be a
more generic object used for more than just tracking events. It now
represents any collection of events of the same type.
Introduce three new json-defined objects:
- event_transformation, which converts one multiset of events to
another. For example, it can filter all kill events to just kill
events attributed to the avatar.
- event_statistic, which converts a multiset of events into a single
value. The simplest case, for example, is counting the number of
events.
- score, which uses an event_statistic to produce a score, which can be
saved as a permanent record of a game. Currently scores' only purpose
is to be written to the memorial log.