diff options
author | Loek Le Blansch <loek@pipeframe.xyz> | 2024-10-30 14:48:02 +0100 |
---|---|---|
committer | Loek Le Blansch <loek@pipeframe.xyz> | 2024-10-30 14:48:02 +0100 |
commit | 6dfa3fb34fb0a2ea028fd46e77296e26b092fb99 (patch) | |
tree | 51257e54561550c91dbec262fe143d4dbe41f059 /frontend/cmd | |
parent | 862186ae7cbbd922057fa5f6b49509c36f9ade36 (diff) |
use string instead of argument vector for commands
Diffstat (limited to 'frontend/cmd')
-rw-r--r-- | frontend/cmd/cheat.cpp | 4 | ||||
-rw-r--r-- | frontend/cmd/equip.cpp | 4 | ||||
-rw-r--r-- | frontend/cmd/get.cpp | 4 | ||||
-rw-r--r-- | frontend/cmd/go.cpp | 8 | ||||
-rw-r--r-- | frontend/cmd/help.cpp | 4 | ||||
-rw-r--r-- | frontend/cmd/hit.cpp | 4 | ||||
-rw-r--r-- | frontend/cmd/put.cpp | 4 | ||||
-rw-r--r-- | frontend/cmd/query.cpp | 2 | ||||
-rw-r--r-- | frontend/cmd/quit.cpp | 4 | ||||
-rw-r--r-- | frontend/cmd/restart.cpp | 4 | ||||
-rw-r--r-- | frontend/cmd/search.cpp | 4 | ||||
-rw-r--r-- | frontend/cmd/use.cpp | 4 | ||||
-rw-r--r-- | frontend/cmd/view.cpp | 8 | ||||
-rw-r--r-- | frontend/cmd/wait.cpp | 4 |
14 files changed, 44 insertions, 18 deletions
diff --git a/frontend/cmd/cheat.cpp b/frontend/cmd/cheat.cpp index 6f1c163..aeed5f4 100644 --- a/frontend/cmd/cheat.cpp +++ b/frontend/cmd/cheat.cpp @@ -1,7 +1,9 @@ #include "../Player.h" #include "../print.h" -FollowupAction Player::cmd_cheat(Argv argv) { +using namespace std; + +FollowupAction Player::cmd_cheat(string &) { this->cheating = !this->cheating; lprtf("Cheats staan nu %s.\n", this->cheating ? "aan" : "uit"); return FollowupAction::NONE; diff --git a/frontend/cmd/equip.cpp b/frontend/cmd/equip.cpp index bcb261f..79ab8d1 100644 --- a/frontend/cmd/equip.cpp +++ b/frontend/cmd/equip.cpp @@ -1,6 +1,8 @@ #include "../Player.h" -FollowupAction Player::cmd_equip(Argv argv) { +using namespace std; + +FollowupAction Player::cmd_equip(string & argv) { // TODO return FollowupAction::UPDATE; } diff --git a/frontend/cmd/get.cpp b/frontend/cmd/get.cpp index b703a0e..77ad727 100644 --- a/frontend/cmd/get.cpp +++ b/frontend/cmd/get.cpp @@ -1,6 +1,8 @@ #include "../Player.h" -FollowupAction Player::cmd_get(Argv argv) { +using namespace std; + +FollowupAction Player::cmd_get(string & argv) { // TODO return FollowupAction::NONE; } diff --git a/frontend/cmd/go.cpp b/frontend/cmd/go.cpp index cbe8e7c..624bf6c 100644 --- a/frontend/cmd/go.cpp +++ b/frontend/cmd/go.cpp @@ -2,6 +2,7 @@ #include "../Player.h" #include "../print.h" +#include "../strings.h" using namespace std; @@ -12,13 +13,14 @@ static const unordered_map<string, Direction> direction_map = { { "west", Direction::WEST }, }; -FollowupAction Player::cmd_go(Argv argv) { - if (argv.size() == 0 || !direction_map.contains(argv[0])) { +FollowupAction Player::cmd_go(string & argv) { + string direction_str = str_consume_arg(argv); + if (direction_str.size() == 0 || !direction_map.contains(direction_str)) { lprtf("Fout, gebruik: Ga <noord|zuid|oost|west>\n"); return FollowupAction::NONE; } - Direction direction = direction_map.at(argv[0]); + Direction direction = direction_map.at(direction_str); Location * next_location = this->location.get_exit(direction); if (next_location == nullptr) { lprtf("Er is geen uitgang in deze richting!\n"); diff --git a/frontend/cmd/help.cpp b/frontend/cmd/help.cpp index 1ae1fde..e614f28 100644 --- a/frontend/cmd/help.cpp +++ b/frontend/cmd/help.cpp @@ -1,7 +1,9 @@ #include "../print.h" #include "../Player.h" -FollowupAction Player::cmd_help(Argv argv) { +using namespace std; + +FollowupAction Player::cmd_help(string &) { lprtf("De beschikbare commando's zijn: "); bool first = true; for (auto & [ key, _ ] : this->cmds) { diff --git a/frontend/cmd/hit.cpp b/frontend/cmd/hit.cpp index 17f9099..86d596a 100644 --- a/frontend/cmd/hit.cpp +++ b/frontend/cmd/hit.cpp @@ -1,6 +1,8 @@ #include "../Player.h" -FollowupAction Player::cmd_hit(Argv argv) { +using namespace std; + +FollowupAction Player::cmd_hit(string & argv) { // TODO return FollowupAction::UPDATE; } diff --git a/frontend/cmd/put.cpp b/frontend/cmd/put.cpp index 8a6c828..6e7002b 100644 --- a/frontend/cmd/put.cpp +++ b/frontend/cmd/put.cpp @@ -1,6 +1,8 @@ #include "../Player.h" -FollowupAction Player::cmd_put(Argv argv) { +using namespace std; + +FollowupAction Player::cmd_put(string & argv) { // TODO return FollowupAction::NONE; } diff --git a/frontend/cmd/query.cpp b/frontend/cmd/query.cpp index 3a26e9c..e1e45a1 100644 --- a/frontend/cmd/query.cpp +++ b/frontend/cmd/query.cpp @@ -13,7 +13,7 @@ static const unordered_map<Direction, string> direction_map = { { Direction::WEST, "West" }, }; -FollowupAction Player::cmd_query(Argv argv) { +FollowupAction Player::cmd_query(string &) { lprtf("Je staat bij de locatie %s.\n", this->location.get_name()); lprtf("%s\n", this->location.get_description()); diff --git a/frontend/cmd/quit.cpp b/frontend/cmd/quit.cpp index 24aa7c9..8f97562 100644 --- a/frontend/cmd/quit.cpp +++ b/frontend/cmd/quit.cpp @@ -1,6 +1,8 @@ #include "../Player.h" -FollowupAction Player::cmd_quit(Argv argv) { +using namespace std; + +FollowupAction Player::cmd_quit(string &) { return FollowupAction::EXIT; } diff --git a/frontend/cmd/restart.cpp b/frontend/cmd/restart.cpp index aac5833..d9d68e0 100644 --- a/frontend/cmd/restart.cpp +++ b/frontend/cmd/restart.cpp @@ -1,6 +1,8 @@ #include "../Player.h" -FollowupAction Player::cmd_restart(Argv argv) { +using namespace std; + +FollowupAction Player::cmd_restart(string &) { return FollowupAction::RESTART; } diff --git a/frontend/cmd/search.cpp b/frontend/cmd/search.cpp index af22ca2..4646ddc 100644 --- a/frontend/cmd/search.cpp +++ b/frontend/cmd/search.cpp @@ -1,6 +1,8 @@ #include "../Player.h" -FollowupAction Player::cmd_search(Argv argv) { +using namespace std; + +FollowupAction Player::cmd_search(string & argv) { // TODO return FollowupAction::UPDATE; } diff --git a/frontend/cmd/use.cpp b/frontend/cmd/use.cpp index a7955eb..a6e876a 100644 --- a/frontend/cmd/use.cpp +++ b/frontend/cmd/use.cpp @@ -1,6 +1,8 @@ #include "../Player.h" -FollowupAction Player::cmd_use(Argv argv) { +using namespace std; + +FollowupAction Player::cmd_use(string & argv) { // TODO return FollowupAction::NONE; } diff --git a/frontend/cmd/view.cpp b/frontend/cmd/view.cpp index 0636cac..b9d179b 100644 --- a/frontend/cmd/view.cpp +++ b/frontend/cmd/view.cpp @@ -2,13 +2,15 @@ #include "../Player.h" #include "../strings.h" -FollowupAction Player::cmd_view(Argv argv) { - if (argv.size() == 0) { +using namespace std; + +FollowupAction Player::cmd_view(string & target) { + if (target.size() == 0) { lprtf("Fout, gebruik: Bekijk <Zelf|VIJHAND|OBJECT>\n"); return FollowupAction::NONE; } - if (str_lower(argv[0]) == "zelf") { + if (str_lower(target) == "zelf") { lprtf("Je hebt %d levenspunten.\n", this->health_points); lprtf("Je hebt een aanvalskans van %.0f%%.\n", this->get_attack() * 100); // TODO: weapon diff --git a/frontend/cmd/wait.cpp b/frontend/cmd/wait.cpp index d2bc908..49cb7db 100644 --- a/frontend/cmd/wait.cpp +++ b/frontend/cmd/wait.cpp @@ -1,6 +1,8 @@ #include "../Player.h" -FollowupAction Player::cmd_wait(Argv argv) { +using namespace std; + +FollowupAction Player::cmd_wait(string &) { return FollowupAction::NONE; } |