SC CODE: Function InitializePrivate() Uint64
10 IF init() == 0 THEN GOTO 30
20 RETURN 1
30 STORE("nameHdr", "Tic Tac Toe")
31 STORE("descrHdr", "Tic-Tac-Toe is a classic two-player game where players take turns marking a 3x3 grid with 'X' or 'O'. The goal is to get three of your marks in a row—horizontally, vertically, or diagonally—before your opponent does. If all spaces are filled without a winner, the game ends in a draw. This version allows player versus player, or player versus bot.")
32 STORE("iconURLHdr", "")
33 STORE("dURL", "tic_tac_toe.tela")
40 STORE("DOC1", "f4771e1c38dfeb868d8e4ddb7ea77c90b0cc328f78d082fb305500e7d8cbe78b")
41 STORE("DOC2", "ccfab3cc08333211bcf9a04b0b7c8518b51d81b38229f674821a34eab123d3ef")
1000 RETURN 0
End Function
Function init() Uint64
10 IF EXISTS("owner") == 0 THEN GOTO 30
20 RETURN 1
30 STORE("owner", address())
50 STORE("telaVersion", "1.0.0")
60 STORE("commit", 0)
70 STORE(0, HEX(TXID()))
80 STORE("hash", HEX(TXID()))
85 STORE("likes", 0)
90 STORE("dislikes", 0)
100 RETURN 0
End Function
Function address() String
10 DIM s as String
20 LET s = SIGNER()
30 IF IS_ADDRESS_VALID(s) THEN GOTO 50
40 RETURN "anon"
50 RETURN ADDRESS_STRING(s)
End Function
Function Rate(r Uint64) Uint64
10 DIM addr as String
15 LET addr = address()
16 IF r < 100 && EXISTS(addr) == 0 && addr != "anon" THEN GOTO 30
20 RETURN 1
30 STORE(addr, ""+r+"_"+BLOCK_HEIGHT())
40 IF r < 50 THEN GOTO 70
50 STORE("likes", LOAD("likes")+1)
60 RETURN 0
70 STORE("dislikes", LOAD("dislikes")+1)
100 RETURN 0
End Function
Function UpdateCode(code String) Uint64
10 IF LOAD("owner") == "anon" THEN GOTO 20
15 IF code == "" THEN GOTO 20
16 IF LOAD("owner") == address() THEN GOTO 30
20 RETURN 1
30 UPDATE_SC_CODE(code)
40 STORE("commit", LOAD("commit")+1)
50 STORE(LOAD("commit"), HEX(TXID()))
60 STORE("hash", HEX(TXID()))
100 RETURN 0
End Function |
SC Arguments: [Name:SC_ACTION Type:uint64 Value:'1' Name:SC_CODE Type:string Value:'Function InitializePrivate() Uint64
10 IF init() == 0 THEN GOTO 30
20 RETURN 1
30 STORE("nameHdr", "Tic Tac Toe")
31 STORE("descrHdr", "Tic-Tac-Toe is a classic two-player game where players take turns marking a 3x3 grid with 'X' or 'O'. The goal is to get three of your marks in a row—horizontally, vertically, or diagonally—before your opponent does. If all spaces are filled without a winner, the game ends in a draw. This version allows player versus player, or player versus bot.")
32 STORE("iconURLHdr", "")
33 STORE("dURL", "tic_tac_toe.tela")
40 STORE("DOC1", "f4771e1c38dfeb868d8e4ddb7ea77c90b0cc328f78d082fb305500e7d8cbe78b")
41 STORE("DOC2", "ccfab3cc08333211bcf9a04b0b7c8518b51d81b38229f674821a34eab123d3ef")
1000 RETURN 0
End Function
Function init() Uint64
10 IF EXISTS("owner") == 0 THEN GOTO 30
20 RETURN 1
30 STORE("owner", address())
50 STORE("telaVersion", "1.0.0")
60 STORE("commit", 0)
70 STORE(0, HEX(TXID()))
80 STORE("hash", HEX(TXID()))
85 STORE("likes", 0)
90 STORE("dislikes", 0)
100 RETURN 0
End Function
Function address() String
10 DIM s as String
20 LET s = SIGNER()
30 IF IS_ADDRESS_VALID(s) THEN GOTO 50
40 RETURN "anon"
50 RETURN ADDRESS_STRING(s)
End Function
Function Rate(r Uint64) Uint64
10 DIM addr as String
15 LET addr = address()
16 IF r < 100 && EXISTS(addr) == 0 && addr != "anon" THEN GOTO 30
20 RETURN 1
30 STORE(addr, ""+r+"_"+BLOCK_HEIGHT())
40 IF r < 50 THEN GOTO 70
50 STORE("likes", LOAD("likes")+1)
60 RETURN 0
70 STORE("dislikes", LOAD("dislikes")+1)
100 RETURN 0
End Function
Function UpdateCode(code String) Uint64
10 IF LOAD("owner") == "anon" THEN GOTO 20
15 IF code == "" THEN GOTO 20
16 IF LOAD("owner") == address() THEN GOTO 30
20 RETURN 1
30 UPDATE_SC_CODE(code)
40 STORE("commit", LOAD("commit")+1)
50 STORE(LOAD("commit"), HEX(TXID()))
60 STORE("hash", HEX(TXID()))
100 RETURN 0
End Function'] |