game_notifications.c 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. #include "game_notifications.h"
  2. #include <notification/notification.h>
  3. #include <notification/notification_messages.h>
  4. #include "game.h"
  5. const NotificationSequence sequence_earn_point = {
  6. &message_green_255, &message_vibro_on, &message_note_c7, &message_delay_50,
  7. &message_sound_off, &message_vibro_off, &message_green_0, NULL,
  8. };
  9. void
  10. game_notify(GameContext* game_context, const NotificationSequence* sequence)
  11. {
  12. static const NotificationMessage* notification[20];
  13. size_t input_index = 0;
  14. size_t result_index = 0;
  15. for (; (*sequence)[input_index] != NULL; ++input_index) {
  16. const NotificationMessage* item = (*sequence)[input_index];
  17. bool is_sound = item->type == NotificationMessageTypeSoundOn ||
  18. item->type == NotificationMessageTypeSoundOff;
  19. bool is_led = item->type == NotificationMessageTypeLedRed ||
  20. item->type == NotificationMessageTypeLedGreen ||
  21. item->type == NotificationMessageTypeLedBlue;
  22. bool is_vibro = item->type == NotificationMessageTypeVibro;
  23. if ((is_sound && game_context->sound == StateOff) ||
  24. (is_vibro && game_context->vibro == StateOff) ||
  25. (is_led && game_context->led == StateOff)) {
  26. continue;
  27. }
  28. notification[result_index] = item;
  29. ++result_index;
  30. }
  31. notification[result_index] = NULL;
  32. notification_message(game_context->notification,
  33. (const NotificationSequence*)notification);
  34. }