fork download
  1. #include <iostream>
  2. #include <string>
  3. #include <cstdlib>
  4. #include <ctime>
  5.  
  6. enum SceneState {
  7. STATE_INIT,
  8. STATE_SELECT_SERVER,
  9. STATE_SELECT_CHANNEL,
  10. STATE_LOBBY,
  11. STATE_WAIT_ROOM,
  12. STATE_GAME_PLAY,
  13. STATE_EXIT
  14. };
  15.  
  16. void LogOutput(const std::string& scene, const std::string& msg, const std::string& type = "Normal") {
  17. std::cout << "[" << scene << "] ";
  18. if (type == "Error") std::cout << "❌ [ERROR] ";
  19. else if (type == "Warning") std::cout << "⚠️ [WARN] ";
  20. else if (type == "Packet") std::cout << "🌐 [PACKET] ";
  21. else std::cout << "⚙️ ";
  22.  
  23. std::cout << msg << std::endl;
  24. }
  25.  
  26. struct UserSession {
  27. std::string nick;
  28. int grade;
  29. int userIndex;
  30. };
  31.  
  32. class KeroroGameEngine {
  33. private:
  34. SceneState currentScene;
  35. UserSession session;
  36. bool isRunning;
  37.  
  38. public:
  39. KeroroGameEngine() {
  40. currentScene = STATE_INIT;
  41. isRunning = true;
  42. session.nick = "Liebe";
  43. session.grade = 18;
  44. session.userIndex = 142;
  45. srand(static_cast<unsigned int>(time(NULL)));
  46. }
  47.  
  48. void UpdateEngine() {
  49. if (currentScene == STATE_INIT) {
  50. LogOutput("Init", "Engine Kernel Creation Succeeded....");
  51. LogOutput("Init", "Best BackBuffer Format : X8R8G8B8 (DirectX 9)");
  52. LogOutput("Init", "Sound System Initialized (fmod.dll)");
  53. LogOutput("Init", "can't load file : ( Property/Script/FileLocation_Entity.xml )", "Error");
  54. LogOutput("Init", "Requesting Auth Code...", "Packet");
  55. currentScene = STATE_SELECT_SERVER;
  56. }
  57. else if (currentScene == STATE_SELECT_SERVER) {
  58. LogOutput("Server", "Connecting to Gateway Server...", "Packet");
  59. LogOutput("Server", "ServerNo [1] MaxUser [1400] NowUser [57]");
  60. currentScene = STATE_SELECT_CHANNEL;
  61. }
  62. else if (currentScene == STATE_SELECT_CHANNEL) {
  63. LogOutput("Channel", "cNetGDMS::ChannelInfo() Received", "Packet");
  64. LogOutput("Channel", "Ch [1]: Novice Channel 1 (49 Users) | Ch [2]: Free Channel 1 (1 User)");
  65. std::cout << "[Auth] ⚙️ Login Success! Welcome " << session.nick << " (Grade: " << session.grade << ")" << std::endl;
  66. currentScene = STATE_LOBBY;
  67. }
  68. else if (currentScene == STATE_LOBBY) {
  69. LogOutput("Lobby", "Entering CGameScene_LobbyExtension...");
  70. LogOutput("Lobby", "Still Has no Myuser info", "Warning");
  71. LogOutput("Lobby", "Room [5] 'The Very Last' (Solo Match)", "Packet");
  72. LogOutput("Lobby", "Room [10] 'Let's Fight' (Team Match)", "Packet");
  73. LogOutput("Lobby", "Joining Room 10...");
  74. currentScene = STATE_WAIT_ROOM;
  75. }
  76. else if (currentScene == STATE_WAIT_ROOM) {
  77. LogOutput("WaitRoom", "Joined Room 10.");
  78. std::cout << "[WaitRoom] ⚙️ [Member] " << session.nick << " (Me) - Ready" << std::endl;
  79. LogOutput("WaitRoom", "[Member] Eun-Byul-Chan (Host) - Ready", "Packet");
  80. std::cout << "\n=============================================\n";
  81. std::cout << " 🚀 GAME START - Loading Map... \n";
  82. std::cout << "=============================================\n\n";
  83. currentScene = STATE_GAME_PLAY;
  84. }
  85. else if (currentScene == STATE_GAME_PLAY) {
  86. LogOutput("Game", "Loading Map Resource: [TF_File/My_Room_ball_TF.TF]");
  87. std::string battleActions[4];
  88. battleActions[0] = "Keroro Combo Attack connected successfully!";
  89. battleActions[1] = "Ultimate Skill [Lightning Strike] triggered!";
  90. battleActions[2] = "Enemy's dash attack successfully blocked!";
  91. battleActions[3] = "Weapon item acquired!";
  92. for(int i = 0; i < 3; ++i) {
  93. std::cout << " -> " << battleActions[rand() % 4] << std::endl;
  94. }
  95. std::cout << "\n---------------------------------------------\n";
  96. LogOutput("Game", "CGameScene_GamePlay::End - destroyUI");
  97. LogOutput("Game", "GameManager : remove complete cached Scene");
  98. currentScene = STATE_EXIT;
  99. }
  100. else if (currentScene == STATE_EXIT) {
  101. isRunning = false;
  102. }
  103. }
  104.  
  105. void Run() {
  106. std::cout << "=== ONLINE C++ KERORO FIGHTER SIMULATOR ===\n\n";
  107. while (isRunning) {
  108. UpdateEngine();
  109. }
  110. std::cout << "\n=============================================\n";
  111. std::cout << " Client terminated normally. (SUCCESS) \n";
  112. std::cout << "=============================================\n";
  113. }
  114. };
  115.  
  116. int main() {
  117. KeroroGameEngine engine;
  118. engine.Run();
  119. return 0;
  120. }
