words
This commit is contained in:
parent
cd1f96022c
commit
e39c7dc647
8
.idea/hang-man.iml
generated
8
.idea/hang-man.iml
generated
@ -1,2 +1,8 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<module classpath="CMake" type="CPP_MODULE" version="4" />
|
<module classpath="CMake" type="CPP_MODULE" version="4">
|
||||||
|
<component name="FacetManager">
|
||||||
|
<facet type="Python" name="Python facet">
|
||||||
|
<configuration sdkName="Python 3.11" />
|
||||||
|
</facet>
|
||||||
|
</component>
|
||||||
|
</module>
|
3
.idea/misc.xml
generated
3
.idea/misc.xml
generated
@ -1,4 +1,7 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<project version="4">
|
<project version="4">
|
||||||
|
<component name="Black">
|
||||||
|
<option name="sdkName" value="Python 3.11" />
|
||||||
|
</component>
|
||||||
<component name="CMakeWorkspace" PROJECT_DIR="$PROJECT_DIR$" />
|
<component name="CMakeWorkspace" PROJECT_DIR="$PROJECT_DIR$" />
|
||||||
</project>
|
</project>
|
@ -10,7 +10,13 @@ endif ()
|
|||||||
find_package(SDL2 CONFIG REQUIRED)
|
find_package(SDL2 CONFIG REQUIRED)
|
||||||
find_package(CURL REQUIRED)
|
find_package(CURL REQUIRED)
|
||||||
|
|
||||||
add_executable(hang_man src/main.cpp)
|
add_executable(hang_man src/main.cpp
|
||||||
|
src/Game.cpp
|
||||||
|
src/Game.hpp
|
||||||
|
src/State.hpp
|
||||||
|
src/words.hpp
|
||||||
|
src/words.cpp
|
||||||
|
)
|
||||||
|
|
||||||
target_link_libraries(hang_man PRIVATE
|
target_link_libraries(hang_man PRIVATE
|
||||||
SDL2::SDL2
|
SDL2::SDL2
|
||||||
|
7
src/Game.cpp
Normal file
7
src/Game.cpp
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
#include "Game.hpp"
|
||||||
|
#include "SDL.h"
|
||||||
|
|
||||||
|
void Game::Run() {
|
||||||
|
SDL_
|
||||||
|
|
||||||
|
}
|
10
src/Game.hpp
Normal file
10
src/Game.hpp
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
|
||||||
|
class Game {
|
||||||
|
|
||||||
|
|
||||||
|
public:
|
||||||
|
static void Run();
|
||||||
|
};
|
||||||
|
|
6
src/State.hpp
Normal file
6
src/State.hpp
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
|
||||||
|
enum class State {
|
||||||
|
START, PLAY, GAME_OVER, WIN
|
||||||
|
};
|
443059
src/words.cpp
Normal file
443059
src/words.cpp
Normal file
File diff suppressed because it is too large
Load Diff
3
src/words.hpp
Normal file
3
src/words.hpp
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
const char* words[];
|
38
words.py
Normal file
38
words.py
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
import requests
|
||||||
|
import csv
|
||||||
|
from os import path
|
||||||
|
|
||||||
|
BASE_DIR = path.join(path.dirname(__file__), "src")
|
||||||
|
|
||||||
|
content = (
|
||||||
|
requests.get("https://raw.githubusercontent.com/peterdalle/svensktext/master/lemma/lemmatization.csv")
|
||||||
|
.content
|
||||||
|
.decode('utf-8')
|
||||||
|
.splitlines()
|
||||||
|
)
|
||||||
|
|
||||||
|
table = csv.DictReader(content)
|
||||||
|
|
||||||
|
|
||||||
|
def filter_word(word: str) -> bool:
|
||||||
|
def valid_char(c: str) -> bool:
|
||||||
|
return ord("a") <= ord(c) <= ord("z")
|
||||||
|
pass
|
||||||
|
|
||||||
|
return all(valid_char(c) for c in word)
|
||||||
|
|
||||||
|
|
||||||
|
words = filter(filter_word, map(lambda row: row["word"].lower(), table))
|
||||||
|
|
||||||
|
# write to c++ header and cpp source files
|
||||||
|
with open(path.join(BASE_DIR, "words.hpp"), "w") as file:
|
||||||
|
file.write("#pragma once\n\n")
|
||||||
|
file.write("const char* words[];")
|
||||||
|
|
||||||
|
# Write to C++ source file (optional, if needed)
|
||||||
|
with open(path.join(BASE_DIR, "words.cpp"), "w") as file:
|
||||||
|
file.write('#include "words.hpp"\n\n')
|
||||||
|
file.write("const char* words[] = {\n")
|
||||||
|
for word in words:
|
||||||
|
file.write(f' "{word}",\n')
|
||||||
|
file.write("};\n\n")
|
Loading…
x
Reference in New Issue
Block a user