-
Notifications
You must be signed in to change notification settings - Fork 1
ha5 #4
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?
ha5 #4
Conversation
yurii-litvinov
left a comment
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.
С функциональностью всё идеально, надо только код привести в порядок:
- Надо комментарии
- Надо юнит-тесты на всё, что в принципе можно оттестировать (вывод картинок и ввод с клавиатуры не надо, но там перемещение персонажей, генерацию карты и т.д., особенно всякие алгоритмически нетривиальные вещи типа поиска пути и областей видимости)
- Надо логирование основных действий
- Надо ещё поправить замечания по коду. Разделение на модель и представление можно не делать, это всё переписывать, но порефакторить иерархии наследования и в целом навести порядок всё-таки надо.
| import screens.Cell; | ||
| import start.MainFrame; | ||
|
|
||
| public class Amunation { |
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.
Надо ещё комментарии, как обычно
| @@ -0,0 +1,66 @@ | |||
| package characters; | |||
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 class Amunation { | ||
| private Cell[] cells = new Cell[3]; | ||
| private Item armore = null; | ||
| private Item weapon = null; |
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.
Это ж Java, они и так null
| } | ||
|
|
||
| public int getSumDamage() { | ||
| int armoreDmg = armore == null ? 0 : armore.getDamage(); |
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.
Кстати, почему armore? Оно ж "armor"
| Item old = null; | ||
| switch (item.type()) { | ||
| case WEAPON: | ||
| cells[0].setItem(item); |
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.
Это тогда лучше делать не массивом, а отдельным классом, типа слотов снаряжения. Чтобы было сразу понятно в коде, какой шмот куда одевается.
task5/src/main/java/items/Item.java
Outdated
| } | ||
|
|
||
| public static Item generateWeapon(int level) { | ||
| Random rand = new Random(); |
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.
Random инициализируется системным временем (по крайней мере под виндой, под линуксом он может использовать /dev/random, но вроде как тоже не обязан), так что если насоздавать пачку рандомов в одну миллисекунду, они все будут возвращать одно и то же. Кроме того, чем чаще рандомом пользуются, тем более рандомными становятся значения, так что лучше вообще иметь один рандом на всё приложение и передавать его везде, где он нужен.
| private int itemCount = 0; | ||
| private final int size = 15; | ||
| private ImageIcon background = new ImageIcon("sprites/inventory.png"); | ||
| private Amunation amunation = new Amunation(); |
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.
Ammunition? :)
| return amunation; | ||
| } | ||
|
|
||
| public boolean isFool() { |
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 class StartScreen extends JPanel implements Screen { | ||
|
|
||
| JLabel jlabel = new JLabel(); |
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.
Зачем ему пакетная видимость?
| import screens.Screen; | ||
| import screens.StartScreen; | ||
| import sun.audio.AudioPlayer; | ||
| import sun.audio.AudioStream; |
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.
У меня нету такого. И вообще, мне кажется, он умер: https://stackoverflow.com/questions/22031701/sun-audio-player-and-sound-i-o
| import spbau2018.se.screens.AmunationCells; | ||
| import spbau2018.se.start.MainFrame; | ||
|
|
||
| public class Ammunation { |
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.
Комментарии-то так и не появились
| import spbau2018.se.start.MainFrame; | ||
|
|
||
| public class Ammunation { | ||
| AmunationCells cells = new AmunationCells(); |
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.
package-поле, нельзя
No description provided.