mirror of
https://github.com/zenorogue/hyperrogue.git
synced 2025-01-11 09:50:34 +00:00
bounded Minefield now works according to the standard Minesweeper rules
This commit is contained in:
parent
e61c684bca
commit
57f2891826
11
bigstuff.cpp
11
bigstuff.cpp
@ -1516,4 +1516,15 @@ void moreBigStuff(cell *c) {
|
||||
}
|
||||
}
|
||||
|
||||
void generate_mines() {
|
||||
vector<cell*> candidates;
|
||||
for(cell *c: currentmap->allcells())
|
||||
if(c->wall == waMineUnknown)
|
||||
candidates.push_back(c);
|
||||
bounded_mine_max = isize(candidates);
|
||||
hrandom_shuffle(&candidates[0], bounded_mine_max);
|
||||
bounded_mine_quantity = int(bounded_mine_max * bounded_mine_percentage + 0.5);
|
||||
for(int i=0; i<bounded_mine_quantity; i++) candidates[i]->wall = waMineMine;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -4,6 +4,9 @@
|
||||
|
||||
namespace hr {
|
||||
|
||||
ld bounded_mine_percentage = 0.1;
|
||||
int bounded_mine_quantity, bounded_mine_max;
|
||||
|
||||
const char *conffile = "hyperrogue.ini";
|
||||
|
||||
array<ld, gGUARD> sightranges;
|
||||
@ -409,6 +412,8 @@ void initConfig() {
|
||||
addsaver(racing::standard_centering, "race_standard_centering");
|
||||
#endif
|
||||
|
||||
addsaver(bounded_mine_percentage, "bounded_mine_percentage");
|
||||
|
||||
#if CAP_SHMUP
|
||||
shmup::initConfig();
|
||||
#endif
|
||||
|
1
game.cpp
1
game.cpp
@ -3515,6 +3515,7 @@ void gainShard(cell *c2, const char *msg) {
|
||||
|
||||
void uncoverMinesFull(cell *c2) {
|
||||
int mineradius =
|
||||
bounded ? 3 :
|
||||
(items[itBombEgg] < 1 && !tactic::on) ? 0 :
|
||||
items[itBombEgg] < 20 ? 1 :
|
||||
items[itBombEgg] < 30 ? 2 :
|
||||
|
18
geom-exp.cpp
18
geom-exp.cpp
@ -676,6 +676,24 @@ void showEuclideanMenu() {
|
||||
|
||||
dialog::addSelItem(XLAT("land"), XLAT1(linf[specialland].name), 'l');
|
||||
dialog::add_action_push(ge_land_selection);
|
||||
|
||||
if(specialland == laMinefield && bounded) {
|
||||
dialog::addSelItem(XLAT("number of mines"), its(bounded_mine_quantity), 'm');
|
||||
dialog::add_action([] {
|
||||
dialog::editNumber(bounded_mine_quantity, 0, bounded_mine_max, (bounded_mine_max+5)/10, 1,
|
||||
XLAT("number of mines"), "");
|
||||
dialog::reaction = [] {
|
||||
if(bounded_mine_quantity < 0) bounded_mine_quantity = 0;
|
||||
if(bounded_mine_quantity > bounded_mine_max) bounded_mine_quantity = bounded_mine_max;
|
||||
};
|
||||
dialog::reaction_final = [] {
|
||||
bounded_mine_percentage = bounded_mine_quantity * 1. / bounded_mine_max;
|
||||
stop_game();
|
||||
start_game();
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
dialog::addBoolItem(XLAT("pattern"), specialland == laCanvas, 'p');
|
||||
if(specialland == laCanvas) dialog::lastItem().value = patterns::whichCanvas;
|
||||
dialog::add_action_push(patterns::showPrePattern);
|
||||
|
4
hyper.h
4
hyper.h
@ -1663,6 +1663,10 @@ extern bool timerstopped;
|
||||
bool againstRose(cell *cfrom, cell *cto);
|
||||
bool withRose(cell *cfrom, cell *cto);
|
||||
|
||||
extern ld bounded_mine_percentage;
|
||||
extern int bounded_mine_quantity, bounded_mine_max;
|
||||
void generate_mines();
|
||||
|
||||
// loops
|
||||
|
||||
#define fakecellloop(ct) for(cell *ct = (cell*)1; ct; ct=NULL)
|
||||
|
@ -1954,7 +1954,8 @@ void giantLandSwitch(cell *c, int d, cell *from) {
|
||||
break;
|
||||
|
||||
case laMinefield:
|
||||
if(d == 7) {
|
||||
if(d == 7 && bounded) c->wall = waMineUnknown;
|
||||
else if(d == 7) {
|
||||
c->wall = waMineUnknown;
|
||||
// 250: rare mines
|
||||
// 1250: at 25
|
||||
@ -1985,7 +1986,7 @@ void giantLandSwitch(cell *c, int d, cell *from) {
|
||||
c->monst = moBomberbird;
|
||||
else placeLocalSpecial(c, 500);
|
||||
}
|
||||
if(d == 3 && safety && (c->wall == waMineMine || c->wall == waMineUnknown))
|
||||
if(d == 3 && safety && (c->wall == waMineMine || c->wall == waMineUnknown) && !bounded)
|
||||
c->wall = waMineOpen;
|
||||
break;
|
||||
|
||||
|
@ -304,6 +304,13 @@ eItem wanderingTreasure(cell *c) {
|
||||
}
|
||||
|
||||
void wandering() {
|
||||
if(bounded && specialland == laMinefield) {
|
||||
kills[moBomberbird] = 0;
|
||||
kills[moTameBomberbird] = 0;
|
||||
for(cell *c: currentmap->allcells()) if(c->wall == waMineUnknown) kills[moBomberbird]++;
|
||||
for(cell *c: currentmap->allcells()) if(among(c->wall, waMineMine, waMineUnknown) && mineMarked(c)) kills[moTameBomberbird]++;
|
||||
return;
|
||||
}
|
||||
if(!canmove) return;
|
||||
if(!gen_wandering) return;
|
||||
if(racing::on) return;
|
||||
|
@ -270,6 +270,9 @@ void initgame() {
|
||||
makeEmpty(cwt.at);
|
||||
}
|
||||
|
||||
if(specialland == laMinefield && bounded)
|
||||
generate_mines();
|
||||
|
||||
princess::squeaked = false;
|
||||
clearing::current_root = NULL;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user