Transaction

047c84687ebaa8379c5b60d3ed78a10ed310f47672e3a836b60fc1c455704c9f
( - )
177,240
2021-06-25 12:25:23
1
9,974 B

3 Outputs

Total Output:
  • jrun cryptofightsMñ%{"in":0,"ref":["d6edec4a1c79ea975d3fe3608ddaccb9a3e5d69d908114055c8b7733deb9b134_o1","24da7c843b463f23e1e0cc9a73f4d95202b330194bcc100ee79edc90f78a0f8b_o1","49932fba5a7a47d91cd61007a993eaefaf12b99344ab1240419aab2ab0eed6db_o1","5b259cd9534b3c87b7c205b7f7f62e490535f3b9aec97ae59d6289355b99df15_o1","5334f688050535806987424ec00ba75b74a2087c8c3945765dd9107ac81af1a7_o1","9f0e192f744258c3484a1c19fa88ef68e46ee6cf75acc78cfe2ad5a0d2340d0e_o1","aa2ebcab82c10e20f2f8cb0751fc5e1692252ce71fe3ba62c75a984da7d8e1f9_o1","e2f4d8e09c9835156a2a221aedd8bb04db191d9642573906439bbd889dde40d0_o1","870c20f2e1b5f421a3083f749776c059e5bf227d6b2d555f11ffda2306389c56_o1","f97d4ac2a3d6f5ed09fad4a4f341619dc5a3773d9844ff95c99c5d4f8388de2f_o1","b1fae14b7f53620c8d2354e3e9ba50164b0b4916eead575a1add7026a8373dfa_o1"],"out":["d0046ac6781d478406105faa51b98a303465e34237bae40e6b38a88dd58296b5"],"del":[],"cre":["n2Bd4cWhEQK1aVjb1R7EBGV9mrw3etvSdC"],"exec":[{"op":"DEPLOY","data":["class Battle extends FyxJig {\n init(validator, rules, players, id, timestamp) {\n this.id = this.random = id;\n this.timestamp = timestamp;\n this.rules = rules;\n\n this.battlePlayers = players.map(player => this.joinBattle(player));\n this.battlegroundTier = rules.tier;\n this.dice = new Dice(id);\n this.state = BattleUtils.buildBattleState(this.battlePlayers, this.dice);\n\n this.turnCount = 0;\n\n this.satoshis = rules.reward || 546;\n\n this.stateHash = Sha256.hashToHex(JSON.stringify(this.state));\n this.status = Constants.Status.Open;\n this.stateHistory = [];\n this.actor = players[this.state.playerToAct].userId;\n this.stage = 'created';\n \n this.owner = this.validator = validator;\n\n const tempPlayerToAct = this.state.playerToAct;\n\n for (let i = 0; i < 2; i++) {\n this.state.playerToAct = i;\n let skills = this.battlePlayers[i].fighter.skills;\n if (skills.includes(Constants.SkillType.Shadowy))\n {\n var playerName = BattleUtils.getPrettifiedPlayerName(this, this.state);\n let log = `${playerName} uses <sprite name=\"${BattleUtils.parseSkillName(Constants.SkillType.Hide)}\">${BattleUtils.parseSkillName(Constants.SkillType.Hide)}\\n`;\n this.state.actionLogs.push(BattleUtils.abilityCheckAndApplyStatusEffect(this, this.state, this.dice, Constants.SkillType.Hide\n , Constants.Ability.Dexterity, Constants.Ability.Intelligence, Constants.StatusEffect.Hidden, 99, true, log));\n \n this.state.fighterStates = BattleUtils.computeFighterStates(this, this.state);\n }\n }\n \n this.state.playerToAct = tempPlayerToAct; \n }\n\n joinBattle(player) {\n const { userId, pubkey, owner, items, fighter, skills, tags } = player;\n \n if(this.rules.fee) {\n if (fighter.satoshis < this.rules.fee) throw new Error('Insufficient Fighter Satoshis');\n fighter.setSatoshis(fighter.satoshis - this.rules.fee);\n } else {\n fighter.auth();\n }\n \n items.forEach(item => item && item.auth());\n const [mainhand, offhand, armor, hat, disguise] = items.map(i => i && i.item && FyxClass.deepClone(i.item));\n\n return {\n userId,\n pubkey,\n owner,\n fighter,\n mainhand,\n offhand,\n armor,\n hat,\n disguise,\n skills,\n tags: tags || []\n };\n }\n\n begin(timeout) {\n if (this.stage !== 'created') throw new Error('Invalid Stage');\n this.timeout = timeout;\n delete this.stage;\n }\n\n resolve(random, timestamp, timeout, actionIndex, sig) {\n console.log('Resolve', this.location);\n if (this.status !== Constants.Status.Open) throw new Error('Invalid Status');\n if (!BattleUtils.validateRandom(random, this.random)) throw new Error('Invalid Random');\n this.sig = sig;\n this.random = random;\n \n this.stateHistory[this.turnCount] = this.getState();\n const state = FyxClass.deepClone(this.state);\n state.actionLogs = [];\n this.dice = new Dice(random);\n if (timestamp < this.timeout) {\n if (actionIndex === -1 || actionIndex === undefined) {\n this.state = BattleUtils.skipTurn(this, state, this.dice, timestamp);\n } else {\n const attacker = this.battlePlayers[this.state.playerToAct];\n const skill = attacker.skills[actionIndex];\n if (!skill) throw new Error(`${attacker.fighter.displayName} used an invalid Skill ID: ${actionIndex}`);\n this.state = skill.run(this, state, this.dice, timestamp);\n }\n } else {\n this.state = BattleUtils.skipTurn(this, state, this.dice, timestamp);\n }\n\n this.status = this.state.status;\n this.timestamp = timestamp;\n this.timeout = timeout;\n this._endTurn();\n }\n\n forfeit(message, timestamp) {\n if (this.status !== Constants.Status.Open) throw new Error('Invalid Status');\n this.stateHistory[this.turnCount] = this.getState();\n const playerIndex = this.battlePlayers.findIndex(p => p.userId === message.from);\n const player = this.battlePlayers[playerIndex];\n const victorIndex = this.battlePlayers.findIndex(p => p.userId !== message.from);\n const victor = this.battlePlayers[victorIndex];\n \n const state = FyxClass.deepClone(this.state);\n state.victor = {\n pubkey: victor.pubkey,\n owner: victor.owner,\n fighter: victor.fighter,\n userId: victor.userId\n };\n state.actionLogs = [{\n playerIndex: playerIndex,\n actionLogMessage: `<gradient=!player${playerIndex}-color><b>${player.fighter.metadata.name.toUpperCase()}</b> <gradient=!log-color> Forfeited`\n }];\n state.playerToAct = victorIndex;\n state.status = Constants.Status.Forfeit;\n this.state = state;\n\n this.status = this.state.status;\n this.timestamp = timestamp;\n this._endTurn();\n }\n\n // _endTurn() {\n // this.turnCount++;\n // this.stateHash = Sha256.hashToHex(JSON.stringify(this.state));\n // this.actor = this.battlePlayers[this.state.playerToAct].userId;\n // if (this.status !== Constants.Status.Open) {\n // this.victor = {...this.battlePlayers[this.state.playerToAct]};\n // this.stateHistory[this.turnCount] = this.getState();\n // const victor = this.victor;\n // const loser = this.battlePlayers.find(p => p.userId !== victor.userId);\n // this.xp = Battle.LevelXPReward[loser.fighter.level];\n \n // if (!victor.tags.includes('bot')) {\n // const items = issueRewards(this.dice, this.battlegroundTier);\n // this.rewards = items.map(i => new FyxItem(victor.fighter.owner, i.metadata, i.item, i.satoshis));\n // }\n \n // this.battlePlayers.forEach(player => new BattleToken(player.fighter.owner));\n // this.owner = victor.fighter.owner;\n // this.status = Constants.Status.Finalized;\n // }\n // }\n\n _endTurn() {\n if (this.status !== Constants.Status.Open) {\n this.victor = {...this.battlePlayers[this.state.playerToAct]};\n }\n this.turnCount++;\n this.stateHash = Sha256.hashToHex(JSON.stringify(this.state));\n this.actor = this.battlePlayers[this.state.playerToAct].userId;\n }\n\n finalize() {\n this.stateHistory[this.turnCount] = this.getState();\n if(![Constants.Status.Complete, Constants.Status.Forfeit].includes(this.status)) throw new Error('Invalid Status');\n const victor = this.victor;\n const loser = this.battlePlayers.find(p => p.userId !== victor.userId);\n this.xp = Battle.LevelXPReward[loser.fighter.level];\n \n if (!victor.tags.includes('bot')) {\n const items = issueRewards(this.dice, this.battlegroundTier);\n this.rewards = items.map(i => new FyxItem(victor.fighter.owner, i.metadata, i.item, i.satoshis));\n }\n \n this.battlePlayers.forEach(player => new BattleToken(player.fighter.owner));\n this.owner = victor.fighter.owner;\n this.status = Constants.Status.Finalized;\n }\n \n getState() {\n const state = {\n ...this.state,\n location: this.origin,\n origin: this.origin,\n actor: this.actor,\n battleId: this.id,\n random: this.random,\n stateHash: this.stateHash,\n timestamp: this.timestamp,\n turnCount: this.turnCount,\n timeout: this.timeout,\n battleStatus: this.status\n };\n return state;\n }\n}",{"LevelXPReward":[0,100,200,300,600,1200,2400,0,0,556,713,913,1170,1498,1919,2458,3148,4032,5164,6614,8472],"MaxRounds":100,"deps":{"BattleToken":{"$jig":0},"BattleUtils":{"$jig":1},"Config":{"$jig":2},"Constants":{"$jig":3},"Dice":{"$jig":4},"FyxClass":{"$jig":5},"FyxItem":{"$jig":6},"FyxJig":{"$jig":7},"Sha256":{"$jig":8},"expect":{"$jig":9},"issueRewards":{"$jig":10}},"hash":"c7a3769524df4c82cf7dd311d2deb6163c4b9d9d6b84138573ce1201644a8d2a","metadata":{"app":"Cryptofights","emoji":"⚔","name":"Battle","publisher":"FYX"}}]}]}
    https://whatsonchain.com/tx/047c84687ebaa8379c5b60d3ed78a10ed310f47672e3a836b60fc1c455704c9f