GithubHelp home page GithubHelp logo

Comments (2)

tuomount avatar tuomount commented on July 23, 2024 1
MissionHandling.fleetMakeMove(final Game game, final int nx, final int ny,
      final PlayerInfo info, final Fleet fleet)
``` is used only when fleet are moving with FTL routes.

MissionHandling.fleetMakeMove(final Game game, final PathPoint point,
final PlayerInfo info, final Fleet fleet)
``` is used when fleet is moving with standard moves where PathPoints were calculated with A* search. Both of these method then call game.fleetMakeMove() which does the actual fleet moving. Reason why this is in game is that there can be game state change during fleet move for example attack or diplomatic trade and only place where to make game state changes is Game class.

They have different logic since they check a bit different things while moving in FTL and while moving with regular moves. For example FTL movement should not start combat, only when moved with same sector with regular move. Javadocs are horrible, since they are identical. I also think that this part in pathpoint fleetMakeMove is dead code.

 else {
          Message msg = new Message(MessageType.FLEET,
              "Fleet encounter another fleet while moving in FTL!",
              Icons.getIconByName(Icons.ICON_HULL_TECH));
          msg.setCoordinate(fleet.getCoordinate());
          msg.setMatchByString(fleet.getName());
          info.getMsgList().addNewMessage(msg);
        }

from open-realms-of-stars.

BottledByte avatar BottledByte commented on July 23, 2024

Ah, I see, so it is a primarily naming and copied javadoc issue. 👍
One method is technically fleetMoveFTL(), while the other is fleetMoveRegular().

I will rename them, try to extract repeated code, fix Javadoc, remove the presumably dead code and open a PR. Or two, since I did some other smaller refactors in MissionHandling.java already.

Also, as an experiment, I tried to blindly refactor the methods, leaving only the PathPoint code version, added like 2 null checks and mixed in the A* search code... All the tests passed and I have not observed any weird behavior in-game. 😄
Maybe the AI now starts combats in FTL, but as a player, I haven't noticed that 😄

from open-realms-of-stars.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.