Cataclysm-DDA icon indicating copy to clipboard operation
Cataclysm-DDA copied to clipboard

Consumption now checks for JSON Flags instead of trait ID

Open actually-the-artificer opened this issue 2 years ago • 7 comments

Summary

Bugfixes "Consumption code now checks for JSON Flag instead of ID"

Purpose of change

Fixes #63558

Describe the solution

Switched from has_trait to has_flag. This also makes the Mutation flags distinct for readability instead of them being under the 'CANNIBAL' umbrella.

Describe alternatives you've considered

Leaving it up to @Venera3 to finish.

Testing

I ran a quick build with Visual studio as a once-over.

Additional context

This change also opens up opportunities for modders who may desire to add their own mutation trees.

actually-the-artificer avatar Feb 23 '23 12:02 actually-the-artificer

https://github.com/CleverRaven/Cataclysm-DDA/blob/master/doc/JSON_FLAGS.md#character also needs to be updated if you change character flags

irwiss avatar Feb 23 '23 13:02 irwiss

There seems to be some incorrect deletions that sneaked in.

Qrox avatar Feb 24 '23 04:02 Qrox

There seems to be some incorrect deletions that sneaked in.

Hey, thanks for telling me; I must've missed them in my haste. I tried to revert them.

Though, please do tell me which ones they are; and why the style tests are failing even though I installed the Astyle extension for visual studio 2022.

actually-the-artificer avatar Feb 24 '23 07:02 actually-the-artificer

OK so I reverted all the styling things; now the most recent commit should be "add new flags to item.cpp"

actually-the-artificer avatar Feb 24 '23 07:02 actually-the-artificer

I think that should be all, unless I missed something.

actually-the-artificer avatar Feb 24 '23 08:02 actually-the-artificer

I guess that's all that needs to be done, except for the last of the styling. Currently trying to get the extension to work

actually-the-artificer avatar Feb 24 '23 09:02 actually-the-artificer

Hey, I'm in class rn so can;t do much. What still needs to be done?

actually-the-artificer avatar Mar 01 '23 23:03 actually-the-artificer

Just wanting to move this along, anything else that needs to be done?

JazzGlobal avatar Apr 29 '23 23:04 JazzGlobal

Looks good to me, and the failures seem to be unrelated. It won't hurt to rebase it and rerun the checks though.

Qrox avatar Apr 30 '23 03:04 Qrox

Looks good to me, and the failures seem to be unrelated. It won't hurt to rebase it and rerun the checks though.

Thanks for the response, didn't want the author to be left hanging any longer 😁

JazzGlobal avatar Apr 30 '23 04:04 JazzGlobal

Yeah, I thought someone would merge it and then completely forgot about it... I also notice that @irwiss 's comment is not addressed though, so the json flags documentation needs to be updated too.

Qrox avatar Apr 30 '23 05:04 Qrox

Crap, sorry about this. University got in the way. Rebasing? Hrm, how do I do that?

actually-the-artificer avatar May 18 '23 01:05 actually-the-artificer

There is no need to rebase currently because @Maleclypse's commits triggered new checks which seem to be failing for unrelated reasons again. In the mean time could you update doc/JSON_FLAGS.md with the new flags?

Qrox avatar May 18 '23 04:05 Qrox

tests/npc_talk_test.cpp:116: FAILED:
(~[slow] ~[.],starting_items)=>   REQUIRE( d.responses.size() == expected_count )
(~[slow] ~[.],starting_items)=> with expansion:
Error: (~[slow] ~[.],starting_items)=>   2 == 4
(~[slow] ~[.],starting_items)=> with message:
(~[slow] ~[.],starting_items)=>   d.responses := { talk_response( text="This is a basic test response." ),
(~[slow] ~[.],starting_items)=>   talk_response( text="This is a wearing test response." ) }

Error result before I kicked the tests

Maleclypse avatar Jun 15 '23 04:06 Maleclypse

@Maleclypse may I ask why is the numb flag reverted?

Qrox avatar Aug 09 '23 03:08 Qrox

@Maleclypse may I ask why is the numb flag reverted?

Clang was saying it was called but never used so I was trying to get this to a minimum viable state. That was probably the wrong path to take but when Clang showed me that NUMB was a problem I thought, I can remove it.
On discord Renech saw a different error.

Renech — Today at 9:15 PM The test error seems to be due to changing the flags on both the psychopath and sapiovore mutations.

So I'm open to anything that gets this into a mergeable state where it's passing basic build. Looking at the test history it's never gotten a basic build passed flag.

Maleclypse avatar Aug 09 '23 03:08 Maleclypse

The clang-tidy error was saying that trait_NUMB (not json_flag_NUMB) was unused, so I think you should remove the definition of trait_NUMB rather than reverting the json_flag_NUMB changes.

Qrox avatar Aug 09 '23 06:08 Qrox

The clang-tidy error was saying that trait_NUMB (not json_flag_NUMB) was unused, so I think you should remove the definition of trait_NUMB rather than reverting the json_flag_NUMB changes.

Oops, thanks! I'll try to work on this today/tonight when I can pull it locally.

Maleclypse avatar Aug 09 '23 13:08 Maleclypse

Hi Qrox, I'm not sure how to fix the error. Do I just change the below

 talker_npc.toggle_trait( trait_SAPIOVORE );
    gen_response_lines( d, 4 );
    CHECK( d.responses[0].text == "This is a basic test response." );
    CHECK( d.responses[1].text == "This is a wearing test response." );
    CHECK( d.responses[2].text == "This is a trait flags test response." );
    CHECK( d.responses[3].text == "This is a npc trait flags test response." );
    player_character.toggle_trait( trait_PSYCHOPATH );
    talker_npc.toggle_trait( trait_SAPIOVORE );

To toggle json_flag_Sapiovore?

It's in TALK_TEST_WEARING_AND_TRAIT

Maleclypse avatar Aug 12 '23 01:08 Maleclypse

I think you should change the following lines to use the new flags of the respective traits:

https://github.com/CleverRaven/Cataclysm-DDA/blob/f2dedcb01f952a9f004e10ef9f0f051821e2a0a5/data/json/npcs/TALK_TEST.json#L97-L106

I.e. change the lines to

      {
        "text": "This is a trait flags test response.",
        "topic": "TALK_DONE",
        "condition": { "u_has_flag": "PSYCHOPATH" }
      },
      {
        "text": "This is a npc trait flags test response.",
        "topic": "TALK_DONE",
        "condition": { "npc_has_flag": "SAPIOVORE" }
      }

Qrox avatar Aug 12 '23 09:08 Qrox