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

disable join if spec disabled #2605

Merged
merged 1 commit into from
Apr 20, 2017
Merged

disable join if spec disabled #2605

merged 1 commit into from
Apr 20, 2017

Conversation

ZeldaZach
Copy link
Member

Related Ticket(s)

Short roundup of the initial problem

Join button should be disabled if the game doesn't allow spectators. This does so.

Screenshots

screenshot 2017-04-19 23 31 47

@ZeldaZach ZeldaZach requested a review from Daenyth April 20, 2017 03:32
@ZeldaZach ZeldaZach merged commit e2e9c5a into Cockatrice:master Apr 20, 2017
@ZeldaZach ZeldaZach deleted the fix_2599 branch April 20, 2017 07:01
@@ -23,6 +23,7 @@ private slots:
void actCreate();
void actJoin();
void checkResponse(const Response &response);
void updateButtonChoices(const QModelIndex &);
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why aren't you following the actXxxx naming conventions?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Didn't realize there was a convention

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you change it?

Copy link
Member Author

@ZeldaZach ZeldaZach Apr 20, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you wanna make a Pr to fix all the style changes you outlined here, feel free to and I'll approve it

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you able to do it? its your PR

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I feel this was merged too soon. One of the reviewers @Daenyth hasnt replied yet.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ctrlaltca There is nothing in the contributing.md about peer review processes.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, i don't get what you mean. I just said that right now there is no code convention defined about naming actions actXXX, but that as you suggested we should try to start using it and formalize it in the CONTRIBUTING.md file, that contains code best practices.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there any documentation on peer review processes?

Copy link
Contributor

@ctrlaltca ctrlaltca Apr 20, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nope; afaik github actually has no way to force a review by external peers.
It typically boils down to the peer leaving a 👍 on the PR or commenting it.

return;

const ServerInfo_Game &game = gameListModel->getGame(index.data(Qt::UserRole).toInt());
bool overrideRestrictions = !tabSupervisor->getAdminLocked();
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this check being performed?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Admins/Mods have full authority on a server

Copy link

@ghost ghost Apr 20, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you want to check for permissions, isnt it better to do it through the ServerInfo_User: ServerInfo_User *getUserInfo() const { return userInfo; } from TabSupervisor, rather than checking if a tab is locked?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The "supervisor" tab has a button that locks/unlocks admin superpowers.
The line is making the admin able to override the no-spectators-allowed constraint only when the superpowers are unlocked.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, so you need to click a button to enable a superuser permission.
This line also assigns an inverse result. It returns the getAdminLocked() and then ! it. This doesnt feel right. The ! should be placed in the check.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Imho having a variable named overrideRestrictions helps understanding what is actually checked in the if(), while just putting !tabSupervisor->getAdminLocked() would make it more obscure, as you originally noticed by not getting why the check was performed.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

bool adminLocked = tabSupervisor->getAdminLocked()
Return if the admin is locked.
if (!adminLocked)
If admin is not locked, then proceed.
You dont need a custom overrideRestrictions name when the original variable says all it needs to.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It was just imho, but if you know to have the truth, probably you are right.

const ServerInfo_Game &game = gameListModel->getGame(index.data(Qt::UserRole).toInt());
bool overrideRestrictions = !tabSupervisor->getAdminLocked();

if (game.spectators_allowed() || overrideRestrictions)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Simplify to spectateButton->setEnabled(game.spectators_allowed() || overrideRestrictions)?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

True, might change it to this at some point in the future

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@tooomm
Copy link
Member

tooomm commented Apr 20, 2017

Another thing... why don't we do the same with Join for full games?

@ZeldaZach
Copy link
Member Author

@tooomm Not a bad idea. can you open a ticket and i'll look into that later?

@ghost
Copy link

ghost commented Apr 20, 2017

@ZeldaZach are you able to make a new PR addressing the feedback in this PR?

@ZeldaZach
Copy link
Member Author

I can, yes, but it's not too high on my priority list right now as I have other tickets I'd rather address. If you'd like to make a PR I'd be more then glad to review it and merge it in

@ghost ghost mentioned this pull request Apr 20, 2017
@tooomm
Copy link
Member

tooomm commented Apr 20, 2017

@ZeldaZach will do later, yes. Leaving home now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants