Settings

Blockchain
Network
Unit
Language
Theme
Sound New Block

Transaction

cde227d5672b212a837e8dee9c285556e30ca0f4e591802e4526c2ddd73a0ce7
Timestamp (utc)
2022-03-25 16:24:52
Fee Paid
0.00002336 BSV
(
0.00098971 BSV
-
0.00096635 BSV
)
Fee Rate
250.1 sat/KB
Version
1
Confirmations
243,606
Size Stats
9,340 B

3 Outputs

Total Output:
0.00096635 BSV
  • jrun cryptofightsMã"{"in":1,"ref":["b38c3477cc661c65e8a6bf6fa1fd046ef21c6069391f24ccba43a168becd2dac_o1","e5602b14f529aa66499a6dc2b93f7fdf2f091edbbc2b0efd8b2e2161d59b5ca5_o1","5334f688050535806987424ec00ba75b74a2087c8c3945765dd9107ac81af1a7_o1","e2f4d8e09c9835156a2a221aedd8bb04db191d9642573906439bbd889dde40d0_o1","5dc606e8c78f47a10ecb5f8645f2dbe09a3b3a2da87e7e614dcc150203adba1a_o1","870c20f2e1b5f421a3083f749776c059e5bf227d6b2d555f11ffda2306389c56_o1"],"out":["6b0fc19062ddd71817438899d89730cb9eb562842ab4bab0ca3e3f44f826179f"],"del":[],"cre":[],"exec":[{"op":"UPGRADE","data":[{"$jig":0},"class Fighter extends FyxJig {\n init(owner, race, abilityScores, appearance, metadata = {}) {\n Fighter.validateStartingScores(race, abilityScores);\n this.race = race;\n this.abilityScores = abilityScores;\n this.appearance = appearance;\n this.metadata = {\n ...metadata,\n publisher: 'FYX'\n };\n\n this.pvpBattlesFought = 0;\n this.pvpBattlesWon = 0;\n this.pveBattlesFought = 0;\n this.pveBattlesWon = 0;\n this.xp = 0;\n this.level = 1;\n\n this.skills = [\n Constants.SkillType.Attack,\n Constants.SkillType.Focus,\n Constants.SkillType.Hide,\n Fighter.initialSkills[race]\n ];\n\n this.levelUpHpBonusDice = [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]; \n this.levelUpHpBonusModifiers = [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0];\n\n this.owner = owner;\n }\n\n setSatoshis(satoshis) {\n this.satoshis = satoshis;\n }\n\n static validateStartingScores(race, abilityScores) {\n const costs = {\n 1: 1,\n 2: 2,\n 3: 4,\n 4: 7,\n 5: 11,\n 6: 16\n };\n\n let cost = 0;\n abilityScores.forEach((score, ability) => {\n const start = Fighter.initialScores[race][ability];\n const upgrade = score - start;\n if (upgrade < 0) throw new Error('Invalid Ability Scores');\n if (upgrade > 0) {\n const points = costs[upgrade];\n if (!points) throw new Error('Invalid Ability Scores');\n cost += points;\n }\n });\n if (cost === 15) return true;\n throw new Error('Invalid Ability Scores');\n }\n\n transfer(recipient) {\n this.owner = recipient;\n }\n\n //Called by all players.\n //Do not change fighters outside here, they can only be updated by the jig owner.\n recordBattle(battle, win)\n {\n if (battle.constructor.owner !== Fighter.owner) throw new Error('Unauthorized battle');\n if (battle.validator !== Config.pubkey) {\n console.log('Validator:', battle.validator);\n console.log('Config.pubkey:', Config.pubkey);\n throw new Error('Unauthorized validator');\n }\n\n if (win) {\n if (battle.victor.fighter !== this) throw new Error('Stolen Valor!');\n if (battle.rules) {\n if (battle.rules.playerCount !== 1) { \n this.pvpBattlesFought = (this.pvpBattlesFought || 0) + 1;\n this.pvpBattlesWon = (this.pvpBattlesWon || 0) + 1;\n }\n else\n {\n this.pveBattlesFought = (this.pvpBattlesFought || 0) + 1;\n this.pveBattlesWon = (this.pveBattlesWon || 0) + 1;\n } \n }\n this.xp += battle.xp;\n this.diceSeed = battle.random;\n battle.destroy();\n }\n else\n {\n if (battle.rules)\n {\n if (battle.rules.playerCount !== 1) {\n this.pvpBattlesFought = (this.pvpBattlesFought || 0) + 1;\n }\n else\n {\n this.pveBattlesFought = (this.pvpBattlesFought || 0) + 1;\n }\n }\n }\n }\n\n levelUp(ability, skillType) {\n const reqXp = Constants.XPTable[this.level];\n\n if (this.xp < reqXp) {\n throw new Error(`Inadequate XP fighter has ${this.xp}, ${reqXp} is required.`);\n }\n this.level++;\n if(this.level == 7 && this.race == Constants.Race.Human) {\n this.skills.push(Constants.SkillType.ReTrain);\n }\n this.xp -= reqXp;\n if (Constants.SkillLevels.includes(this.level)) {\n if (!skillType) {\n throw new Error('Requested skill at Index ' + skillType + ' is not found!');\n }\n let skillInfo = Constants.SkillData[skillType];\n if ((this.level - 1) < skillInfo.requiredLevel) {\n throw new Error(`Player doesn't meet skill level up requirements to unlock ${skillType}. Player is low level`);\n }\n skillInfo.requiredSkills.forEach(st => {\n if (!this.skills.includes(st)) {\n throw new Error(`Player doesn't meet skill level up requirements unlock ${skillType}. Missing ${st}`);\n }\n });\n\n this._applySkill(skillType);\n skillInfo.unlockableSkills.forEach(st => {\n this._applySkill(st);\n });\n }\n\n if (Constants.AbilityScoreLevels.includes(this.level)) {\n this.abilityScores[ability]++;\n }\n \n if(this.diceSeed == null){\n console.log(`Uninitialized dice seed, using fighter location`);\n this.diceSeed = this.location;\n }\n const dice = new Dice(this.diceSeed);\n this.diceSeed = Sha256.hashToHex(this.diceSeed);\n\n const strMod = parseInt(KronoMath.floor((this.abilityScores[0] - 10) / 2));\n if(!this.levelUpHpBonusDice) {\n this.levelUpHpBonusDice = [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0];\n }\n if(this.levelUpHpBonusDice.length < this.level) {\n for(let i = this.levelUpHpBonusDice.length; i < this.level; i++) {\n this.levelUpHpBonusDice.push(0);\n }\n }\n this.levelUpHpBonusDice[this.level-1] = dice.roll(1,4);\n\n if(!this.levelUpHpBonusModifiers) {\n this.levelUpHpBonusModifiers = [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0];\n }\n if(this.levelUpHpBonusModifiers.length < this.level) {\n for(let i = this.levelUpHpBonusModifiers.length; i < this.level; i++) {\n this.levelUpHpBonusModifiers.push(0);\n }\n }\n this.levelUpHpBonusModifiers[this.level-1] = strMod;\n }\n\n\n rerollHp(level) {\n const reqXp = KronoMath.floor(Constants.XPTable[level] * Constants.RespecCost);\n\n if (this.xp < reqXp) {\n throw new Error(`Inadequate XP fighter has ${this.xp}, ${reqXp} is required.`);\n }\n \n this.xp -= reqXp;\n \n if(!this.diceSeed){\n console.log(`Uninitialized dice seed, using fighter location`);\n this.diceSeed = this.location;\n }\n const dice = new Dice(this.diceSeed);\n this.diceSeed = Sha256.hashToHex(this.diceSeed);\n\n const strMod = parseInt(KronoMath.floor((this.abilityScores[0] - 10) / 2));\n if(this.levelUpHpBonusDice === null || !this.levelUpHpBonusDice || this.levelUpHpBonusDice.length < this.level){\n this.levelUpHpBonusDice = [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0];\n }\n this.levelUpHpBonusDice[level] = dice.roll(1,4);\n\n if(this.levelUpHpBonusModifiers === null || !this.levelUpHpBonusModifiers || this.levelUpHpBonusModifiers.length < this.level){\n this.levelUpHpBonusModifiers = [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0];\n }\n this.levelUpHpBonusModifiers[level] = strMod;\n }\n\n static floor(value)\n {\n return value>0 ? value >> 0 : (value -.5) >> 0;\n }\n\n _applySkill(skillType) {\n // TODO validate prerequesite for skillType\n this.skills.push(skillType);\n }\n\n static async deploy (deployer, prev) {\n if(!prev) {\n console.log('Deploying');\n return deployer.run.deploy(Fighter);\n } else {\n console.log('Upgrading');\n prev.upgrade(Fighter);\n await prev.sync();\n return prev;\n }\n }\n}",{"deps":{"Config":{"$jig":1},"Constants":{"$jig":2},"Dice":{"$jig":3},"FyxJig":{"$jig":4},"KronoMath":{"$jig":5},"Sha256":{"$jig":6}},"hash":"bc8d0322932b2053345e5936af11e968b339e6c3314b304f2ab4b7c6fecae273","initialScores":{"0":[8,8,8],"1":[9,7,7],"2":[7,7,7]},"initialSkills":{"0":33,"1":31,"2":32},"metadata":{"app":"Cryptofights","emoji":"👤","name":"Fighter","publisher":"FYX"},"transferrable":true}]}]}
    https://whatsonchain.com/tx/cde227d5672b212a837e8dee9c285556e30ca0f4e591802e4526c2ddd73a0ce7