mirror of
https://github.com/zenorogue/hyperrogue.git
synced 2025-03-13 23:18:16 +00:00
racing:: limit on pauses
This commit is contained in:
parent
32f876dc4f
commit
fb6e8b72da
18
racing.cpp
18
racing.cpp
@ -1250,8 +1250,26 @@ EX void displayScore(eLand l) {
|
||||
}
|
||||
}
|
||||
|
||||
EX int pause_limit = 3;
|
||||
|
||||
EX bool started() {
|
||||
return race_start_tick && ticks >= race_start_tick;
|
||||
}
|
||||
|
||||
EX bool finished() {
|
||||
for(int& i: racing::race_finish_tick) if(!i) return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
EX void race_won() {
|
||||
if(!race_finish_tick[multi::cpid]) {
|
||||
|
||||
if(shmup::count_pauses >= pause_limit) {
|
||||
addMessage(XLAT("Too many pauses!"));
|
||||
race_finish_tick[multi::cpid] = ticks;
|
||||
return;
|
||||
}
|
||||
|
||||
int result = ticks - race_start_tick;
|
||||
int losers = 0;
|
||||
int place = 1;
|
||||
|
15
shmup.cpp
15
shmup.cpp
@ -851,10 +851,10 @@ void movePlayer(monster *m, int delta) {
|
||||
mdx = mdy = 0;
|
||||
}
|
||||
facemouse = shotkey = dropgreen = false;
|
||||
if(ticks < racing::race_start_tick || !racing::race_start_tick) (WDIM == 2 ? mgo : mdy) = 0;
|
||||
if(!racing::started()) (WDIM == 2 ? mgo : mdy) = 0;
|
||||
}
|
||||
else {
|
||||
if(racing::on && (ticks < racing::race_start_tick || !racing::race_start_tick)) mgo = mdx = mdy = 0;
|
||||
if(racing::on && !racing::started()) mgo = mdx = mdy = 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -2564,6 +2564,9 @@ EX hookset<bool(int)> hooks_turn;
|
||||
/** the amount of time chars are disabled in PvP */
|
||||
EX int pvp_delay = 2000;
|
||||
|
||||
EX int count_pauses;
|
||||
EX bool in_pause;
|
||||
|
||||
EX void turn(int delta) {
|
||||
|
||||
if(split_screen && subscreens::split( [delta] () { turn(delta); })) return;
|
||||
@ -2592,6 +2595,13 @@ EX void turn(int delta) {
|
||||
if(!shmup::on) return;
|
||||
if(!(cmode & sm::NORMAL)) {
|
||||
#if CAP_RACING
|
||||
if(!in_pause) {
|
||||
in_pause = true;
|
||||
if(!(racing::on && !racing::started() && !racing::finished())) {
|
||||
count_pauses++;
|
||||
addMessage(XLAT("Pauses: %1 of %2 allowed", its(count_pauses), its(racing::pause_limit)));
|
||||
}
|
||||
}
|
||||
if(racing::on) {
|
||||
if(racing::race_start_tick) racing::race_start_tick += delta;
|
||||
for(int& i: racing::race_finish_tick) if(i) i += delta;
|
||||
@ -2599,6 +2609,7 @@ EX void turn(int delta) {
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
else in_pause = false;
|
||||
|
||||
passive_switch = (gold() & 1) ? moSwitch1 : moSwitch2;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user