From 207cd0af2c5dfd4ea868eb5bde4bab212e5e847e Mon Sep 17 00:00:00 2001
From: Floris <f.k.h.vandezande@students.uu.nl>
Date: Thu, 5 Dec 2024 13:09:03 +0100
Subject: [PATCH] skyscraper update

---
 PuzzlePlayer/PuzzleForm.cs   | 11 ++---
 PuzzlePlayer/PuzzlePlayer.cs |  2 +-
 PuzzlePlayer/Skyscrapers.cs  | 90 ++++++++++++++++++++++++++++++++++++
 3 files changed, 94 insertions(+), 9 deletions(-)
 create mode 100644 PuzzlePlayer/Skyscrapers.cs

diff --git a/PuzzlePlayer/PuzzleForm.cs b/PuzzlePlayer/PuzzleForm.cs
index 5ab038f..8cd61d3 100644
--- a/PuzzlePlayer/PuzzleForm.cs
+++ b/PuzzlePlayer/PuzzleForm.cs
@@ -12,17 +12,16 @@ namespace PuzzlePlayer_Namespace
 {
     internal class PuzzleForm : Form
     {
-        public readonly string puzzleType;
         private readonly Button solvebutton;
         private readonly Button hintbutton;
         private readonly Button generatebutton;
         private readonly Button restartbutton;
+        private readonly Button UPDATEBUTTON;
         private readonly Label titlebox;
         private readonly Label informationbox;
         private Rectangle boardspace;
         private readonly MenuStrip menuStrip;
         private readonly ToolStripMenuItem menuSettings;
-
         private readonly BufferedGraphics bufferedGraphics;
         private Board board;
         public Board Board //updating the Board member will immediately call board.Draw method so that the board is updated visually
@@ -34,9 +33,7 @@ namespace PuzzlePlayer_Namespace
                 this.Invalidate();
             }
         }
-
-        private readonly Button UPDATEBUTTON;
-
+        public readonly string puzzleType;
 
         public PuzzleForm(Board b, Size s = default) //takes Board and Size parameter and sets up the PuzzleForm window.
         {
@@ -99,7 +96,6 @@ namespace PuzzlePlayer_Namespace
                 TextAlign = ContentAlignment.BottomRight,
                 Font = SettingForm.mainFont,
             };
-
             menuStrip.Items.Add(menuSettings);
             this.Controls.Add(menuStrip);
             void CreateButton(Button b)
@@ -177,7 +173,6 @@ namespace PuzzlePlayer_Namespace
             solvebutton.Location = new Point(boardspace.Right + 30, 190);
             restartbutton.Location = new Point(boardspace.Right + 30, 270);
             UPDATEBUTTON.Location = new Point(boardspace.Right + 30, 350);
-            informationbox.Text = Convert.ToString(boardspace.Size);
             this.Invalidate();
         }
         public static Size FitBoard(Size gamesize, Size maxboardsize, int drawfactor) //returns the largest rectangle smaller than MaxBoardSize that fits the given GameSize well
@@ -219,7 +214,7 @@ namespace PuzzlePlayer_Namespace
                     return;
             }
             Point tile = GetTile(new Size(Board.boardState.GetLength(0), Board.boardState.GetLength(1)), boardspace, Control.MousePosition);
