bounded Minefield now works according to the standard Minesweeper rules

This commit is contained in:
Zeno Rogue 2019-04-04 14:36:45 +02:00
parent e61c684bca
commit 57f2891826
8 changed files with 52 additions and 2 deletions

View File

@ -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;
}
}

View File

@ -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

View File

@ -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 :

View File

@ -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);

View File

@ -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)

View File

@ -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;

View File

@ -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;

View File

@ -270,6 +270,9 @@ void initgame() {
makeEmpty(cwt.at);
}
if(specialland == laMinefield && bounded)
generate_mines();
princess::squeaked = false;
clearing::current_root = NULL;