Skip to content

Commit

Permalink
1.2.2.0 cheege build
Browse files Browse the repository at this point in the history
  • Loading branch information
hunter2actual committed Nov 18, 2024
1 parent a9a4b5b commit d9a67dd
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 30 deletions.
8 changes: 4 additions & 4 deletions DalamudMinesweeper.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"Author": "hunter2_",
"Name": "Minesweeper",
"InternalName": "DalamudMinesweeper",
"AssemblyVersion": "1.2.0.0",
"AssemblyVersion": "1.2.2.0",
"Description": "Logic puzzle in which you find and flag hidden mines.\n\nLeft click to uncover a square, right click to place a flag.\nThe game ends when all mines are flagged and all safe squares have been uncovered.\nClick the smiley face to start a new game.",
"ApplicableVersion": "any",
"Tags": [
Expand All @@ -18,9 +18,9 @@
"LoadPriority": 0,
"Punchline": "Classic puzzle game.",
"AcceptsFeedback": true,
"DownloadLinkInstall": "https://github.com/hunter2actual/DalamudMinesweeper/releases/download/1.2.0.0/latest.zip",
"DownloadLinkUpdate": "https://github.com/hunter2actual/DalamudMinesweeper/releases/download/1.2.0.0/latest.zip",
"DownloadLinkInstall": "https://github.com/hunter2actual/DalamudMinesweeper/releases/download/1.2.2.0/latest.zip",
"DownloadLinkUpdate": "https://github.com/hunter2actual/DalamudMinesweeper/releases/download/1.2.2.0/latest.zip",
"IconUrl": "https://raw.githubusercontent.com/hunter2actual/DalamudMinesweeper/master/images/icon.png",
"Changelog": "Update for FFXIV 7.1"
"Changelog": "Consider game won when all safe cells revealed, even if not all mines are flagged (thanks cheege)"
}
]
2 changes: 1 addition & 1 deletion DalamudMinesweeper/DalamudMinesweeper.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<Import Project="Dalamud.Plugin.Bootstrap.targets" />

<PropertyGroup>
<Version>1.2.1.0</Version>
<Version>1.2.2.0</Version>
<Description>A logic puzzle featuring hidden mines.</Description>
<PackageProjectUrl>https://github.com/hunter2actual/DalamudMinesweeper</PackageProjectUrl>
<PackageLicenseExpression>AGPL-3.0-or-later</PackageLicenseExpression>
Expand Down
27 changes: 15 additions & 12 deletions DalamudMinesweeper/Game/BoardExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,19 @@ public static Board HideAll(this Board board)
return board;
}

public static Board FlagAllMines(this Board board)
{
for (int x = 0; x < board.width; x++) {
for (int y = 0; y < board.height; y++) {
if (board.cells[x, y].contents is CellContents.Mine)
{
board.cells[x, y].isFlagged = true;
}
}
}
return board;
}

public static CellContents RevealCell(this Board board, int x, int y)
{
board.cells[x, y].isRevealed = true;
Expand Down Expand Up @@ -220,18 +233,8 @@ public static void RevealConnectedField(this Board board, int x, int y)
return;
}

public static bool IsVictory(this Board board)
{
var cells = board.cells.ToList();

var minesAreFlagged = cells
.Where(c => c.contents is CellContents.Mine)
.All(c => c.isFlagged);

var nonMinesRevealed = cells
public static bool IsVictory(this Board board) =>
board.cells.ToList()
.Where(c => c.contents is not CellContents.Mine)
.All(c => c.isRevealed);

return minesAreFlagged && nonMinesRevealed;
}
}
3 changes: 3 additions & 0 deletions DalamudMinesweeper/Game/MinesweeperGame.cs
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ public void RightClick(int x, int y)
public void Win()
{
GameState = GameState.Victorious;
FlagAllMines();
_onVictory();
_stopwatch.Stop();
}
Expand All @@ -117,6 +118,8 @@ public void Win()

public void HideAll() => Board.HideAll();

public void FlagAllMines() => Board.FlagAllMines();

public Cell GetCell(int x, int y) => Board.cells[x, y];

