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

geat(plugin): implement cloning for GameState & Board #356

Merged
merged 3 commits into from
Jan 15, 2021

Conversation

xeruf
Copy link
Member

@xeruf xeruf commented Jan 15, 2021

No description provided.

Copy link
Contributor

@anarchuser anarchuser left a comment

Choose a reason for hiding this comment

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

Looks good generally.
I've just noted two style questions

plugin/src/shared/sc/plugin2021/Board.kt Outdated Show resolved Hide resolved
&& board == other.board
&& lastMove == other.lastMove
&& lastMoveMono == other.lastMoveMono
&& turn == other.turn)
Copy link
Contributor

Choose a reason for hiding this comment

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

Since Kotlin doesn't have enforced semicolon to mark line endings, in ambigous cases of multi-line statements you need to put the operator at the end of the previous line (which is why || has to be at the end of the line).
Thus I think it's cleaner to put every operator of multi-line statements at the end of the line, rather than the beginning

Copy link
Member Author

Choose a reason for hiding this comment

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

though having the operators aligned improves readability imo 🤔

Copy link
Member Author

Choose a reason for hiding this comment

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

no, the || can also be at the beginning of the line, this isn't really an ambiguous case.

Copy link
Contributor

Choose a reason for hiding this comment

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

oh, really?
I thought it couldn't know the return continues over several lines.
But maybe they just fixed that already

Copy link
Contributor

Choose a reason for hiding this comment

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

If it's possible I wonder why you don't put the || at the beginning of the next line. That should improve readability even more, then

Copy link
Member Author

Choose a reason for hiding this comment

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

because then it would be in front of the parentheses and thus not aligned either.

<field x="8" y="6" content="YELLOW"/>
<field x="5" y="9" content="BLUE"/>
</board>
<lastMoveMono class="linked-hash-map"/>
Copy link
Contributor

Choose a reason for hiding this comment

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

is it fine to just reorder the XML?

Copy link
Contributor

Choose a reason for hiding this comment

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

Depends on how the pupils parse it 😕 I would prefer to not change it mid-season.

Copy link
Contributor

@SKoschnicke SKoschnicke left a comment

Choose a reason for hiding this comment

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

Nice! Is there a good reason to change the XML?

field = 1 + turn / orderedColors.size
return field
}
internal val validColors: MutableSet<Color> =
Copy link
Contributor

Choose a reason for hiding this comment

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

How about a comment explaining what validColors is?

<field x="8" y="6" content="YELLOW"/>
<field x="5" y="9" content="BLUE"/>
</board>
<lastMoveMono class="linked-hash-map"/>
Copy link
Contributor

Choose a reason for hiding this comment

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

Depends on how the pupils parse it 😕 I would prefer to not change it mid-season.

@xeruf
Copy link
Member Author

xeruf commented Jan 15, 2021

It changes depending on the ordering of the fields in the class, which seems much more sensible to me now.
I hope nobody is parsing it by hand and everyone is using a library, thus I thought order would not matter.

@xeruf xeruf changed the title Implement GameState cloning geat(plugin): implement cloning for GameState & Board Jan 15, 2021
@xeruf xeruf merged commit d69385b into master Jan 15, 2021
@xeruf xeruf deleted the feat/gamestate-clone branch January 15, 2021 18:06
xeruf added a commit that referenced this pull request Jan 15, 2021
- implement Gamestate equality correctly
- implement cloning for GameState & Board
- slight GameState XML change due to reorderings
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.

3 participants