From: kemal <kemalinanc8@gmail.com>
To: 9front@9front.org
Subject: [9front] Re: games/mines: do not put a mine to the first clicked tile, add a cool option
Date: Sun, 11 Jul 2021 16:31:26 +0000 [thread overview]
Message-ID: <CABO6shc-zJkQQZwYdZhiepDvhOLZQ6iPopTW8OXKExK_qLFXcg@mail.gmail.com> (raw)
In-Reply-To: <CABO6sheQd+LcpYwwafs=OX9CddrgRfrJFTerTDKPZ+8mvNQn5g@mail.gmail.com>
[-- Attachment #1: Type: text/plain, Size: 190 bytes --]
just realised that middle+right click at the very beginning
will cause problems, and i saw a typo in the manpage
change, so um apply this instead:
(HOPEFULLY not a second games/glendy case)
[-- Attachment #2: patch.txt --]
[-- Type: text/plain, Size: 5295 bytes --]
From: kemal <kemalinanc8@gmail.com>
Date: Sun, 11 Jul 2021 16:28:18 +0000
Subject: [PATCH] games/mines: some mechanism changes
1. do not put a mine to the first clicked tile.
2. do not allow middle/right clicks at beginning.
3. add a option that will make the game run "faster" :^)
(thanks ori for the idea of -f)
---
diff c3589ef3cf33189d342a3ab638b558fd9249b220 99536f642160327672971cf8606a64ddd12e02d3
--- a/sys/man/1/mines Sat Jul 10 21:34:22 2021
+++ b/sys/man/1/mines Sun Jul 11 19:28:18 2021
@@ -4,7 +4,7 @@
.SH SYNOPSIS
.B games/mines
[
-.B -aeqg
+.B -aefgq
]
.SH DESCRIPTION
.I Mines
@@ -46,11 +46,16 @@
.B -e
Start at expert difficulty.
.TP
-.B -q
-Disable the query marker.
+.B -f
+It t-
+.I ahem
+I mean it makes the game faster to solve.
.TP
.B -g
It's a secret to everybody.
+.TP
+.B -q
+Disable the query marker.
.SH SOURCE
.B /sys/src/games/mines
.SH HISTORY
--- a/sys/src/games/mines/dat.h Sat Jul 10 21:34:22 2021
+++ b/sys/src/games/mines/dat.h Sun Jul 11 19:28:18 2021
@@ -23,15 +23,15 @@
};
enum {
- Empty0 = 0,
- Empty1 = 1,
- Empty2 = 2,
- Empty3 = 3,
- Empty4 = 4,
- Empty5 = 5,
- Empty6 = 6,
- Empty7 = 7,
- Empty8 = 8,
+ Empty0,
+ Empty1,
+ Empty2,
+ Empty3,
+ Empty4,
+ Empty5,
+ Empty6,
+ Empty7,
+ Empty8,
Query,
MouseQuery,
Mark,
--- a/sys/src/games/mines/mines.c Sat Jul 10 21:34:22 2021
+++ b/sys/src/games/mines/mines.c Sun Jul 11 19:28:18 2021
@@ -10,7 +10,7 @@
int MaxX, MaxY, Mines;
} Settings[] = { {8, 8, 10}, {16, 16, 40}, {30, 16, 99}, {0, 0, 0} };
-int MaxX, MaxY, Mines, Level, UnknownCell, Playing, MinesRemain, Time, Status, UseQuery = TRUE, UseGhost = FALSE, UseColor = TRUE;
+int MaxX, MaxY, Mines, Level, UnknownCell, Playing, MinesRemain, Time, Status, UseQuery = TRUE, UseGhost = FALSE, Trololo = FALSE, UseColor = TRUE;
Point Origin;
Mouse LastMouse;
@@ -159,21 +159,45 @@
}
void InitMineField(void) {
+ int x, y;
+ /* clean up mine field, make all cells unknown */
- /* clean up mine field, make all cells unknown and place new mines */
- {
- int i, x, y;
+ for(y = 0; y < MaxY; y++)
+ for(x = 0; x < MaxX; x++) {
+ MineField[x][y].Mine = FALSE;
+ MineField[x][y].Picture = Unknown;
+ }
- for(y = 0; y < MaxY; y++)
- for(x = 0; x < MaxX; x++) {
- MineField[x][y].Mine = FALSE;
- MineField[x][y].Picture = Unknown;
- }
+ /* reset status, remaining mines etc. */
+ Status = Game;
+ Playing = FALSE;
+ MinesRemain = Mines;
+ Time = 0;
+ UnknownCell = MaxX * MaxY - Mines;
+}
- for(i = 0; i < Mines; ) {
+void GenMines(int fcx, int fcy) {
+ srand(time(0));
+ /* plant mines */
+ {
+ int i = 0, x, y;
+
+ /*
+ * this option just trolls the user by increasing
+ * the chance of a mine in the first click from %0 to %90
+ */
+ if(Trololo){
+ i = nrand(9);
+ if(i){
+ MineField[fcx][fcy].Mine = TRUE;
+ i = 1;
+ }
+ }
+ while(i < Mines) {
x = nrand(MaxX);
y = nrand(MaxY);
if(MineField[x][y].Mine) continue;
+ if(x == fcx && y == fcy) continue;
MineField[x][y].Mine = TRUE;
i++;
}
@@ -196,12 +220,6 @@
if(x < MaxX - 1 && y < MaxY - 1 && MineField[x + 1][y + 1].Mine) MineField[x][y].Neighbours++;
}
}
-
- Status = Game;
- Playing = FALSE;
- MinesRemain = Mines;
- Time = 0;
- UnknownCell = MaxX * MaxY - Mines;
}
void NewMineField(int NewLevel) {
@@ -284,12 +302,17 @@
}
void LeftClick(Point Cell) {
+
+ int FirstClick;
- if(! (Status == Game) || Cell.x < 0 || Cell.y < 0) return;
+ if(Status != Game || Cell.x < 0 || Cell.y < 0) return;
+ FirstClick = !Playing;
Playing = TRUE;
switch(MineField[Cell.x][Cell.y].Picture) {
case Query:
case Unknown:
+ if(FirstClick)
+ GenMines(Cell.x, Cell.y);
if(MineField[Cell.x][Cell.y].Mine) {
MineField[Cell.x][Cell.y].Picture = Explosion;
DrawCell(Cell);
@@ -320,8 +343,7 @@
int Neighbours = 0;
- if(! (Status == Game) || Cell.x < 0 || Cell.y < 0) return;
- Playing = TRUE;
+ if(Status != Game || Playing == FALSE || Cell.x < 0 || Cell.y < 0) return;
switch(MineField[Cell.x][Cell.y].Picture) {
case Empty1:
case Empty2:
@@ -359,9 +381,7 @@
void RightClick(Point Cell) {
- if(! (Status == Game) || Cell.x < 0 || Cell.y < 0) return;
-
- Playing = TRUE;
+ if(Status != Game || Playing == FALSE || Cell.x < 0 || Cell.y < 0) return;
switch(MineField[Cell.x][Cell.y].Picture) {
case Unknown:
MineField[Cell.x][Cell.y].Picture = Mark;
@@ -381,7 +401,7 @@
void Usage(void) {
- fprint(2, "Usage: %s [-aeq]\n", argv0);
+ fprint(2, "Usage: %s [-aefgq]\n", argv0);
exits("usage");
}
@@ -392,8 +412,9 @@
ARGBEGIN {
case 'a': Level = Advanced; break;
case 'e': Level = Expert; break;
- case 'q': UseQuery = FALSE; break;
+ case 'f': Trololo = TRUE; break;
case 'g': UseGhost = TRUE; break;
+ case 'q': UseQuery = FALSE; break;
default:
Usage();
} ARGEND
@@ -518,8 +539,6 @@
ImageCell[Fault] = allocimage(display, Rect(0, 0, 15, 15), RGB24, 0, DNofill);
loadimage(ImageCell[Fault], ImageCell[Fault]->r, SrcFault, CellBytes);
- srand(time(0)); /* initialize generator of random numbers */
-
NewMineField(Level);
eresized(0);
@@ -649,7 +668,7 @@
if(PushButton && CurrentButton) {
InitMineField();
eresized(0);
- }
+ }
Button = FALSE;
PushButton = FALSE;
prev parent reply other threads:[~2021-07-11 21:25 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-07-10 23:11 [9front] " kemal
2021-07-11 11:07 ` Philip Silva
2021-07-11 13:41 ` hiro
2021-07-11 16:31 ` kemal [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=CABO6shc-zJkQQZwYdZhiepDvhOLZQ6iPopTW8OXKExK_qLFXcg@mail.gmail.com \
--to=kemalinanc8@gmail.com \
--cc=9front@9front.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).