-            if (!(tile.X >= 0 && tile.X < Board.boardState.GetLength(0) && tile.Y >= 0 && tile.Y < Board.boardState.GetLength(1))) return; //if tile is in bounds
+            if (!(tile.X >= 0 && tile.X < Board.boardState.GetLength(0) && tile.Y >= 0 && tile.Y < Board.boardState.GetLength(1))) return; //if tile is out of bounds
             if (!(Board.lastGeneratedBoard[tile.X, tile.Y] == Board.emptySpace)) return; //if tile is a given
             switch (k)
             {
diff --git a/PuzzlePlayer/PuzzlePlayer.cs b/PuzzlePlayer/PuzzlePlayer.cs
index a1a65a3..ac27d0e 100644
--- a/PuzzlePlayer/PuzzlePlayer.cs
+++ b/PuzzlePlayer/PuzzlePlayer.cs
@@ -10,7 +10,7 @@ namespace PuzzlePlayer_Namespace
     {
         internal static void Main(string[] args)
         {
-            Application.Run(new MainForm()); //nnew PuzzleForm(new Maze())
+            Application.Run(new PuzzleForm(new Skyscrapers()));
         }
     }
 
diff --git a/PuzzlePlayer/Skyscrapers.cs b/PuzzlePlayer/Skyscrapers.cs
new file mode 100644
index 0000000..fe9c7ec
--- /dev/null
+++ b/PuzzlePlayer/Skyscrapers.cs
@@ -0,0 +1,90 @@
+using System;
+using System.Collections.Generic;
+using System.Drawing;
+using System.Drawing.Text;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows.Forms;
+
+namespace PuzzlePlayer_Namespace
+{
+    internal class Skyscrapers : Board
+    {
+        public int[,] visionState;
+        public Skyscrapers(int boardSize = 6)
+        {
+            boardState = GetClearBoard(boardSize);
+            lastGeneratedBoard = GetClearBoard(boardSize);
+            description = "lol";
+            drawFactor = 1;
+        }
+        public override void Draw(Graphics gr, Rectangle r)
+        {
+            gr.TextRenderingHint = TextRenderingHint.AntiAlias;
+            Size tilesize = new Size(r.Width / boardState.GetLength(0), r.Height / boardState.GetLength(1));
+            int stringsize = Math.Min(tilesize.Height / 2, tilesize.Width) * 2 * 1 / 2;
+            StringFormat stringFormat = new StringFormat();
+            stringFormat.LineAlignment = StringAlignment.Center;
+            stringFormat.Alignment = StringAlignment.Center;
+            gr.FillRectangle(Brushes.Beige, r.X + tilesize.Width, r.Y + tilesize.Height, r.Width - 2 * tilesize.Width, r.Height - 2 * tilesize.Height);
+            for (int i = 0; i < boardState.GetLength(0); i++)
+            {
+                for (int j = 0; j < boardState.GetLength(1); j++)
+                {
+                    if (i == 0 || i == boardState.GetLength(0) - 1 || j == 0 || j == boardState.GetLength(1) - 1)
+                    {
+                        if (boardState[i, j] != emptySpace)
+                        {
+                            gr.DrawString(Convert.ToString(boardState[i, j]),
+                            new Font("Verdana", stringsize / 2),
+                            Brushes.Black,
+                            (int)(r.X + ((double)i + 0.5) * tilesize.Width),
+                            (int)(r.Y + ((double)j + 0.5) * tilesize.Height),
+                            stringFormat);
+                        }
+                    }
+                    else
+                    {
+                        gr.DrawRectangle(Pens.DarkGray,
+                        r.X + i * tilesize.Width,
+                        r.Y + j * tilesize.Height,
+                        tilesize.Width,
+                        tilesize.Height);
+                        if (boardState[i, j] != emptySpace)
+                        {
+                            gr.DrawString(Convert.ToString(boardState[i, j]),
+                            new Font("Verdana", stringsize),
+                            Brushes.Black,
+                            (int)(r.X + ((double)i + 0.5) * tilesize.Width),
+                            (int)(r.Y + ((double)j + 0.5) * tilesize.Height),
+                            stringFormat);
+                        }
+                    }
+                }
+            }
+        }
+
+        public override SOLUTIONS Solve(bool CheckOnly)
+        {
+            return SOLUTIONS.NONE;
+        }
+
+        public override void Generate()
+        {
+            throw new NotImplementedException();
+        }
+
+        public override void TileInput(Point? p, Keys k)
+        {
+            if (p == null) return;
+            int num = (int)k - 48;
+            if (num > 0 && num <= boardState.GetLength(0)) boardState[((Point)p).X, ((Point)p).Y] = num;
+        }
+
+        protected override List<Move> GetSolveList(int[,] boardToSolve)
+        {
+            return new List<Move>();
+        }
+    }
+}
-- 
GitLab