diff --git a/Battleship/Battleship/Drawnings/DrawningBattleship.cs b/Battleship/Battleship/Drawnings/DrawningBattleship.cs
index deb60b5..e6e743c 100644
--- a/Battleship/Battleship/Drawnings/DrawningBattleship.cs
+++ b/Battleship/Battleship/Drawnings/DrawningBattleship.cs
@@ -26,6 +26,7 @@ public class DrawningBattleship : DrawningShip
public override void DrawTransport(Graphics g)
{
+ base.DrawTransport(g);
if (EntityShip == null || EntityShip is not EntityBattleship battleShip || !_startPosX.HasValue || !_startPosY.HasValue)
{
return;
@@ -111,7 +112,7 @@ public class DrawningBattleship : DrawningShip
g.DrawRectangle(pen, x + 119, y + 24, 12, 2);
}
- base.DrawTransport(g);
+
}
}
diff --git a/Battleship/Battleship/Drawnings/DrawningShip.cs b/Battleship/Battleship/Drawnings/DrawningShip.cs
index 0dc210e..7a3aa1b 100644
--- a/Battleship/Battleship/Drawnings/DrawningShip.cs
+++ b/Battleship/Battleship/Drawnings/DrawningShip.cs
@@ -32,7 +32,7 @@ namespace Battleship.Drawnings
/// Ширина прорисовки корабля
///
- private readonly int _drawningShipWidth = 130;
+ private readonly int _drawningShipWidth = 145;
///
/// Высота прорисовки корабля
///
@@ -80,9 +80,13 @@ namespace Battleship.Drawnings
/// true - границы заданы, false - проверка не пройдена, нельзя разместить объект в этих размерах
public bool SetPictureSize(int width, int height)
{
- _pictureWidth = width;
- _pictureHeight = height;
- return true;
+ if (width >= _drawningShipWidth || height >= _drawningShipHeight)
+ {
+ _pictureWidth = width;
+ _pictureHeight = height;
+ return true;
+ }
+ return false;
}
///
/// Установка позиции
@@ -91,10 +95,26 @@ namespace Battleship.Drawnings
/// Координата Y
public void SetPosition(int x, int y)
{
- if (!_pictureHeight.HasValue || !_pictureWidth.HasValue)
+ if (x < 0)
{
- return;
+ x = 0;
}
+ else if (x + _drawningShipWidth > _pictureWidth.Value)
+ {
+ x = _pictureWidth.Value - _drawningShipWidth;
+ }
+
+ if (y < 0)
+ {
+ y = 0;
+ }
+ else if (y + _drawningShipHeight > _pictureHeight.Value)
+ {
+ y = _pictureHeight.Value - _drawningShipHeight;
+ }
+
+
+
_startPosX = x;
_startPosY = y;
}
diff --git a/Battleship/Battleship/Entities/EntityBattleship.cs b/Battleship/Battleship/Entities/EntityBattleship.cs
index 8ed0183..d7f0a08 100644
--- a/Battleship/Battleship/Entities/EntityBattleship.cs
+++ b/Battleship/Battleship/Entities/EntityBattleship.cs
@@ -42,7 +42,7 @@
/// Дополнительный цвет
/// Признак наличия орудийной башни
/// Признак наличия отсека под ракеты
- ///Признак наличия отсека под ракеты
+ ///Признак наличия оружия
public EntityBattleship(int speed, double weight, Color bodyColor, Color additionalColor, bool turret, bool rocketCompartment, bool weapon)
: base(speed, weight, bodyColor)
{