From 34713af22308aec6467c731add7eb8fe6019a893 Mon Sep 17 00:00:00 2001 From: Michele Michetti Date: Tue, 18 Jun 2024 23:25:41 +0200 Subject: [PATCH] Defined bitmask, populated functions, added bit manipulation in utils --- game/include/Interaction.hpp | 9 +++++- game/include/utils.hpp | 54 +++++++++++++++++++++++++++++++++++- game/src/Interaction.cpp | 46 ++++++++++++++++++++++++++---- 3 files changed, 102 insertions(+), 7 deletions(-) diff --git a/game/include/Interaction.hpp b/game/include/Interaction.hpp index 80d2745..815f53c 100644 --- a/game/include/Interaction.hpp +++ b/game/include/Interaction.hpp @@ -24,11 +24,18 @@ class Interaction { uint8_t getType(); uint8_t getStatus(); + //Interaction status reading bool isInteraction(); - void playInteraction(); bool isInteractionEnded(); + + //Interaction status manipulation void enableInteraction(); void disableInteraction(); + void playInteraction(); + void endInteraction(); + void increaseInteractionCounter(); + + void callFromFile(); }; } // namespace _interaction \ No newline at end of file diff --git a/game/include/utils.hpp b/game/include/utils.hpp index c0698b0..714c7e4 100644 --- a/game/include/utils.hpp +++ b/game/include/utils.hpp @@ -1,5 +1,5 @@ #pragma once - +#include #include namespace utils { @@ -25,4 +25,56 @@ enum InteractionType : uint8_t { trigger = 0b01000000, trainer = 0b10000000 }; + +enum InteractionStatus : uint8_t { + ENABLED = 0b00000001, + INTERACTION_NEVER_HAPPENED = 0b00000010, + IS_PLAYING = 0b00000100, + INTERACTION_ENDED = 0b00001000, + PLAYED_BIT1 = 0b00010000, + PLAYED_BIT2 = 0b00100000, + PLAYED_BIT3 = 0b01000000, + PLAYED_BIT4 = 0b10000000 + +}; + +//read n-th bit +template +bool readBit(T field, T n) { + return field & ((T)1<(status_bit_mask_,bit_pos); + } + counter = utils::incrementByOne(counter); + //TODO: copy counter to bitmask +} \ No newline at end of file