mirror of
https://github.com/zenorogue/hyperrogue.git
synced 2024-11-20 11:54:48 +00:00
rulegen:: apply arb::convert, and imrpoved generation
This commit is contained in:
parent
c996805533
commit
4a0f688673
1
cell.cpp
1
cell.cpp
@ -343,6 +343,7 @@ EX void initcells() {
|
||||
#if CAP_CRYSTAL
|
||||
else if(cryst) currentmap = crystal::new_map();
|
||||
#endif
|
||||
else if(arb::in() && rulegen::known()) currentmap = rulegen::new_hrmap_rulegen();
|
||||
else if(arb::in()) currentmap = arb::new_map();
|
||||
#if CAP_ARCM
|
||||
else if(arcm::in()) currentmap = arcm::new_map();
|
||||
|
32
rulegen.cpp
32
rulegen.cpp
@ -1240,8 +1240,12 @@ EX void generate_rules() {
|
||||
|
||||
delete_tmap();
|
||||
|
||||
if(!arb::in())
|
||||
throw rulegen_surrender("rulegen algorithm works only on arb tessellations");
|
||||
if(!arb::in()) try {
|
||||
arb::convert::convert();
|
||||
}
|
||||
catch(hr_exception& e) {
|
||||
throw rulegen_surrender("conversion failure");
|
||||
}
|
||||
|
||||
prepare_around_radius = 1;
|
||||
|
||||
@ -1504,21 +1508,16 @@ EX int get_state(cell *c) {
|
||||
return c->master->fieldval;
|
||||
}
|
||||
|
||||
EX void restart_game_on(hrmap *m) {
|
||||
stop_game();
|
||||
int a = addHook(hooks_newmap, 0, [m] { return m;});
|
||||
start_game();
|
||||
delHook(hooks_newmap, a);
|
||||
}
|
||||
|
||||
string rules_known_for;
|
||||
string rules_known_for = "unknown";
|
||||
string rule_status;
|
||||
|
||||
EX bool known() {
|
||||
return rules_known_for == arb::current.name;
|
||||
}
|
||||
|
||||
bool prepare_rules() {
|
||||
if(rules_known_for == arb::current.name) return true;
|
||||
if(known()) return true;
|
||||
try {
|
||||
if(!arb::in())
|
||||
throw rulegen_failure("rulegen in wrong tessellation");
|
||||
generate_rules();
|
||||
rules_known_for = arb::current.name;
|
||||
rule_status = XLAT("rules generated successfully");
|
||||
@ -1549,8 +1548,11 @@ int args() {
|
||||
cleanup();
|
||||
else if(argis("-rulegen-play")) {
|
||||
PHASEFROM(3);
|
||||
if(prepare_rules())
|
||||
restart_game_on(new hrmap_rulegen);
|
||||
if(prepare_rules()) {
|
||||
stop_game();
|
||||
set_geometry(gArbitrary);
|
||||
start_game();
|
||||
}
|
||||
}
|
||||
else return 1;
|
||||
return 0;
|
||||
|
Loading…
Reference in New Issue
Block a user