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

JSONify activity text widget #55138

Merged
merged 5 commits into from
Feb 9, 2022

Conversation

wapcaplet
Copy link
Contributor

@wapcaplet wapcaplet commented Feb 5, 2022

Summary

None

Purpose of change

Contribute to #55076 by converting the "activity text" variable to a widget with JSONized conditional clauses.

Describe the solution

  • Add Character::activity_level_index() returning 0-5 (half of instantaneous_activity_level)
  • Add get_activity_level() to talker and implement it in talker_character, using the above function
  • Add u_var "activity_level" returning that get_activity_level value
  • Tests

Describe alternatives you've considered

It's a little jarring just how instantaneously-changing this widget is (in both the old and new versions). Simply walking around switches between "None" and "Moderate", and running goes straight to "Active". It might be nice if it were smoothed out over several turns.

Testing

Walk, run, dig pits. See activity level change in realtime.

Additional context

I couldn't get "Light" or "Brisk" to appear, but here are the others:

image

@github-actions github-actions bot added json-styled JSON lint passed, label assigned by github actions astyled astyled PR, label is assigned by github actions labels Feb 5, 2022
@Maleclypse Maleclypse added the Info / User Interface Game - player communication, menus, etc. label Feb 6, 2022
@wapcaplet wapcaplet added [C++] Changes (can be) made in C++. Previously named `Code` [JSON] Changes (can be) made in JSON Mechanics: Character / Player Character / Player mechanics labels Feb 6, 2022
@wapcaplet wapcaplet marked this pull request as ready for review February 7, 2022 21:28
@wapcaplet
Copy link
Contributor Author

There's a test failure in CI that I can reproduce locally with tests/cata_test --rng-seed 1644185419 causing all activity descriptions to show up as "Extreme". Investigating...

@dseguin
Copy link
Member

dseguin commented Feb 8, 2022

I tried using the same method as the activity tracker test and it seems to fix the issue (at least on my machine):

diff
diff --git a/tests/widget_test.cpp b/tests/widget_test.cpp
index 458c7292b6..ede43629bd 100644
--- a/tests/widget_test.cpp
+++ b/tests/widget_test.cpp
@@ -594,27 +594,30 @@ TEST_CASE( "widgets showing activity level", "[widget][activity]" )
     widget activity_w = widget_test_activity_clauses.obj();
 
     ava.reset_activity_level();
-    ava.set_activity_level( NO_EXERCISE );
+    activity_tracker &tracker = ava.activity_history;
+
+    tracker.new_turn();
+    tracker.log_activity( NO_EXERCISE );
     CHECK( activity_w.layout( ava ) == "Activity: <color_c_light_gray>None</color>" );
 
-    ava.reset_activity_level();
-    ava.set_activity_level( LIGHT_EXERCISE );
+    tracker.new_turn();
+    tracker.log_activity( LIGHT_EXERCISE );
     CHECK( activity_w.layout( ava ) == "Activity: <color_c_yellow>Light</color>" );
 
-    ava.reset_activity_level();
-    ava.set_activity_level( MODERATE_EXERCISE );
+    tracker.new_turn();
+    tracker.log_activity( MODERATE_EXERCISE );
     CHECK( activity_w.layout( ava ) == "Activity: <color_c_yellow>Moderate</color>" );
 
-    ava.reset_activity_level();
-    ava.set_activity_level( BRISK_EXERCISE );
+    tracker.new_turn();
+    tracker.log_activity( BRISK_EXERCISE );
     CHECK( activity_w.layout( ava ) == "Activity: <color_c_light_red>Brisk</color>" );
 
-    ava.reset_activity_level();
-    ava.set_activity_level( ACTIVE_EXERCISE );
+    tracker.new_turn();
+    tracker.log_activity( ACTIVE_EXERCISE );
     CHECK( activity_w.layout( ava ) == "Activity: <color_c_light_red>Active</color>" );
 
-    ava.reset_activity_level();
-    ava.set_activity_level( EXTRA_EXERCISE );
+    tracker.new_turn();
+    tracker.log_activity( EXTRA_EXERCISE );
     CHECK( activity_w.layout( ava ) == "Activity: <color_c_red>Extreme</color>" );
 }

I think it's also possible that the test could need the activity changes spaced out by something like 1_turns (using activity_tracker::new_turn() or Character::update_body()). I find that the activity tracker is just kind of wonky sometimes :P

@github-actions github-actions bot added the BasicBuildPassed This PR builds correctly, label assigned by github actions label Feb 8, 2022
@kevingranade kevingranade merged commit e84ea7e into CleverRaven:master Feb 9, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
astyled astyled PR, label is assigned by github actions BasicBuildPassed This PR builds correctly, label assigned by github actions [C++] Changes (can be) made in C++. Previously named `Code` Info / User Interface Game - player communication, menus, etc. [JSON] Changes (can be) made in JSON json-styled JSON lint passed, label assigned by github actions Mechanics: Character / Player Character / Player mechanics
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants