Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

It's possible to start the game without placing all the ships #8

Open
Sokom141 opened this issue Nov 7, 2020 · 23 comments · Fixed by #37
Open

It's possible to start the game without placing all the ships #8

Sokom141 opened this issue Nov 7, 2020 · 23 comments · Fixed by #37
Assignees
Labels
bug Something isn't working good first issue Good for newcomers
Milestone

Comments

@Sokom141
Copy link
Owner

Sokom141 commented Nov 7, 2020

This bug is easily reproducible by placing all but one ship and the activating the MouseListener without placing the last one.

The culprit is the cose inside ShipPlanner line 159 :
if (comboBoxItemCount == 1) { buttonOk.setEnabled(true); }

@Sokom141 Sokom141 added bug Something isn't working good first issue Good for newcomers labels Nov 7, 2020
@Sokom141 Sokom141 added this to the 1.0 milestone Nov 7, 2020
@sstanham
Copy link

sstanham commented Nov 7, 2020

This sounds like a very fun project, I would like to help you with your bug and maybe some of your enhancements. Can you assign this to me?

@Sokom141
Copy link
Owner Author

Sokom141 commented Nov 8, 2020

@sstanham Hi!
We are glad you want to contribute to this project.
I'm going to assign you this issue, let me know if you need anything, have fun.

@sstanham
Copy link

sstanham commented Nov 8, 2020

Thank you! I'm going through the code to get it running first. Just to make sure, where do I run the project from? I assume its the Application.java file?

@Sokom141
Copy link
Owner Author

Sokom141 commented Nov 8, 2020

I assume its the Application.java file?

Exactly, that's the entry point of the program.

Currently I'm working on integrating Maven, for an easier and IDE-independent approach, so the project structure will change if everything works correctly.😄

@sstanham
Copy link

sstanham commented Nov 8, 2020

Hi, I'm trying to run the project from the Application.java file and I keep running into this error:

Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException: Cannot invoke "javax.swing.JButton.addActionListener(java.awt.event.ActionListener)" because "this.b_exit" is null at com.battleship.GUI.Window.initUI(Window.java:48) at com.battleship.GUI.Window.<init>(Window.java:36) at java.desktop/java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:316) at java.desktop/java.awt.EventQueue.dispatchEventImpl(EventQueue.java:770) at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:721) at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:715) at java.base/java.security.AccessController.doPrivileged(AccessController.java:391) at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:85) at java.desktop/java.awt.EventQueue.dispatchEvent(EventQueue.java:740) at java.desktop/java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:203) at java.desktop/java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:124) at java.desktop/java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:113) at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:109) at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101) at java.desktop/java.awt.EventDispatchThread.run(EventDispatchThread.java:90)`

Is there a dependency that I may be missing, or something else I'm missing? My IDE is VScode, if that makes a difference.

@Sokom141
Copy link
Owner Author

Sokom141 commented Nov 8, 2020

Yeah, I know about this problem, sorry about that.
I'm currently working on a fix by integrating Maven as I said above.
The culprit is that we used IntelliJ GUI builder for the .form files and it's currently creating binary files instead of Java sources.
As a immediate workaround you can use IntelliJ as your IDE or wait for the fix ( should be fast, at maximum a couple days hopefully)
Let me know

@sstanham
Copy link

sstanham commented Nov 8, 2020

Will do, I'll give IntelliJ a shot and keep you updated. Thank you!

@sstanham
Copy link

sstanham commented Nov 8, 2020

Sorry for the additional questions, but I was wondering if there was a way to playtest a game in IntelliJ. I've gotten the project downloaded and set-up, I just wanted to see how the project currently comes together.

@Sokom141
Copy link
Owner Author

Sokom141 commented Nov 8, 2020

Don't worry!
As of now you should set your source and resources directories by going to:
File > Project Structure > Modules > BattleShip and then marking the right directories
src -> "Sources"
resources -> Resources
Then you should go to "Run/Debug Configurations" ( you can find it in the top right corner just next to the run button) and set
com.battleship.Application as your main-class and setting the JRE at least to the 14 version.

Let me know if this is enough to start the project.
Right now I think my experimental maven set-up it's working so I might push an experimental branch soon.

P.S:
You can even go to the releases and download the latest snapshot.
The jar also requires at least the jdk 14 for now and be aware of some bugs if you trying to play

@Sokom141 Sokom141 changed the title [BUG] It's possible to start the game without placing all the ships It's possible to start the game without placing all the ships Nov 8, 2020
@sstanham
Copy link

sstanham commented Nov 8, 2020

Perfect, got it all up and running now. Thank you for the guide, I was unfamiliar with the IntelliJ environment.

@Sokom141
Copy link
Owner Author

Sokom141 commented Nov 8, 2020

Wonderful!
If you want to check it out I've also pushed the experimental branch with maven.
That should be IDE-independent and should also be more straightforward to import the project and run it right away 😁

@Sokom141
Copy link
Owner Author

Hi @sstanham !
Do you still plan to work on this issue?
We made a lot of changes, so let me know if you need something.

@sstanham
Copy link

Ah yes, sorry for not updating you on my progress, school work has been picking up. I wish to keep on this issue and will work on it as soon as I can. I'll make sure to grab the most recent branch when I get back to work on it.

@Sokom141
Copy link
Owner Author

Sokom141 commented Nov 10, 2020

school work has been picking up.

I feel you 😅

Don't worry and take your time, I was just checking since we got reached by new people.
If you need help hit me up!

@sstanham
Copy link

My plan is to work on this tomorrow, but I have done plenty of investigating and I believe I know how to fix this. I'll keep you posted

@Sokom141
Copy link
Owner Author

Good!
If you've not already I suggest to look into the contributing file (currently on the develop branch), it may clear some common question for you, if you need it, and help you integrate the contributions better.
Good luck and thank you for your interest

@sstanham
Copy link

I found a way to fix the bug, just let me download the most recent version of the code, I'll modify it and send a push with an explanation

@sstanham
Copy link

#34 Just sent the pull request. I wrote the reasoning there. In short, I added an extra check for a click position, to check if it's valid. That way, if you click an invalid place as the last placement, it won't count it. Let me know what you think!

@Sokom141
Copy link
Owner Author

Good, thank you!
I've made a comment on your pull request let me know if everything it's okay

@sstanham
Copy link

Ah perfect, I completely forgot to look for the conventions. I'll conform my changes when I return to my computer and I'll resend the request asap

@Sokom141
Copy link
Owner Author

Thank you for the help!

@sstanham
Copy link

Thank you! Its a very fun project, so I'll take a look at the other bugs in the issue list and see if I can fix those too

@sstanham
Copy link

sstanham commented Nov 14, 2020

I just closed the request and submitted an updated version. Please let me know if I got the formatting right, and thank you for being patient with me!

Edit: Sorry for spamming the pull requests, the last one should be the best one.

@Sokom141 Sokom141 linked a pull request Nov 14, 2020 that will close this issue
Sokom141 pushed a commit that referenced this issue Nov 14, 2020
This push is to fix the error that a player can start the game without placing their last ship. This is done by clicking anywhere a ship cannot be placed. I fixed this by adding a check in line 217, checking if the mouseclick is a valid location, and only recording the action if it is valid.
Closes #8
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working good first issue Good for newcomers
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants