Skip to content

Hw6 game#12

Open
MikePuzanov wants to merge 7 commits intomasterfrom
hw6Game
Open

Hw6 game#12
MikePuzanov wants to merge 7 commits intomasterfrom
hw6Game

Conversation

@MikePuzanov
Copy link
Copy Markdown
Owner

No description provided.

MikePuzanov added 2 commits April 19, 2021 02:05
tests are still waiting
Copy link
Copy Markdown
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 thread hw6Game/hw6Game/Game.cs Outdated
coordinates = map.GetPlayerCoordinates();
switch (step)
{
case "left":
Copy link
Copy Markdown
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.

Comment thread hw6Game/hw6Game.Test/MoveTest.cs Outdated
[SetUp]
public void Setup()
{
eventLoop = new EventLoop();
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

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

Comment thread hw6Game/hw6Game/Map.cs Outdated
public int y;
}

static private string[] mapPic;
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

А почему он static?

Comment thread hw6Game/hw6Game/Map.cs Outdated
{
public class Map
{
private struct PlayerCoordination
Copy link
Copy Markdown
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
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

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

Comment thread hw6Game/hw6Game/Game.cs Outdated

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

Choose a reason for hiding this comment

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

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

Comment thread hw6Game/hw6Game/Map.cs Outdated

private string[] mapPic;

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

Choose a reason for hiding this comment

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

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

Comment thread hw6Game/hw6Game/Map.cs Outdated
return false;
}
player.y -= 1;
return true;
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

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

Copy link
Copy Markdown
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 thread hw6Game/hw6Game/Game.cs
Comment on lines +19 to +22
left,
right,
up,
down
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

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

Comment thread hw6Game/hw6Game/Game.cs
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
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

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

Comment thread hw6Game/hw6Game/Map.cs

private bool CheckMove((int x, int y) coord)
{
if (mapPic[coord.y][coord.x ] != ' ' && mapPic[coord.y][coord.x] != '@')
Copy link
Copy Markdown
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] != '@')

Comment thread hw6Game/hw6Game/Map.cs
return false;
}
player.x = coord.x;
player.y =coord.y;
Copy link
Copy Markdown
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;

Comment thread hw6Game/hw6Game/Map.cs
default:
return false;
}
}
Copy link
Copy Markdown
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