| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | /* | ||
| 2 | ** EPITECH PROJECT, 2024 | ||
| 3 | ** zappy/ai | ||
| 4 | ** File description: | ||
| 5 | ** Debug.cpp | ||
| 6 | */ | ||
| 7 | #include "../bots/ABotPattern.hpp" | ||
| 8 | |||
| 9 | ✗ | void ABot::debugInitialisation() | |
| 10 | { | ||
| 11 | ✗ | printColor("========== [Bot initiation] ==========\n", BLUE); | |
| 12 | ✗ | printKeyValueColored("sockfd", std::to_string(_sockfd)); | |
| 13 | ✗ | printKeyValueColored("teamName", _teamName); | |
| 14 | ✗ | printColor("========== [!Bot initiation] ==========\n\n", BLUE); | |
| 15 | ✗ | } | |
| 16 | |||
| 17 | ✗ | void ABot::debugState() | |
| 18 | { | ||
| 19 | ✗ | printColor("🤖📋 Bot State\n", YELLOW); | |
| 20 | ✗ | printKeyValueColored("food", std::to_string(_state.ressources.food)); | |
| 21 | ✗ | printKeyValueColored("linemate", std::to_string(_state.ressources.linemate)); | |
| 22 | ✗ | printKeyValueColored("deraumere", std::to_string(_state.ressources.deraumere)); | |
| 23 | ✗ | printKeyValueColored("sibur", std::to_string(_state.ressources.sibur)); | |
| 24 | ✗ | printKeyValueColored("mendiane", std::to_string(_state.ressources.mendiane)); | |
| 25 | ✗ | printKeyValueColored("phiras", std::to_string(_state.ressources.phiras)); | |
| 26 | ✗ | printKeyValueColored("thystame", std::to_string(_state.ressources.thystame)); | |
| 27 | ✗ | printKeyValueColored("level", std::to_string(_state.level)); | |
| 28 | ✗ | printKeyValueColored("state", getStateName(_state.state)); | |
| 29 | ✗ | } | |
| 30 | |||
| 31 | ✗ | void ABotPattern::debugResponses(const std::string &responseServer, const std::string &responseBroadcast) | |
| 32 | { | ||
| 33 | PRINT_STATE state = PRINT_STATE_INFO; | ||
| 34 | ✗ | if (responseServer.find("ok") != std::string::npos) | |
| 35 | state = PRINT_STATE_SUCESS; | ||
| 36 | ✗ | else if (responseServer.find("ko") != std::string::npos) | |
| 37 | state = PRINT_STATE_WARNING; | ||
| 38 | ✗ | printColor("🤖👂 Bot listens\n", YELLOW); | |
| 39 | ✗ | printKeyValueColored("\t- server", responseServer, state); | |
| 40 | ✗ | printKeyValueColored("\t- broadcast", responseBroadcast); | |
| 41 | ✗ | } | |
| 42 | |||
| 43 | ✗ | void ABotPattern::debugBotRun() | |
| 44 | { | ||
| 45 | ✗ | printColor("========== [Bot Run] ==========\n", BRIGHT_BLUE); | |
| 46 | ✗ | printKeyValueColored("Iteration", std::to_string(_iteration)); | |
| 47 | ✗ | printKeyValueColored("Pattern:", _state.pattern); | |
| 48 | ✗ | } | |
| 49 | |||
| 50 | ✗ | void ABotPattern::debugMetadata() | |
| 51 | { | ||
| 52 | ✗ | printColor("🤖📂 Bot metadata\n", YELLOW); | |
| 53 | ✗ | _state.printMetadata(); | |
| 54 | std::cout << std::endl; | ||
| 55 | ✗ | } | |
| 56 | |||
| 57 | ✗ | void ABot::debugAction(const ActionInfo actionInfo, const std::string ¶meter) | |
| 58 | { | ||
| 59 | ✗ | ActionInfo actionToServerClean = actionInfo; | |
| 60 | ✗ | std::string finalParameter = parameter; | |
| 61 | |||
| 62 | ✗ | if (actionInfo.action == BROADCAST) | |
| 63 | { | ||
| 64 | ✗ | if (parameter.empty()) | |
| 65 | { | ||
| 66 | ✗ | exit(0); | |
| 67 | } | ||
| 68 | else | ||
| 69 | { | ||
| 70 | ✗ | std::string tmpStr = getElementBefore(parameter, ':'); | |
| 71 | ✗ | Message tmp(tmpStr); | |
| 72 | ✗ | tmp.vigenereDecrypt(); | |
| 73 | finalParameter = tmp.content; | ||
| 74 | ✗ | } | |
| 75 | } | ||
| 76 | ✗ | std::string actionToServer = actionToServerClean.getName(); | |
| 77 | |||
| 78 | ✗ | if (!finalParameter.empty()) | |
| 79 | ✗ | actionToServer += " " + finalParameter; | |
| 80 | ✗ | printKeyValueColored("🤖🤜 Bot does", actionToServer); | |
| 81 | ✗ | } | |
| 82 |