1
- pragma solidity ^ 0.4.25 ;
1
+ pragma solidity >= 0.4.25 < 0.6.0 ;
2
2
3
3
contract Starter
4
4
{
@@ -8,10 +8,10 @@ contract Starter
8
8
9
9
string public PingPongGameName;
10
10
address public GameStarter;
11
- address public GamePlayer;
11
+ Player public GamePlayer;
12
12
int public PingPongTimes;
13
13
14
- constructor (string gameName ) public {
14
+ constructor (string memory gameName ) public {
15
15
PingPongGameName = gameName;
16
16
GameStarter = msg .sender ;
17
17
@@ -20,30 +20,28 @@ contract Starter
20
20
State = StateType.GameProvisioned;
21
21
}
22
22
23
- function StartPingPong (int pingPongTimes ) public
23
+ function StartPingPong (int pingPongTimes ) public
24
24
{
25
25
PingPongTimes = pingPongTimes;
26
26
27
- Player player = Player (GamePlayer);
28
27
State = StateType.Pingponging;
29
28
30
- player .Ping (pingPongTimes);
29
+ GamePlayer .Ping (pingPongTimes);
31
30
}
32
31
33
- function Pong (int currentPingPongTimes ) public
32
+ function Pong (int currentPingPongTimes ) public
34
33
{
35
- currentPingPongTimes = currentPingPongTimes - 1 ;
34
+ int remainingPingPongTimes = currentPingPongTimes - 1 ;
36
35
37
- Player player = Player (GamePlayer);
38
- if (currentPingPongTimes > 0 )
36
+ if (remainingPingPongTimes > 0 )
39
37
{
40
38
State = StateType.Pingponging;
41
- player .Ping (currentPingPongTimes );
39
+ GamePlayer .Ping (remainingPingPongTimes );
42
40
}
43
41
else
44
42
{
45
43
State = StateType.GameFinished;
46
- player .FinishGame ();
44
+ GamePlayer .FinishGame ();
47
45
}
48
46
}
49
47
@@ -62,22 +60,22 @@ contract Player
62
60
address public GameStarter;
63
61
string public PingPongGameName;
64
62
65
- constructor (string pingPongGameName ) public {
63
+ constructor (string memory pingPongGameName ) public {
66
64
GameStarter = msg .sender ;
67
65
PingPongGameName = pingPongGameName;
68
66
69
67
State = StateType.PingpongPlayerCreated;
70
68
}
71
69
72
- function Ping (int currentPingPongTimes ) public
70
+ function Ping (int currentPingPongTimes ) public
73
71
{
74
- currentPingPongTimes = currentPingPongTimes - 1 ;
72
+ int remainingPingPongTimes = currentPingPongTimes - 1 ;
75
73
76
74
Starter starter = Starter (msg .sender );
77
- if (currentPingPongTimes > 0 )
75
+ if (remainingPingPongTimes > 0 )
78
76
{
79
77
State = StateType.PingPonging;
80
- starter.Pong (currentPingPongTimes );
78
+ starter.Pong (remainingPingPongTimes );
81
79
}
82
80
else
83
81
{
0 commit comments