Skip to content

Commit a57a95f

Browse files
authored
Merge pull request #20 from cpp-gamedev/integration
Improve First Release
2 parents 51ed3f0 + bdd47a7 commit a57a95f

File tree

9 files changed

+62
-25
lines changed

9 files changed

+62
-25
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -371,6 +371,9 @@ assets/textures/*.txt
371371
assets/data/*.json
372372
manifest.json
373373

374+
# VS
375+
CMakeSettings.json
376+
374377
# VSCode, clangd etc
375378
.vscode/
376379
.cache/

EasyInstall.ps1

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
Write-Host -ForegroundColor Yellow "+++ PKMN Asset Builder +++"
2+
3+
Write-Host "`nAccording to the National Pok\u00e9mon Index, the first 151 entries served in Generation I."
4+
Write-Host "You may use any of these numbers to create new asset files to play this game.`n"
5+
6+
$ID1 = Read-Host "Pokemon ID #1"
7+
$ID2 = Read-Host "Pokemon ID #2"
8+
9+
if ( -not (Test-Path -Path "venv" -PathType Container) )
10+
{
11+
Write-Host -ForegroundColor Yellow "Creating a new virtual environment . . ."
12+
python -m venv venv/
13+
.\venv\Scripts\Activate.ps1
14+
Write-Host "Installing dependencies . . ."
15+
python -m pip install --upgrade pip
16+
python -m pip install -r requirements.txt --only-binary all
17+
}
18+
else
19+
{
20+
.\venv\Scripts\Activate.ps1
21+
}
22+
23+
python gen_data.py --verbose make --id $ID1 $ID2
24+
python gen_data.py manifest
25+
26+
Write-Host -ForegroundColor Yellow "Done!"
27+
28+
deactivate # virtual environment

README.md

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,20 @@
2121
</a>
2222
</p>
2323

24-
## Build & Debug
24+
## For Users: Playing the Game
25+
26+
Go to [Releases](https://github.com/cpp-gamedev/pkmn/releases) and download the
27+
latest version of `pkmn-x64-linux-windows-v1.0.0-*.zip`. Unzip this directory, then
28+
29+
- run `easy_install.sh` (Linux)
30+
- run `EasyInstall.ps1` (Windows)
31+
32+
to configure the game. This process may take a minute or two depending on your
33+
internet connection. After that, run the `pkmn` binary (`pkmn.exe` on Windows)
34+
to start the game. The game takes up quite a bit of vertical space, so you may
35+
want to adjust the size of your terminal.
36+
37+
## For Developers: Build & Debug the Game
2538

2639
Initialize and update all submodules after you have cloned this repository:
2740

@@ -34,12 +47,6 @@ environments on Linux.
3447

3548
### Generating new Pokemon
3649

37-
---
38-
39-
*Note: You can also use the `./easy_install.sh` script to skip this section.*
40-
41-
---
42-
4350
If this is your first time using a python script, use
4451

4552
```bash

easy_install.sh

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ fi
2525
python3 gen_data.py --verbose make --id $id1 $id2
2626
python3 gen_data.py manifest
2727

28-
echo "Updating submodules . . ."
29-
git submodule update --init --recursive
30-
3128
echo "Done!"
29+
30+
deactivate # virtual environment

src/anim.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ void print_splash_screen(const std::filesystem::path& assets_dir)
4141

4242
std::cout << '\n' << std::setfill(' ') << std::setw(19);
4343

44-
utils::slow_print("copyright (c) 2021 cpp-gamedev", std::chrono::milliseconds{50});
44+
utils::delayed_print("copyright (c) 2021 cpp-gamedev", std::chrono::milliseconds{50});
4545
}
4646

4747
void print_move_table(const models::Pokemon& pkmn)

src/main.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,22 +20,21 @@ int main()
2020

2121
auto pkmns = load_main_menu(manifest);
2222
auto& [player, ai] = pkmns;
23-
clear_screen();
2423

2524
while (player.hp > 0 && ai.hp > 0)
2625
{
26+
clear_screen();
2727
player.make_move(ai, print_frame(player, ai));
2828

2929
if (ai.hp > 0)
3030
{
3131
sleep(1000ms);
3232
ai.make_move(player, random_range<std::size_t>(1, 4));
33-
clear_screen();
3433
}
3534
}
3635

37-
clear_screen();
38-
slow_print((ai.hp == 0) ? "You Won :)" : "You Lost :(", 50ms);
36+
std::cout << '\n';
37+
delayed_print((ai.hp == 0) ? "You Won :)" : "You Lost :(", 50ms);
3938

4039
return EXIT_SUCCESS;
4140
}

src/models.cpp

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ void Pokemon::configure_move_set()
3030
if (move.power > 0 && move.accuracy > 0)
3131
{
3232
move.type = MoveType::ATTACK;
33+
move.accuracy = utils::random_range<int>(this->difficulty == Difficulty::EASY ? 5 : (this->difficulty == Difficulty::MODERATE) ? 6 : 7, 10) * 10;
3334
move.power += this->difficulty == Difficulty::EASY ? -20 : (this->difficulty == Difficulty::MODERATE) ? 0 : 20;
3435
move.power = abs(move.power);
3536
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)
107108
int damage = std::ceil(move.power * (this->atk * 100) / (100 * pkmn.def));
108109
pkmn.hp -= damage;
109110
pkmn.hp = (pkmn.hp < 0) ? 0 : pkmn.hp;
110-
msg = kt::format_str("{} used {} and inflicts {} points in damage!", this->name, move.name, damage);
111+
msg = kt::format_str("{} uses {}! and inflicts {} points in damage!", this->name, move.name, damage);
111112
}
112113
else
113114
{
114-
msg = kt::format_str("{} missed his target!", this->name);
115+
msg = kt::format_str("{} uses {}! The ATTACK missed its target!", this->name, move.name);
115116
}
116117
break;
117118
case MoveType::HEAL:
118119
this->hp += move.power;
119120
this->hp = (this->hp > this->max_hp) ? this->max_hp : this->hp;
120-
msg = kt::format_str("{} increased his HP by {} points", this->name, move.power);
121+
msg = kt::format_str("{} increased its HP by {} points", this->name, move.power);
121122
break;
122123
case MoveType::BOOST_ATK:
123124
this->atk += move.power;
124-
msg = kt::format_str("{} increased his ATTACK by {}%!", this->name, move.power);
125+
msg = kt::format_str("{} increased its ATTACK by {}%!", this->name, move.power);
125126
break;
126127
case MoveType::BOOST_DEF:
127128
this->def += move.power;
128-
msg = kt::format_str("{} increased his DEFENSE by {}%!", this->name, move.power);
129+
msg = kt::format_str("{} increased its DEFENSE by {}%!", this->name, move.power);
129130
break;
130131
default:
131132
break;
132133
}
133134

134-
utils::slow_print(msg, std::chrono::milliseconds{50});
135+
utils::delayed_print(msg, std::chrono::milliseconds{25});
135136
}
136137
} // namespace models

src/utils.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,11 @@ void sleep(std::chrono::milliseconds ms)
1818
std::this_thread::sleep_for(ms);
1919
}
2020

21-
void slow_print(const std::string& str, std::chrono::milliseconds ms)
21+
void delayed_print(std::string_view msg, std::chrono::milliseconds ms)
2222
{
23-
for (char c : str)
23+
for (char c : msg)
2424
{
25-
std::cout << c;
25+
std::cout << c << std::flush;
2626
sleep(ms);
2727
}
2828

src/utils.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ void clear_screen();
7676

7777
void sleep(std::chrono::milliseconds ms);
7878

79-
void slow_print(const std::string& str, std::chrono::milliseconds ms);
79+
void delayed_print(std::string_view msg, std::chrono::milliseconds ms);
8080

8181
enum class Color
8282
{

0 commit comments

Comments
 (0)