51 lines
		
	
	
		
			1.3 KiB
		
	
	
	
		
			C
		
	
	
	
	
	
			
		
		
	
	
			51 lines
		
	
	
		
			1.3 KiB
		
	
	
	
		
			C
		
	
	
	
	
	
#include <stdlib.h>
 | 
						|
#include <string.h>
 | 
						|
#include "action.h"
 | 
						|
#include "game.h"
 | 
						|
#include "util.h"
 | 
						|
 | 
						|
void load_action(Game *g, char *line) {
 | 
						|
  Action *action = &g->actions->actions[g->actions->count];
 | 
						|
 | 
						|
  char *line_token_guy;
 | 
						|
  char *line_token = strtok_r(line, "|", &line_token_guy);
 | 
						|
 | 
						|
  char command_buffer[200];
 | 
						|
  strcpy(command_buffer, line_token);
 | 
						|
 | 
						|
  char *command_token_guy;
 | 
						|
  char *command_word = strtok_r(command_buffer, " ", &command_token_guy);
 | 
						|
  while (command_word != NULL) {
 | 
						|
    Word *word = find_word(g->words, command_word);
 | 
						|
    action->words[action->words_count++] = word;
 | 
						|
    command_word = strtok_r(NULL, " ", &command_token_guy);
 | 
						|
  }
 | 
						|
 | 
						|
  line_token = strtok_r(NULL, "|", &line_token_guy);
 | 
						|
 | 
						|
  // predicate bullshit
 | 
						|
  // char *command_predicate_strtok = strtok_r
 | 
						|
 | 
						|
  line_token = strtok_r(NULL, "|", &line_token_guy);
 | 
						|
  action->priority = atoi(line_token);
 | 
						|
 | 
						|
  line_token = strtok_r(NULL, "|", &line_token_guy);
 | 
						|
  action->description = malloc(strlen(line_token) + 1);
 | 
						|
  strcpy(action->description, line_token);
 | 
						|
 | 
						|
  line_token = strtok_r(NULL, "|", &line_token_guy);
 | 
						|
 | 
						|
  // action bullshit
 | 
						|
 | 
						|
  g->actions->count++;
 | 
						|
}
 | 
						|
 | 
						|
#include "data/actions.c"
 | 
						|
void game_load_actions(Game *g) {
 | 
						|
  parse_multiline_string(g, data_actions_txt, &load_action);
 | 
						|
}
 | 
						|
 | 
						|
Action *find_action(Actions *actions, char *command) {
 | 
						|
  return NULL;
 | 
						|
}
 |