LCOV - code coverage report
Current view: top level - src - Parser.c (source / functions) Coverage Total Hit
Test: lcov-output.info Lines: 100.0 % 30 30
Test Date: 2025-03-31 18:12:52 Functions: 100.0 % 1 1

            Line data    Source code
       1              : /*
       2              : Created by Daniel Monteiro on 08/10/2019.
       3              : */
       4              : 
       5              : #ifndef DONT_INCLUDE
       6              : #ifdef WIN32
       7              : #include "Win32Int.h"
       8              : #else
       9              : 
      10              : #include <stdint.h>
      11              : 
      12              : #endif
      13              : 
      14              : #include "Enums.h"
      15              : #include "Common.h"
      16              : #include "Core.h"
      17              : #include "Parser.h"
      18              : #include <string.h>
      19              : 
      20              : #endif
      21              : 
      22          105 : uint8_t parseCommand(const char *cmd, const char *operand) {
      23          105 :     if (!strcmp(cmd, "pick")) {
      24           23 :         pickObjectByName(operand);
      25           82 :     } else if (!strcmp(cmd, "drop")) {
      26           11 :         dropObjectByName(operand);
      27           71 :     } else if (!strcmp(cmd, "move")) {
      28              : 
      29           14 :         if (operand != NULL && operand[0] != '\0') {
      30           12 :             moveBy(operand[0] - '0');
      31              :         } else {
      32            2 :             errorHandlerCallback("Please specify a valid direction");
      33              :         }
      34           57 :     } else if (!strcmp(cmd, "use")) {
      35           23 :         useObjectNamed(operand);
      36           34 :     } else if (!strcmp(cmd, "w")) {
      37            4 :         walkBy(0);
      38           30 :     } else if (!strcmp(cmd, "s")) {
      39            5 :         walkBy(2);
      40           25 :     } else if (!strcmp(cmd, "a")) {
      41            5 :         walkBy(3);
      42           20 :     } else if (!strcmp(cmd, "d")) {
      43            5 :         walkBy(1);
      44           15 :     } else if (!strcmp(cmd, "q")) {
      45            4 :         turnLeft();
      46           11 :     } else if (!strcmp(cmd, "e")) {
      47            4 :         turnRight();
      48            7 :     } else if (!strcmp(cmd, "walkTo")) {
      49            4 :         walkTo(operand);
      50              : #ifdef INCLUDE_ITEM_DESCRIPTIONS
      51              :         } else if (!strcmp(cmd, "info")) {
      52              :             infoAboutItemNamed(operand);
      53              : #endif
      54            3 :     } else if (!strcmp(cmd, "use-with")) {
      55            2 :         useObjectsTogether(operand);
      56              :     } else {
      57            1 :         defaultLogger("Unrecognized command");
      58            1 :         return FALSE;
      59              :     }
      60              : 
      61          104 :     return TRUE;
      62              : }
        

Generated by: LCOV version 2.0-1