1
0
mirror of https://github.com/zenorogue/hyperrogue.git synced 2024-11-23 21:07:17 +00:00

crossbow:: checkmate rule

This commit is contained in:
Zeno Rogue 2023-10-28 08:43:19 +02:00
parent 4f82c3eb8e
commit b0d117e646
3 changed files with 27 additions and 1 deletions

View File

@ -338,6 +338,8 @@ EX void checkmove() {
}
#endif
if(!canmove && bow::crossbow_mode()) canmove = bow::have_bow_target();
if(!canmove) {
achievement_final(true);
if(cmode & sm::NORMAL) showMissionScreen();

View File

@ -297,6 +297,30 @@ EX void shoot() {
gen_bowpath_map();
}
EX bool have_bow_target() {
dynamicval<decltype(bowpath)> bp(bowpath);
dynamicval<decltype(bowpath_map)> bpm(bowpath_map);
for(int i=0; i<isize(dcal); i++) {
cell *c = dcal[i];
target_at = {};
target_at[c->cpdist] = {c};
int res = create_path();
if(res == -1) continue;
checked_move_issue = miVALID;
pcmove pcm;
pcm.checkonly = true;
changes.init(true);
bool b = pcm.try_shooting(false);
changes.rollback();
if(b) return true;
}
return false;
}
EX void showMenu() {
cmode = sm::SIDE | sm::MAYDARK;
gamescreen();

View File

@ -332,7 +332,7 @@ bool pcmove::movepcto() {
changes.rollback();
if(!checkonly) flipplayer = false;
if(!b && items[itCrossbow] == 0 && bow::crossbow_mode() && !bow::fire_mode && d >= 0) {
if(!b && items[itCrossbow] == 0 && bow::crossbow_mode() && !bow::fire_mode && d >= 0 && !checkonly) {
changes.init(checkonly);
changes.value_keep(bow::bowpath_map);
b = try_shooting(true);