|
|
|
@ -4,11 +4,19 @@ |
|
|
|
|
#include "Game.h" |
|
|
|
|
|
|
|
|
|
void Spectator::OnWallJumped(WallJumpEvent *event) { |
|
|
|
|
float timeDiff = Game::instance->eTime - event->time; |
|
|
|
|
if (timeDiff > 2){ |
|
|
|
|
currentMessage = "Ignored event"; |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
currentMessage = "Calculating prime..."; |
|
|
|
|
int prime = getHighPrime(); |
|
|
|
|
currentMessage = std::to_string(prime); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void Spectator::OnWallCrashed(WallCrashEvent *event) { |
|
|
|
|
|
|
|
|
|
currentMessage = "Crash!"; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -41,4 +49,22 @@ void Spectator::draw(QPainter &painter) const { |
|
|
|
|
painter.restore(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
int Spectator::getHighPrime() { |
|
|
|
|
int val = 100'000'000; |
|
|
|
|
int start = int(Game::Random(val, val * 1.5)); |
|
|
|
|
for (int i = start; i < start + 100; i++){ |
|
|
|
|
bool isPrime = true; |
|
|
|
|
for (int j = 3; j < i; j++){ |
|
|
|
|
if (i % j == 0){ |
|
|
|
|
isPrime = false; |
|
|
|
|
break; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
if (isPrime){ |
|
|
|
|
return i; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
return 2; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|