forked from AcalaNetwork/Acala
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathAdvanced.sol
34 lines (30 loc) · 810 Bytes
/
Advanced.sol
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
pragma solidity ^0.8.9;
contract Advanced {
address _owner;
uint256 _prevPrevPlay;
constructor() {
_owner = msg.sender;
}
function owner() public view returns (address) {
return _owner;
}
function play(uint256 round, uint256 prevPlay, uint256 otherPrevPlay) public returns (uint256) {
if (round == 0) {
return 302;
}
if (otherPrevPlay == 302) {
return 302;
}
if (otherPrevPlay == round - 1) {
return round + 2;
}
if (otherPrevPlay == 0) {
return 302;
}
if (otherPrevPlay == (_prevPrevPlay + 2) % 3) {
return prevPlay + 1;
}
_prevPrevPlay = prevPlay;
return uint256(blockhash(block.number)) + round;
}
}