Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Initial bare-bones implementation of achievements #39351

Merged
merged 4 commits into from
Apr 9, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion data/json/scores.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,21 @@
"id": "num_avatar_zombie_kills",
"type": "event_statistic",
"stat_type": "count",
"event_transformation": "avatar_zombie_kills"
"event_transformation": "avatar_zombie_kills",
"description": "Number of zombies killed"
},
{
"id": "score_kills",
"type": "score",
"description": "Number of monsters killed: %s",
"statistic": "num_avatar_kills"
},
{
"id": "achievement_kill_zombie",
"type": "achievement",
"description": "One down, billions to go\u2026",
"requirements": [ { "event_statistic": "num_avatar_zombie_kills", "is": ">=", "target": 1 } ]
},
{
"id": "moves_not_mounted",
"type": "event_transformation",
Expand Down
29 changes: 28 additions & 1 deletion doc/JSON_INFO.md
Original file line number Diff line number Diff line change
Expand Up @@ -1053,7 +1053,7 @@ request](https://github.com/CleverRaven/Cataclysm-DDA/pull/36657) and the
}
```

### Scores
### Scores and achievements

Scores are defined in two or three steps based on *events*. To see what events
exist and what data they contain, read [`event.h`](../src/event.h).
Expand Down Expand Up @@ -1178,6 +1178,11 @@ given field for that unique event:
"field": "avatar_id"
```

Regardless of `stat_type`, each `event_statistic` can also have:
```C++
"description": "Number of things" // Intended for use in describing achievement requirements.
```

#### `score`

Scores simply associate a description to an event for formatting in tabulations
Expand All @@ -1194,6 +1199,28 @@ Note that even though most statistics yield an integer, you should still use
"statistic": "avatar_num_headshots"
```

#### `achievement`

Achievements are goals for the player to aspire to, in the usual sense of the
term as popularised in other games.

An achievement is specified via requirements, each of which is a constraint on
an `event_statistic`. For example:

```C++
{
"id": "achievement_kill_zombie",
"type": "achievement",
// The achievement description is used for the UI.
"description": "One down, billions to go\u2026",
"requirements": [
// Each requirement must specify the statistic being constrained, and the
// constraint in terms of a comparison against some target value.
{ "event_statistic": "num_avatar_zombie_kills", "is": ">=", "target": 1 }
]
},
```

### Skills

```C++
Expand Down
2 changes: 2 additions & 0 deletions lang/extract_json_strings.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ def warning_supressed(filename):
# "sound" member
# "messages" member containing an array of translatable strings
automatically_convertible = {
"achievement",
"activity_type",
"AMMO",
"ammunition_type",
Expand All @@ -125,6 +126,7 @@ def warning_supressed(filename):
"CONTAINER",
"dream",
"ENGINE",
"event_statistic",
"faction",
"furniture",
"GENERIC",
Expand Down
Loading