diff --git a/.gitignore b/.gitignore index cdeca7a..0816680 100644 --- a/.gitignore +++ b/.gitignore @@ -371,6 +371,9 @@ assets/textures/*.txt assets/data/*.json manifest.json +# VS +CMakeSettings.json + # VSCode, clangd etc .vscode/ .cache/ diff --git a/EasyInstall.ps1 b/EasyInstall.ps1 new file mode 100644 index 0000000..5ab8e97 --- /dev/null +++ b/EasyInstall.ps1 @@ -0,0 +1,28 @@ +Write-Host -ForegroundColor Yellow "+++ PKMN Asset Builder +++" + +Write-Host "`nAccording to the National Pok\u00e9mon Index, the first 151 entries served in Generation I." +Write-Host "You may use any of these numbers to create new asset files to play this game.`n" + +$ID1 = Read-Host "Pokemon ID #1" +$ID2 = Read-Host "Pokemon ID #2" + +if ( -not (Test-Path -Path "venv" -PathType Container) ) +{ + Write-Host -ForegroundColor Yellow "Creating a new virtual environment . . ." + python -m venv venv/ + .\venv\Scripts\Activate.ps1 + Write-Host "Installing dependencies . . ." + python -m pip install --upgrade pip + python -m pip install -r requirements.txt --only-binary all +} +else +{ + .\venv\Scripts\Activate.ps1 +} + +python gen_data.py --verbose make --id $ID1 $ID2 +python gen_data.py manifest + +Write-Host -ForegroundColor Yellow "Done!" + +deactivate # virtual environment \ No newline at end of file diff --git a/README.md b/README.md index e5b79d8..5d331e1 100644 --- a/README.md +++ b/README.md @@ -21,7 +21,20 @@

-## Build & Debug +## For Users: Playing the Game + +Go to [Releases](https://github.com/cpp-gamedev/pkmn/releases) and download the +latest version of `pkmn-x64-linux-windows-v1.0.0-*.zip`. Unzip this directory, then + +- run `easy_install.sh` (Linux) +- run `EasyInstall.ps1` (Windows) + +to configure the game. This process may take a minute or two depending on your +internet connection. After that, run the `pkmn` binary (`pkmn.exe` on Windows) +to start the game. The game takes up quite a bit of vertical space, so you may +want to adjust the size of your terminal. + +## For Developers: Build & Debug the Game Initialize and update all submodules after you have cloned this repository: @@ -34,12 +47,6 @@ environments on Linux. ### Generating new Pokemon ---- - -*Note: You can also use the `./easy_install.sh` script to skip this section.* - ---- - If this is your first time using a python script, use ```bash diff --git a/easy_install.sh b/easy_install.sh index 3f6e25b..c6d92aa 100644 --- a/easy_install.sh +++ b/easy_install.sh @@ -25,7 +25,6 @@ fi python3 gen_data.py --verbose make --id $id1 $id2 python3 gen_data.py manifest -echo "Updating submodules . . ." -git submodule update --init --recursive - echo "Done!" + +deactivate # virtual environment diff --git a/src/anim.cpp b/src/anim.cpp index c642bc2..fc931d1 100644 --- a/src/anim.cpp +++ b/src/anim.cpp @@ -41,7 +41,7 @@ void print_splash_screen(const std::filesystem::path& assets_dir) std::cout << '\n' << std::setfill(' ') << std::setw(19); - utils::slow_print("copyright (c) 2021 cpp-gamedev", std::chrono::milliseconds{50}); + utils::delayed_print("copyright (c) 2021 cpp-gamedev", std::chrono::milliseconds{50}); } void print_move_table(const models::Pokemon& pkmn) diff --git a/src/main.cpp b/src/main.cpp index 43eb677..e253387 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -20,22 +20,21 @@ int main() auto pkmns = load_main_menu(manifest); auto& [player, ai] = pkmns; - clear_screen(); while (player.hp > 0 && ai.hp > 0) { + clear_screen(); player.make_move(ai, print_frame(player, ai)); if (ai.hp > 0) { sleep(1000ms); ai.make_move(player, random_range(1, 4)); - clear_screen(); } } - clear_screen(); - slow_print((ai.hp == 0) ? "You Won :)" : "You Lost :(", 50ms); + std::cout << '\n'; + delayed_print((ai.hp == 0) ? "You Won :)" : "You Lost :(", 50ms); return EXIT_SUCCESS; } diff --git a/src/models.cpp b/src/models.cpp index 17b3fe0..60606cc 100644 --- a/src/models.cpp +++ b/src/models.cpp @@ -30,6 +30,7 @@ void Pokemon::configure_move_set() if (move.power > 0 && move.accuracy > 0) { move.type = MoveType::ATTACK; + move.accuracy = utils::random_range(this->difficulty == Difficulty::EASY ? 5 : (this->difficulty == Difficulty::MODERATE) ? 6 : 7, 10) * 10; move.power += this->difficulty == Difficulty::EASY ? -20 : (this->difficulty == Difficulty::MODERATE) ? 0 : 20; move.power = abs(move.power); move.flavor_text = kt::format_str("{} deals {} points in damage.", move.name, move.power); @@ -107,30 +108,30 @@ void Pokemon::make_move(Pokemon& pkmn, std::size_t index) int damage = std::ceil(move.power * (this->atk * 100) / (100 * pkmn.def)); pkmn.hp -= damage; pkmn.hp = (pkmn.hp < 0) ? 0 : pkmn.hp; - msg = kt::format_str("{} used {} and inflicts {} points in damage!", this->name, move.name, damage); + msg = kt::format_str("{} uses {}! and inflicts {} points in damage!", this->name, move.name, damage); } else { - msg = kt::format_str("{} missed his target!", this->name); + msg = kt::format_str("{} uses {}! The ATTACK missed its target!", this->name, move.name); } break; case MoveType::HEAL: this->hp += move.power; this->hp = (this->hp > this->max_hp) ? this->max_hp : this->hp; - msg = kt::format_str("{} increased his HP by {} points", this->name, move.power); + msg = kt::format_str("{} increased its HP by {} points", this->name, move.power); break; case MoveType::BOOST_ATK: this->atk += move.power; - msg = kt::format_str("{} increased his ATTACK by {}%!", this->name, move.power); + msg = kt::format_str("{} increased its ATTACK by {}%!", this->name, move.power); break; case MoveType::BOOST_DEF: this->def += move.power; - msg = kt::format_str("{} increased his DEFENSE by {}%!", this->name, move.power); + msg = kt::format_str("{} increased its DEFENSE by {}%!", this->name, move.power); break; default: break; } - utils::slow_print(msg, std::chrono::milliseconds{50}); + utils::delayed_print(msg, std::chrono::milliseconds{25}); } } // namespace models diff --git a/src/utils.cpp b/src/utils.cpp index 7185630..f0c5b54 100644 --- a/src/utils.cpp +++ b/src/utils.cpp @@ -18,11 +18,11 @@ void sleep(std::chrono::milliseconds ms) std::this_thread::sleep_for(ms); } -void slow_print(const std::string& str, std::chrono::milliseconds ms) +void delayed_print(std::string_view msg, std::chrono::milliseconds ms) { - for (char c : str) + for (char c : msg) { - std::cout << c; + std::cout << c << std::flush; sleep(ms); } diff --git a/src/utils.hpp b/src/utils.hpp index d31bd85..b68098a 100644 --- a/src/utils.hpp +++ b/src/utils.hpp @@ -76,7 +76,7 @@ void clear_screen(); void sleep(std::chrono::milliseconds ms); -void slow_print(const std::string& str, std::chrono::milliseconds ms); +void delayed_print(std::string_view msg, std::chrono::milliseconds ms); enum class Color {