/** * @param {Technique} technique * @param {Monster} user * @param {Monster} target * * @returns {number} */ function simpleDamageCalculation (technique, user, target) { if (technique.power === 0) { return 0; } let userBaseStrength = user.level + 7; let userStrength = 1; let targetResist = 1; if (technique.range === TechniqueRange.melee) { userStrength = userBaseStrength * user.stats.melee; targetResist = target.stats.armour; } else if (technique.range === TechniqueRange.touch) { userStrength = userBaseStrength * user.stats.melee; targetResist = target.stats.dodge; } else if (technique.range === TechniqueRange.ranged) { userStrength = userBaseStrength * user.stats.ranged; targetResist = target.stats.dodge; } else if (technique.range === TechniqueRange.reach) { userStrength = userBaseStrength * user.stats.ranged; targetResist = target.stats.armour; } else if (technique.range === TechniqueRange.reliable) { userStrength = userBaseStrength; targetResist = 1; } const multiplier = simpleDamageMultiplier(technique.types, target.types); const moveStrength = technique.power * multiplier; const damage = Math.floor((userStrength * moveStrength) / targetResist); return Math.max(damage, 1); } /** * @param {(ElementType[]|string[])} techniqueTypes * @param {(ElementType[]|string[])} targetTypes * * @returns {number} */ function simpleDamageMultiplier (techniqueTypes, targetTypes) { let multiplier = 1; for (const techniqueType of techniqueTypes) { if (techniqueType === ElementType.aether) { continue; } for (const targetType of targetTypes) { if (targetType === ElementType.aether) { continue; } multiplier *= DB.elements[techniqueType].types.find((type) => type.against === targetType).multiplier; } } return Math.max(0.25, Math.min(multiplier, 4)); } /** * @param {Monster} opposingMonster * @param {Monster[]} participants * * @returns {number[]} */ function calculateAwardedExperience (opposingMonster, participants) { const awardedExperienceDistribution = []; for (const participantIndex in participants) { const participant = participants[participantIndex]; const awardedExperience = Math.max( Math.floor( opposingMonster.getExperienceRequired(-1) / opposingMonster.level * opposingMonster.experienceModifier / participant.level ), 1 ); awardedExperienceDistribution[participantIndex] = awardedExperience; } return awardedExperienceDistribution; }