[DEV] 2Moons/SmartMoons 3.0 - Next Gen Update (PHP 8.4, Twig Engine & Aerospace Design)

    This site uses cookies. By continuing to browse this site, you are agreeing to our Cookie Policy.

    • 0wum0 wrote:

      Okay, I'll see if I can incorporate the language variables.

      What exactly isn't working for you with the bots? For me, they're building, fighting, sending fleets, forming alliances, and creating new ones.


      I'm using the exact same game files.


      They seem to do something but I can't find any information in the logs
    • What do you see in the bot logs and bot activity?

      You can see what they're doing in the admin panel.

      Admin dashboard at the very bottom and on the bot page.
      SmartMoons – Community Beta
      Modernes 2Moons mit
      KI-Bots, PHP8.3 & 8.4, Twig
      UI/UX-Optik (clean + futuristisch)
      Jetzt testen & mithelfen
      Bitte
      /Bugs/Ideen per SupportTicket posten – ich bin dankbar für jeden Hinweis ❤️
    • I've adjusted and added the language variables.

      If any language variables are still hardcoded in German, please let me know.
      SmartMoons – Community Beta
      Modernes 2Moons mit
      KI-Bots, PHP8.3 & 8.4, Twig
      UI/UX-Optik (clean + futuristisch)
      Jetzt testen & mithelfen
      Bitte
      /Bugs/Ideen per SupportTicket posten – ich bin dankbar für jeden Hinweis ❤️
    • 2Moons Community Edition (2MoonsCE)

      Welcome to the official Telegram channel of 2MoonsCE a modern, open-source Game.
      2MoonsCE Telegram

      And the Group
      2MoonsCE Community Group
      SmartMoons – Community Beta
      Modernes 2Moons mit
      KI-Bots, PHP8.3 & 8.4, Twig
      UI/UX-Optik (clean + futuristisch)
      Jetzt testen & mithelfen
      Bitte
      /Bugs/Ideen per SupportTicket posten – ich bin dankbar für jeden Hinweis ❤️
    • hello, i would recommend removing mysqli dependency from game. As you know, admin pages use mysqli whereas game pages use PDO. In my opinion having 2 kind of different database class is not necessary. Opened same on github as request maybe you consider as future work ( because it wont bring any efficiency to the game ).

      + you need some Code styling rules for future PRs etc. For example, one can consider styling if statements as

      if(){
      #code
      }

      and other can say this is better

      if()
      {
      #code
      }

      and spaces after if() vs if () , these kind of situations all be predescribed in styling rules so project shall have rule set on styling for contrubitions.

      same goes for variable naming. Some part of the code = camelCase, other part PascalCase and some part is snake_case. I would recommend using snake_case for var names and camelCase for functions on overall project. It would make reading a lot more easier. Decision is up to you, but in the long run deciding on such rules would benefit you and your project's contributors a lot.


      + another issue is while game pages using page object to display page , admin and install pages are plain php files. For overall consistency they shall also open as GamePages by Having Abstract + creating an object to display.

      The post was edited 2 times, last by amamoslavida_ ().

    • and another issue

      example from your code AdminStatsService.php

      try {
      $result = $db->selectSingle(
      "SELECT COUNT(*) as cnt FROM %%ALLIANCE%% WHERE ally_universe = :uni AND ally_register_time > :since;",
      [':uni' => $this->universe, ':since' => $since]
      );
      $count = (int)($result['cnt'] ?? 0);
      } catch (\Exception $e) {
      $count = -1; // n/a
      }


      this try / catch is pretty useless because it Shadows a possible error. Game has exceptionHandler, and all exceptions are catched and logged by that handler. ( error.log ) that lies under GeneralFunctions.php.

      If you try catch, and than assign $count you shadow it. When something goes wrong, it wont throw exception, and you will never aware of the real problem.

      same for the usage of ?? operand, if it is null you are filling it with 0, that is not really good idea, if something which is not expecting to be null is becoming null for some reason, it should be log. With the log you can find real reason ( probably db error) and solve it.
    • Thanks a lot for the detailed feedback — these are actually very valuable points.

      I agree that, in the long run, having two different database approaches (PDO in game pages and mysqli in admin parts) is not ideal. From an architectural point of view, moving everything toward a single consistent database layer makes sense. That said, this is probably more of a future refactor step than an immediate priority, since the current focus is still stability, functionality and getting the whole project into a reliable state first.

      I also agree on the styling/topic of contribution rules. A defined code style will definitely be important for future PRs, especially once more contributors get involved. The same applies to naming conventions. Right now the project still contains a mixture from legacy code and newer rewrites, so establishing a clear ruleset for style, formatting and naming would be a good next step.

      Regarding admin/install pages versus game pages: yes, the inconsistency is there. A unified page architecture would absolutely improve maintainability and readability. I see that more as part of a broader structural cleanup phase, but I agree with the general direction.

      About the try/catch example: that is also fair criticism. In cases where exceptions are swallowed and replaced with fallback values, debugging becomes harder and real issues can stay hidden. I will need to review those areas more carefully and separate “safe fallback for UI display” from “silencing actual errors”, because those are not the same thing.

      So overall: good points, and I appreciate you taking the time to write them down. Not everything will be changed immediately, but these are exactly the kinds of things that should be considered as part of the long-term cleanup and standardization of the project.
      SmartMoons – Community Beta
      Modernes 2Moons mit
      KI-Bots, PHP8.3 & 8.4, Twig
      UI/UX-Optik (clean + futuristisch)
      Jetzt testen & mithelfen
      Bitte
      /Bugs/Ideen per SupportTicket posten – ich bin dankbar für jeden Hinweis ❤️
    • 2MoonsCE – Major Refactoring & Full Modernization in Progress

      Hello everyone,

      I wanted to give you a clear update on the current state of the project.

      Over the last days I have been working intensively on restructuring and improving the foundation of 2MoonsCE. Based on feedback from the community and my own long-term goals, I am now starting a full project-wide modernization.

      Special thanks to @amamoslavida_ for the valuable feedback and ideas that helped push this decision forward.

      This is not just small fixes anymore — the goal is to turn 2MoonsCE into a stable, clean and maintainable codebase for the future.

      • Database Layer
        Unification towards a consistent PDO-based structure (removing mixed mysqli/PDO usage step by step)
      • Admin Architecture
        Introduction of a unified page system (AbstractAdminPage) to replace legacy plain PHP admin files
      • Code Quality
        Defined coding style, naming conventions and contribution rules for future PRs
      • Exception Handling
        Removing hidden errors, fixing swallowed exceptions and improving debugging transparency
      • Service Structure
        Separation of page logic, business logic and database access for better maintainability
      • Installer & Legacy Cleanup
        Harmonizing old structures while keeping full compatibility
      • Extensibility
        Preparing the project for future plugins, mods and easier customization
      • Documentation
        Adding architecture docs, migration plans and contributor guidelines



      Important:
      I am currently starting a full repository-wide migration.
      This means I will go through the entire codebase and bring it to a consistent standard as far as safely possible.

      The main focus is:
      • Stability
      • Consistency
      • Maintainability
      • Future extensibility



      This is a larger step, so some areas may be refactored more deeply than before — but everything is done with the goal of keeping the project fully usable.

      If you have feedback, ideas or want to contribute, feel free to share your thoughts.

      Thanks again for the valuable feedback so far — it directly influenced this decision.

      Greetings
      0wum0
      SmartMoons – Community Beta
      Modernes 2Moons mit
      KI-Bots, PHP8.3 & 8.4, Twig
      UI/UX-Optik (clean + futuristisch)
      Jetzt testen & mithelfen
      Bitte
      /Bugs/Ideen per SupportTicket posten – ich bin dankbar für jeden Hinweis ❤️
    • Update:

      Just to clarify — the refactoring and full modernization process is still in progress.

      I am currently working through the codebase step by step to bring everything to a consistent and stable standard. This will take some time, as I want to do it properly without breaking existing functionality.

      So if you notice inconsistencies, mixed structures or partially migrated areas — that is expected during this phase.

      The goal is:
      • Complete consistency across the project
      • Clean and maintainable architecture
      • A stable and reliable base for future development



      I will keep you updated as progress continues.

      Thanks for your patience and support

      — 0wum0
      SmartMoons – Community Beta
      Modernes 2Moons mit
      KI-Bots, PHP8.3 & 8.4, Twig
      UI/UX-Optik (clean + futuristisch)
      Jetzt testen & mithelfen
      Bitte
      /Bugs/Ideen per SupportTicket posten – ich bin dankbar für jeden Hinweis ❤️
    • Join the 2Moons Community Edition (2MoonsCE)

      Be part of the next generation of a classic browser game.

      We are currently rebuilding 2MoonsCE into a modern, stable and future-proof open-source game engine — and you can be part of it.

      Whether you are:
      • ‍ a developer
      • a server owner
      • a player
      • ⚙️ or just curious



      this is the place to connect, share ideas and follow the development live.

      Join our official Telegram channel:
      t.me/dev2MoonsCE

      What you get:
      • Development updates & insights
      • Sneak peeks & new features
      • Community discussions
      • Direct project progress


      Let’s rebuild 2Moons — together.

      2MoonsCE
      SmartMoons – Community Beta
      Modernes 2Moons mit
      KI-Bots, PHP8.3 & 8.4, Twig
      UI/UX-Optik (clean + futuristisch)
      Jetzt testen & mithelfen
      Bitte
      /Bugs/Ideen per SupportTicket posten – ich bin dankbar für jeden Hinweis ❤️
    • thank you very nice decision, I can recommend some basic things which you probably already aware of :

      1- avoid inline html coding such as class = "display-flex justify-content-center align-items-center ... " this makes html not managable. Things like bootstrap causes that, or wrong ideas on styling. In my opinion most styling should be handled only in CSS files.

      2- I would use snake case in general, camel and pascal case make code hard to read, hard to write. When you are writing code trying to write $Prod is harder than $prod, because you are expected to press SHIFT. Even if it is in php i would follow this documentation for variable & function naming. But, this is all my opinion and preferences, you can of course go for camelCase or PascalCase, but one of them shall be picked for overall

      C++ Core guidelines:
      isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines
      for php PascalCase for class names, and camelCase for functions would be nice idea while naming every other thing in snake case. I don't know some documantation values camelCase for php though :).

      3- Avoid overriding Vars. Vars is just a table and it can be managed by admin panel, you can add / remove / modify the components of Vars. Most developers in this forum override that for no reason through the years.

      4- Use Enums instead of magic numbers, magic numbers just bring more confusion, instead of $resource[901] i would go $resource[id::metal]

      5- avoid using $_REQUEST, $_GET, $_POST, you already have HTTP::_GP to validate user input.

      6- Strip mysqli, that is really not needed, DATABASE_BC class.

      7- Refactor report system, most Missions hold data in database as HTML for no reason, they create bulk HTMLs and insert into db as message, which is really ineffective.

      8- Avoid use of global $xyz; or $GLOBALS['xyz'] it is not recommended anymore, 90% of the code depending on the use of global.

      9- refactor mysql table engines ( they were myISAM most of the tables, ) even mysql does not recommend using MyIsam as engine, you should update them into InnoDB. ( session -> Memory is good )

      10- refactor naming mysql tables, some tables are spanish, some in german, some in english. some tables using camelCase, some snake_case, and other in PascalCase, that is just problematic.

      11- most tables inside install.sql are written for MySQL version 7. Therefore, you will encounter depracated declarations such as INT(32) DOUBLE(255,0).

      12- I would strip 'class.' prefixes from php files, that is an old convention used by developers to declare file holding a class and not plain php. It is only good if your folder is holding both plain php files & class files, but in steemnova most classes are inside class folder, so that prefix becomes not needed.

      13- Some pages named in other languages such as ShowVertifyPage - probably french no idea correct should be "verify"

      14- i would prefer pure JS instead of libraries such as JQuery. Ogame uses JS

      15- using serialize, unserialize to store and read data is inconvinient, that should be avoided actually. But for some reason most php developers use those functions and plenty of inside steemnova/2moons.

      In short, most of these are my opinions on the current state of steemnova-2moons, you can of course implement your code styles or change/improve those according to your project's needs. Sadly, achieving all those requires A LOT OF working on project which is probably only cared by 10 people at max. Most people went developing/playing Android mobile games and unfortunately nowadays no one interested in browser games.

      I write this because have tried developing long ago and I did not value these kinds of conventions back in the day. As a result, my project become more and more confusing each day and eventually I stopped working on it :). If you declare some rules on the start, and add everything according to those rules, your project someday become organized and easily manageable.
    • I hope I haven't forgotten any files and that I've switched everything to PDO. That was quite a lot of work, and it's possible I've missed something.

      If you find anything else, please let me know; I'll leave the ticket open.
      SmartMoons – Community Beta
      Modernes 2Moons mit
      KI-Bots, PHP8.3 & 8.4, Twig
      UI/UX-Optik (clean + futuristisch)
      Jetzt testen & mithelfen
      Bitte
      /Bugs/Ideen per SupportTicket posten – ich bin dankbar für jeden Hinweis ❤️
    • Well, it's like an addiction for me right now.

      I just can't stop.


      Maybe I'm also running away from my problems this way.
      Of course, I don't know if this is error-free.
      SmartMoons – Community Beta
      Modernes 2Moons mit
      KI-Bots, PHP8.3 & 8.4, Twig
      UI/UX-Optik (clean + futuristisch)
      Jetzt testen & mithelfen
      Bitte
      /Bugs/Ideen per SupportTicket posten – ich bin dankbar für jeden Hinweis ❤️
    • Hi, I used your project on my subdomain. I tried to implement it and make it more secure. I installed:

      - a customizable anti-cheat
      - an events section
      - a store
      - the ability to insert Google advertising
      - the ability to insert and edit game officials
      - the Italian language added
      - almost all text strings were converted into language variables (I think there are still a few missing)

      I was working on adding a 360-degree view of your planet to the home page (but I'm not good at graphics).

      The site is: gamma.galaxywar.eu (register and I'll make you an admin so you can test it).

      As soon as I can, I'll send you everything so you can integrate whatever you want into your project.
    • I'm so glad you're working with me.

      I could really use more support.

      I'm signing up as a God.


      Best regards
      SmartMoons – Community Beta
      Modernes 2Moons mit
      KI-Bots, PHP8.3 & 8.4, Twig
      UI/UX-Optik (clean + futuristisch)
      Jetzt testen & mithelfen
      Bitte
      /Bugs/Ideen per SupportTicket posten – ich bin dankbar für jeden Hinweis ❤️
    • I tested the bots on your server and they're running.

      I checked if everything was working correctly and they're doing exactly what they're supposed to.


      I noticed that you're not using the latest version.
      SmartMoons – Community Beta
      Modernes 2Moons mit
      KI-Bots, PHP8.3 & 8.4, Twig
      UI/UX-Optik (clean + futuristisch)
      Jetzt testen & mithelfen
      Bitte
      /Bugs/Ideen per SupportTicket posten – ich bin dankbar für jeden Hinweis ❤️
    • 0wum0 wrote:

      I tested the bots on your server and they're running.

      I checked if everything was working correctly and they're doing exactly what they're supposed to.


      I noticed that you're not using the latest version.


      no, I think I started from the second to last one, I'll send you the link to download privately, then you choose and if you want to integrate the features that I created, yes in the end the problem was that I hadn't added the cronjob on the hosting panel