function makePrediction(
uint256 matchNumber,
ScoreBoard.Result prediction
) public payable {
if (msg.value != predictionFee) {
revert ThePredicter__IncorrectPredictionFee();
}
if (block.timestamp > START_TIME + matchNumber * 68400 - 68400) {
revert ThePredicter__PredictionsAreClosed();
}
scoreBoard.confirmPredictionPayment(msg.sender, matchNumber);
scoreBoard.setPrediction(msg.sender, matchNumber, prediction);
}
Doesn't implement the feature in the doc.
uint64 private constant MATCH_DURATION = 68400;
uint64 private constant PREDICTION_DURATION = 3600;
error ThePredicter__PaidAndSelectSamePrediction();
function makePrediction(
uint256 matchNumber,
ScoreBoard.Result prediction
) public payable onlyPlayer {
if (
block.timestamp >
START_TIME + matchNumber * MATCH_DURATION - PREDICTION_DURATION
) {
revert ThePredicter__PredictionsAreClosed();
}
(bool isPayed, ScoreBoard.Result result) = scoreBoard.playerPredictions(
msg.sender,
matchNumber
);
if (isPayed) {
if (result == prediction) {
revert ThePredicter__PaidAndSelectSamePrediction();
}
} else {
if (msg.value != predictionFee) {
revert ThePredicter__IncorrectPredictionFee();
}
scoreBoard.confirmPredictionPayment(msg.sender, matchNumber);
}
scoreBoard.setPrediction(msg.sender, matchNumber, prediction);
}
function playerPredictions(
address player,
uint256 matchNumber
) public view returns (bool isPaid, Result result) {
require(matchNumber < NUM_MATCHES, "Invalid match number");
return (
playersPredictions[player].isPaid[matchNumber],
playersPredictions[player].predictions[matchNumber]
);
}