public int NumUnflaggedMines()
Expand Down
2 changes: 1 addition & 1 deletion DalamudMinesweeper/Plugin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public Plugin(

_configWindow = new ConfigWindow(this);
_scoresWindow = new ScoresWindow(this);
_mainWindow = new MainWindow(this, Configuration, Service.TextureProvider);
_mainWindow = new MainWindow(this, Configuration);

WindowSystem.AddWindow(_configWindow);
WindowSystem.AddWindow(_scoresWindow);
Expand Down
17 changes: 5 additions & 12 deletions DalamudMinesweeper/Windows/MainWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,12 @@
using DalamudMinesweeper.Sweepers;
using DalamudMinesweeper.Sprites;
using ImGuiNET;
using Dalamud.Plugin.Services;

namespace DalamudMinesweeper.Windows;

public class MainWindow : Window, IDisposable
{
private readonly TileSprites _tileSprites;
private readonly NumberSprites _numberSprites;
private readonly Sweeper _sweeper;

private readonly Configuration _configuration;
private MinesweeperGame _game;
Expand All @@ -24,7 +21,6 @@ public class MainWindow : Window, IDisposable
// Pixel sizes
private readonly int _dalamudWindowPaddingPx = 8;
private int _gridSquareSizePx;
private Vector2 _gridSquareSizePxVec2;
private readonly int _borderWidthPx = 12;
private readonly Vector2 _borderWidthPxVec2 = new(12, 12);
private readonly int _titleBarHeightPx = 26;
Expand All @@ -36,7 +32,7 @@ public class MainWindow : Window, IDisposable
private Footer _footer;
private Background _background;

public MainWindow(Plugin plugin, Configuration configuration, ITextureProvider textureProvider) : base("Minesweeper",
public MainWindow(Plugin plugin, Configuration configuration) : base("Minesweeper",
ImGuiWindowFlags.NoScrollbar
| ImGuiWindowFlags.NoScrollWithMouse
| ImGuiWindowFlags.NoResize
Expand All @@ -50,25 +46,22 @@ public MainWindow(Plugin plugin, Configuration configuration, ITextureProvider t

_configuration = configuration;
_tileSprites = new TileSprites(Service.PluginInterface);
_numberSprites = new NumberSprites(Service.PluginInterface);
_gridSquareSizePxVec2 = new Vector2(0, 0);
var numberSprites = new NumberSprites(Service.PluginInterface);

_sweeper = new Sweeper();
_game = InitialiseGame();
_gameBoard = new GameBoard(_game, _tileSprites, _configuration);
_header = new Header(_game, _tileSprites, _numberSprites, _configuration, () => InitialiseGame());
_footer = new Footer(_game, _configuration, plugin.DrawConfigUI, plugin.DrawScoresUI, _sweeper);
_header = new Header(_game, _tileSprites, numberSprites, _configuration, () => InitialiseGame());
_footer = new Footer(_game, _configuration, plugin.DrawConfigUI, plugin.DrawScoresUI, new Sweeper());
_background = new Background(_game, _configuration, _borderWidthPx);
}

public override void Draw()
{
// Calculate element sizes
var windowPos = ImGui.GetWindowPos();
var headerHeightPx = (int) (_tileSprites.SmileySize.Y + 8)* _configuration.Zoom;
var headerHeightPx = (int) (_tileSprites.SmileySize.Y + 8) * _configuration.Zoom;

_gridSquareSizePx = (int) _tileSprites.TileSize.X * _configuration.Zoom;
_gridSquareSizePxVec2.X = _gridSquareSizePxVec2.Y = _gridSquareSizePx;
_boardDimensions = new Vector2(_game.Width, _game.Height);
var windowWidthPx = _gridSquareSizePx*_boardDimensions.X + 2*_borderWidthPx*_configuration.Zoom + 2*_dalamudWindowPaddingPx;
var windowHeightPx = _gridSquareSizePx*_boardDimensions.Y + 2*_borderWidthPx*_configuration.Zoom + 2*_dalamudWindowPaddingPx
Expand Down

0 comments on commit d9a67dd

Please sign in to comment.