Success #stdin #stdout 0s 5316KB
stdin
Standard input is empty
stdout
=== ONLINE C++ KERORO FIGHTER SIMULATOR ===

[Init] ⚙️ Engine Kernel Creation Succeeded....
[Init] ⚙️ Best BackBuffer Format : X8R8G8B8 (DirectX 9)
[Init] ⚙️ Sound System Initialized (fmod.dll)
[Init] ❌ [ERROR] can't load file : ( Property/Script/FileLocation_Entity.xml )
[Init] 🌐 [PACKET] Requesting Auth Code...
[Server] 🌐 [PACKET] Connecting to Gateway Server...
[Server] ⚙️ ServerNo [1] MaxUser [1400] NowUser [57]
[Channel] 🌐 [PACKET] cNetGDMS::ChannelInfo() Received
[Channel] ⚙️ Ch [1]: Novice Channel 1 (49 Users) | Ch [2]: Free Channel 1 (1 User)
[Auth] ⚙️ Login Success! Welcome Liebe (Grade: 18)
[Lobby] ⚙️ Entering CGameScene_LobbyExtension...
[Lobby] ⚠️ [WARN] Still Has no Myuser info
[Lobby] 🌐 [PACKET] Room [5] 'The Very Last' (Solo Match)
[Lobby] 🌐 [PACKET] Room [10] 'Let's Fight' (Team Match)
[Lobby] ⚙️ Joining Room 10...
[WaitRoom] ⚙️ Joined Room 10.
[WaitRoom] ⚙️ [Member] Liebe (Me) - Ready
[WaitRoom] 🌐 [PACKET] [Member] Eun-Byul-Chan (Host) - Ready

=============================================
      🚀 GAME START - Loading Map...         
=============================================

[Game] ⚙️ Loading Map Resource: [TF_File/My_Room_ball_TF.TF]
 -> Keroro Combo Attack connected successfully!
 -> Keroro Combo Attack connected successfully!
 -> Weapon item acquired!

---------------------------------------------
[Game] ⚙️ CGameScene_GamePlay::End - destroyUI
[Game] ⚙️ GameManager : remove complete cached Scene

=============================================
  Client terminated normally. (SUCCESS)       
=============================================