team.c 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. /*
  2. * This file is part of RuneOptimizer.
  3. *
  4. * RuneOptimizer is free software: you can redistribute it and/or modify it
  5. * under the terms of the GNU General Public License as published by the Free
  6. * Software Foundation, either version 3 of the License, or (at your option)
  7. * any later version.
  8. *
  9. * RuneOptimizer is distributed in the hope that it will be useful, but WITHOUT
  10. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11. * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
  12. * more details.
  13. *
  14. * You should have received a copy of the GNU General Public License along with
  15. * RuneOptimizer. If not, see <https://www.gnu.org/licenses/>.
  16. */
  17. /**
  18. * @file team.c
  19. *
  20. * Implementation of the team command.
  21. *
  22. * This file implements the team command declared in {@link team.h}.
  23. */
  24. #include <stdio.h>
  25. #include <string.h>
  26. #include "../runeoptimizer.h"
  27. #include "../error/error.h"
  28. #include "team.h"
  29. extern int team(int argc, char *argv[]){
  30. if (argc < 1){
  31. fprintf(stderr, "Command team needs an action\n");
  32. return(ERROR_INPUT_TEAM_NO_ACTION);
  33. }
  34. if (strcmp(argv[0], "list") == 0){
  35. return(team_list(argc - 1, argv + 1));
  36. }
  37. else if (strcmp(argv[0], "create") == 0){
  38. return(team_create(argc - 1, argv + 1));
  39. }
  40. else if (strcmp(argv[0], "delete") == 0){
  41. return(team_delete(argc - 1, argv + 1));
  42. }
  43. else if (strcmp(argv[0], "update") == 0){
  44. return(team_edit(argc - 1, argv + 1));
  45. }
  46. else if (strcmp(argv[0], "add_unit") == 0){
  47. return(team_add_unit(argc - 1, argv + 1));
  48. }
  49. else if (strcmp(argv[0], "remove_unit") == 0){
  50. return(team_remove_unit(argc - 1, argv + 1));
  51. }
  52. else{
  53. fprintf(stderr, "Invalid action for team command: %s\n", argv[0]);
  54. return(ERROR_INPUT_TEAM_INVALID_ACTION);
  55. }
  56. }