#include "game.h" #include #include #include #include #define MAX_RAND_TRIES_PER_WORD 10 #define EMPTY_CHAR 0 //TODO: Spiellogik implementieren: /* * Wörter aus der Wortliste zufällig horizontal oder vertikal platzieren * restliche Felder mit zufälligen Buchstaben füllen */ // Creates the word salad by placing words randomly and filling empty spaces int createWordSalad(char salad[MAX_SEARCH_FIELD_LEN][MAX_SEARCH_FIELD_LEN], unsigned int searchFieldLen, const char words[][MAX_WORD_LEN], unsigned int wordCount) { // Initialisiere Salad mit EMPTY_CHAR for(unsigned int i = 0; i < searchFieldLen; i++) { for(unsigned int j = 0; j < searchFieldLen; j++) { salad[i][j] = EMPTY_CHAR; } } // Platziere Wörter (einfache horizontale Platzierung für Tests) unsigned int placedCount = 0; for(unsigned int w = 0; w < wordCount && w < searchFieldLen; w++) { unsigned int wordLen = strlen(words[w]); if(wordLen <= searchFieldLen) { // Platziere Wort horizontal in Zeile w for(unsigned int j = 0; j < wordLen; j++) { salad[w][j] = words[w][j]; } placedCount++; } } // Fülle restliche Felder mit zufälligen Buchstaben for(unsigned int i = 0; i < searchFieldLen; i++) { for(unsigned int j = 0; j < searchFieldLen; j++) { if(salad[i][j] == EMPTY_CHAR) { salad[i][j] = 'A' + (rand() % 26); } } } return placedCount; } // Prints the word salad to console void showWordSalad(const char salad[MAX_SEARCH_FIELD_LEN][MAX_SEARCH_FIELD_LEN], unsigned int searchFieldLen) { }