#0
nonstandard
0.00010000 BSV
Q!÷´V ÄKÄÃI&iuG§«ç7ªÏþbçPA3=ä£Q®M¬{"__cls":"class GameContract{\n constructor(pKeyOwner,playerIdOwner,wagerAmount){\n this.gamePlayState = 0;\n this.pubKeyCreator = pKeyOwner;\n this.pubKeyOpponent = null;\n this.creatorId = playerIdOwner;\n this.opponentId = null;\n this.createdAt = new Date().getTime();\n this.updatedAt = new Date().getTime();\n this._amount = wagerAmount;\n this.moves = [];\n this._owners = [pKeyOwner];\n this.wagerState = 0;\n }\n addOpponent(pKey,playerId){\n if(!this.pubKeyOpponent){\n this.pubKeyOpponent = pKey;\n this.opponentId = playerId;\n this.gamePlayState = 1;\n this._owners.push(pKey);\n this.updatedAt = new Date().getTime();\n }\n \n }\n \n closeWager(amount,playerId){\n if(amount === this._amount && playerId === this.opponentId && this.gamePlayState == 1){\n this.wagerState = 1;\n this.updatedAt = new Date().getTime();\n }\n }\n \n isValidPayloadMove(move){\n return (move && (move['playerId'] == this.creatorId || move['playerId'] == this.opponentId) && move['fen']);\n }\n isValidMove(fen){\n var isValid = true;\n if(this.moves[this.moves.length-1]['playerId'] == fen['playerId']){\n isValid = false;\n }\n return isValid;\n }\n addMove(move){\n if(this.isValidPayloadMove(move) && this.isValidMove(move) && this.wagerState == 1 && this.gamePlayState>=1 && this.gamePlayState<6 ){\n \n let wm = this.checkWinningMove(move['fen']);\n \n if(wm['isWiningMove']){\n this.gamePlayState = 6;\n this._owners = [wm['pubKeyWinner']];\n this.updatedAt = new Date().getTime();\n }else{\n let temp = {\n playerId : move['playerId'],\n fen : move['fen'],\n timestamp : new Date().getTime()\n }\n this.moves.push(temp);\n this.updatedAt = new Date().getTime();\n }\n }\n }\n checkWinningMove(fen){\n let kingW = fen.match(/K/gm);\n let kingB = fen.match(/k/gm);\n let returnVal;\n if(!kingW || ! kingB){\n if(!kingW){\n returnVal = {\n isWiningMove : true,\n pubKeyWinner : this.pubKeyOpponent\n }\n }else{\n returnVal = {\n isWiningMove : true,\n pubKeyWinner : this.pubKeyCreator\n }\n }\n }else{\n returnVal = {\n isWiningMove : false\n }\n }\n return returnVal;\n\n }\n \n \n }","__index":{"obj":0},"__func":"constructor","__args":["028ff7b45620c44b8cc4c3044926697547a7abe737aacffe62e75041333d12e4a3","60167b023293b80c7ac444b1",10000]}u
https://whatsonchain.com/tx/41c858f4bbd7b8e582cc09bcac180759cd290910a9673568f7c84b1668b5c1bf