Skip to content

Conversation

@MikePuzanov
Copy link
Owner

No description provided.

MikePuzanov added 2 commits April 19, 2021 02:05
tests are still waiting
Copy link
Collaborator

@yurii-litvinov yurii-litvinov left a comment

Choose a reason for hiding this comment

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

В целом так, но как-то уж очень нетехнично.

coordinates = map.GetPlayerCoordinates();
switch (step)
{
case "left":
Copy link
Collaborator

Choose a reason for hiding this comment

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

Мм. Для этого и придумали enum-ы. Хотя, честно говоря, для этого придумали лямбды, чтобы switch-и тут не писать :) Подумайте, как это написать более красиво


namespace hw6Game
{
public class EventLoop

This comment was marked as resolved.

public event EventHandler<EventArgs> LeftHandler = (sender, args) => { };
public event EventHandler<EventArgs> RightHandler = (sender, args) => { };
public event EventHandler<EventArgs> UpHandler = (sender, args) => { };
public event EventHandler<EventArgs> DownHandler = (sender, args) => { };

This comment was marked as resolved.

[SetUp]
public void Setup()
{
eventLoop = new EventLoop();
Copy link
Collaborator

Choose a reason for hiding this comment

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

Что-то он нигде не используется

public int y;
}

static private string[] mapPic;
Copy link
Collaborator

Choose a reason for hiding this comment

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

А почему он static?

{
public class Map
{
private struct PlayerCoordination
Copy link
Collaborator

Choose a reason for hiding this comment

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

"Координация", не "Координаты"?


public event EventHandler<EventArgs> DownHandler = (sender, args) => { };

public void Run()
Copy link
Collaborator

Choose a reason for hiding this comment

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

Комментарии к методам и даже событиям тоже нужны, но ладно


public void OnLeft(object sender, EventArgs args)
{
Move("left");
Copy link
Collaborator

Choose a reason for hiding this comment

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

Ну да, а если тут или в Move опечататься, то не будет работать, и компилятор не поругается. Варианты решения проблемы:
а) enum-ы,
б) лямбда-функции
Реализуйте что-то из этого :)


private string[] mapPic;

static private PlayerCoordinates player = new PlayerCoordinates();
Copy link
Collaborator

Choose a reason for hiding this comment

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

Просто new(), зачем имя типа дважды писать

return false;
}
player.y -= 1;
return true;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Ну тут точно стоило передавать в Move функцию, которая бы возвращала изменённую координату, чтобы четыре раза одно и то же не писать

Copy link
Collaborator

@yurii-litvinov yurii-litvinov left a comment

Choose a reason for hiding this comment

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

Всё равно неаккуратно. Неаккуратных программистов вся команда ненавидит :)

Comment on lines +19 to +22
left,
right,
up,
down
Copy link
Collaborator

Choose a reason for hiding this comment

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

Элементы enum-а в .NET пишутся с заглавной

Comment on lines +35 to +53
public void OnLeft(object sender, EventArgs args)
{
Move(Moves.left);
}

public void OnRight(object sender, EventArgs args)
{
Move(Moves.right);
}

public void OnDown(object sender, EventArgs args)
{
Move(Moves.down);
}

public void OnUp(object sender, EventArgs args)
{
Move(Moves.up);
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Однострочники пишутся через =>


private bool CheckMove((int x, int y) coord)
{
if (mapPic[coord.y][coord.x ] != ' ' && mapPic[coord.y][coord.x] != '@')
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
if (mapPic[coord.y][coord.x ] != ' ' && mapPic[coord.y][coord.x] != '@')
if (mapPic[coord.y][coord.x] != ' ' && mapPic[coord.y][coord.x] != '@')

return false;
}
player.x = coord.x;
player.y =coord.y;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
player.y =coord.y;
player.y = coord.y;

default:
return false;
}
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

expression switch?

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.

2 participants