diff options
| author | BossCode45 <human.cyborg42@gmail.com> | 2023-06-05 20:35:32 +1200 |
|---|---|---|
| committer | BossCode45 <human.cyborg42@gmail.com> | 2023-06-05 20:35:32 +1200 |
| commit | 0b539b0b0278f2d7c2b7629e6d28d8463cba2688 (patch) | |
| tree | 3a0b47f09dc58f2c14ba06443f2a5fe88d166e2f /commands.cpp | |
| parent | e9cc5756dbb0a2d079a7b5e3438d79945f819df5 (diff) | |
| download | YATwm-0b539b0b0278f2d7c2b7629e6d28d8463cba2688.tar.gz YATwm-0b539b0b0278f2d7c2b7629e6d28d8463cba2688.zip | |
Added a very basic config, and fixed some stuff
NOTE: for some reason toggling doesn't work anymore
Diffstat (limited to 'commands.cpp')
| -rw-r--r-- | commands.cpp | 52 |
1 files changed, 31 insertions, 21 deletions
diff --git a/commands.cpp b/commands.cpp index c41536d..141de26 100644 --- a/commands.cpp +++ b/commands.cpp @@ -86,10 +86,9 @@ vector<string> CommandsModule::splitCommand(string command) return v; } -template <typename T> -std::basic_string<T> lowercase(const std::basic_string<T>& s) +string lowercase(string s) { - std::basic_string<T> s2 = s; + string s2 = s; std::transform(s2.begin(), s2.end(), s2.begin(), [](unsigned char c){ return std::tolower(c); }); return s2; } @@ -103,30 +102,41 @@ CommandArg* CommandsModule::getCommandArgs(vector<string>& split, const CommandA { case STR: args[i-1].str = (char*)split[i].c_str(); break; case NUM: args[i-1].num = std::stoi(split[i]); break; - case MOVDIR: args[i-1].dir = LEFT; break; + case MOVDIR: + { + if(lowercase(split[i]) == "up") + args[i-1].dir = UP; + else if(lowercase(split[i]) == "down") + args[i-1].dir = DOWN; + else if(lowercase(split[i]) == "left") + args[i-1].dir = LEFT; + else if(lowercase(split[i]) == "right") + args[i-1].dir = RIGHT; + break; + } case STR_REST: - { - string rest = ""; - for(int j = i; j < split.size(); j++) { - rest += split[j]; - if(j != split.size() - 1) - rest += " "; + string rest = ""; + for(int j = i; j < split.size(); j++) + { + rest += split[j]; + if(j != split.size() - 1) + rest += " "; + } + args[i-1].str = new char[rest.size()]; + strcpy(args[i-1].str, rest.c_str()); + return args; } - args[i-1].str = new char[rest.size()]; - strcpy(args[i-1].str, rest.c_str()); - return args; - } case NUM_ARR_REST: - { - int* rest = new int[split.size() - i]; - for(int j = 0; j < split.size() - i; j++) { - rest[j] = std::stoi(split[j + i]); + int* rest = new int[split.size() - i]; + for(int j = 0; j < split.size() - i; j++) + { + rest[j] = std::stoi(split[j + i]); + } + args[i-1].numArr = {rest, (int) split.size() - i}; + return args; } - args[i-1].numArr = {rest, (int) split.size() - i}; - return args; - } default: cout << "UH OH SOMETHING IS VERY WRONG" << endl; } } |
