-
Notifications
You must be signed in to change notification settings - Fork 0
Code review #2 #9
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
base: master
Are you sure you want to change the base?
Conversation
…ded some simple genrate methods.
…ning is available now.
Merged network into dev
Merged db into dev
… refactored GameState
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- класс Player связан с моделью только
Model.this.field.getSize(). Это можно передать в конструктор, чтобы убрать зависимость - неиспользуемые импорты
- неиспользуемые декларации
- не-final поля (везде)
- слишком сильная связность. Зачем игроку знать, что он победил (markThatPlayerWin)? Просто чтобы двумя строками ниже проверить
if (!players[index].playerWin)? Это можно превратить в локальную переменную. - слишком много int-ов. int - сам по себе - это число, которое никакого смысла не несёт. Используйте объекты.
- из-за предыдущей проблемы код трудно понимать, а ещё его трудно понимать из-за отсутствия документации, а так же потому что Turn.getId() - это не идентификатор хода, а индекс игрока в массиве игроков (внезапно!)
| borderY = new boolean[fieledSize][fieledSize + 1]; | ||
| public Field(int fieldSize) { | ||
| size = fieldSize; | ||
| field = new State[size][fieldSize]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Или [size][size] или [fieldSize][fieldSize].
| public Field(int fieldSize) { | ||
| size = fieldSize; | ||
| field = new State[size][fieldSize]; | ||
| borderX = new boolean[fieldSize + 1][fieldSize]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Почему +1 ?
| private boolean[][] borderY; | ||
| private int treasureX; | ||
| private int treasureY; | ||
| private int treasureOwner; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
У вас тут int умеет владеть сокровищами.
Это поле должно называться treasureOwnerIndex, а ещё лучше оно должно иметь тип Player.
| private State[][] field; | ||
| private boolean[][] borderX; | ||
| private boolean[][] borderY; | ||
| private int treasureX; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Заведите класс Point.
|
|
||
| private int size; | ||
| private State[][] field; | ||
| private boolean[][] borderX; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Вот это совсем непонятно.
Что означают индексы?
| private int hospitalX; | ||
| private int hospitalY; | ||
| private int exitBorderType; // 0 = X, 1 = Y | ||
| private int exitBorderX; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Point
| private int treasureOwner; | ||
| private int hospitalX; | ||
| private int hospitalY; | ||
| private int exitBorderType; // 0 = X, 1 = Y |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Заведите enum
| } | ||
|
|
||
| public void addBorderY(int row, int column){ | ||
| public void addBorderY(int row, int column) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
addBorder(x,y) = setBorder(x,y,true)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Или уберите этот метод, или выразите один через другой
| public int getPlayerNum() { | ||
| return playerNum; | ||
| } | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
final ?
| import ru.spbau.labyrinth.model.Model.*; | ||
|
|
||
| public class GameState { | ||
| public Model getModel() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Зачем этот метод?
|
Как отличается int[] в getBorderInd от int[] в getPosChange ? Почему до сих пор методы принимают и возвращают int-ы ? |
Часть с сетью ещё будем дописывать, но остальное вроде уже можно просмотреть.