Skip to content

Commit cef9963

Browse files
authored
Merge pull request #240 from ayushshaz/master
Log added, Its easy to showcase that what's happening here.
2 parents d47de9a + 2cac0ad commit cef9963

File tree

1 file changed

+9
-4
lines changed
  • blockchain-workbench/application-and-smart-contract-samples/ping-pong-game/ethereum

1 file changed

+9
-4
lines changed

blockchain-workbench/application-and-smart-contract-samples/ping-pong-game/ethereum/PingPongGame.sol

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ pragma solidity >=0.4.25 <0.6.0;
33
contract Starter
44
{
55
enum StateType { GameProvisioned, Pingponging, GameFinished}
6-
6+
event Log(string _myString);
77
StateType public State;
88

99
string public PingPongGameName;
@@ -21,7 +21,7 @@ contract Starter
2121
}
2222

2323
function StartPingPong(int pingPongTimes) public
24-
{
24+
{
2525
PingPongTimes = pingPongTimes;
2626

2727
State = StateType.Pingponging;
@@ -30,16 +30,19 @@ contract Starter
3030
}
3131

3232
function Pong(int currentPingPongTimes) public
33-
{
33+
{
34+
//
3435
int remainingPingPongTimes = currentPingPongTimes - 1;
3536

3637
if(remainingPingPongTimes > 0)
3738
{
3839
State = StateType.Pingponging;
40+
emit Log("Inside_Contract_1");
3941
GamePlayer.Ping(remainingPingPongTimes);
4042
}
4143
else
4244
{
45+
emit Log("Inside_Contract_1");
4346
State = StateType.GameFinished;
4447
GamePlayer.FinishGame();
4548
}
@@ -54,7 +57,7 @@ contract Starter
5457
contract Player
5558
{
5659
enum StateType {PingpongPlayerCreated, PingPonging, GameFinished}
57-
60+
event Log(string _myString);
5861
StateType public State;
5962

6063
address public GameStarter;
@@ -75,10 +78,12 @@ contract Player
7578
if(remainingPingPongTimes > 0)
7679
{
7780
State = StateType.PingPonging;
81+
emit Log("Inside_Contract_2");
7882
starter.Pong(remainingPingPongTimes);
7983
}
8084
else
8185
{
86+
emit Log("Inside_Contract_2");
8287
State = StateType.GameFinished;
8388
starter.FinishGame();
8489
}

0 commit comments

Comments
 (0)