mirror of
https://github.com/zenorogue/hyperrogue.git
synced 2025-08-06 05:43:56 +00:00
separated function chosenDownId
This commit is contained in:
parent
2762b1197c
commit
cebfcf5196
19
bigstuff.cpp
19
bigstuff.cpp
@ -649,11 +649,10 @@ cell *randomDown(cell *c) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// which=1 => right, which=-1 => left
|
// which=1 => right, which=-1 => left
|
||||||
// set which=1,bonus=1 to get right neighbor on level
|
|
||||||
|
|
||||||
typedef int cellfunction(cell*);
|
typedef int cellfunction(cell*);
|
||||||
|
|
||||||
cell *chosenDown(cell *c, int which, int bonus, cellfunction* cf) {
|
int chosenDownId(cell *c, int which, cellfunction* cf) {
|
||||||
int d = (*cf)(c)-1;
|
int d = (*cf)(c)-1;
|
||||||
for(int i=0; i<c->type; i++) {
|
for(int i=0; i<c->type; i++) {
|
||||||
if(!c->move(i)) createMov(c, i);
|
if(!c->move(i)) createMov(c, i);
|
||||||
@ -663,12 +662,20 @@ cell *chosenDown(cell *c, int which, int bonus, cellfunction* cf) {
|
|||||||
int i2 = (i+which+S42)%c->type;
|
int i2 = (i+which+S42)%c->type;
|
||||||
createMov(c, i2);
|
createMov(c, i2);
|
||||||
if((*cf)(c->move(i2)) == d)
|
if((*cf)(c->move(i2)) == d)
|
||||||
return createMovR(c, i2+bonus);
|
return i2;
|
||||||
else return createMovR(c, i+bonus);
|
else return i;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// printf("nothing down here\n");
|
|
||||||
return NULL;
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
// set which=1,bonus=1 to get right neighbor on level
|
||||||
|
|
||||||
|
cell *chosenDown(cell *c, int which, int bonus, cellfunction* cf) {
|
||||||
|
int id = chosenDownId(c, which, cf);
|
||||||
|
if(id == -1) return NULL;
|
||||||
|
return createMovR(c, id + bonus);
|
||||||
}
|
}
|
||||||
|
|
||||||
int edgeDepth(cell *c) {
|
int edgeDepth(cell *c) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user