Update balancing display and account for more stats
This commit is contained in:
parent
102853dfd3
commit
97053af6c3
|
@ -1,2 +1 @@
|
|||
# TODO remove once resolved
|
||||
src/rpg-dice-roller.d.ts
|
||||
# eslint ignore list
|
||||
|
|
|
@ -159,16 +159,19 @@ export default class TestingControl extends Vue {
|
|||
this.dodgeMin = 7;
|
||||
this.armorMax = 1;
|
||||
this.speedMin = 10;*/
|
||||
|
||||
this.dataOutput = "<table><tbody>";
|
||||
this.dataOutput = "";
|
||||
this.dataOutput += "<table><tbody>";
|
||||
CharacterData.Heroes.forEach(hero => {
|
||||
this.dataDumps.push(`${hero.id} ${hero.shortName} ${getShortBaseStats(hero)}<br />`);
|
||||
this.dataOutput += `<tr><td>${hero.id}</td><td>${hero.shortName}</td><td>${getShortBaseStats(hero)}</td></tr>`
|
||||
});
|
||||
this.dataOutput += "</tbody></table>";
|
||||
this.dataOutput += "<table><thead><tr><th>Id</th>Short Name<th></th><th>Health</th><th>Melee</th><th>Range</th><th>Magic</th><th>Dodge</th><th>Armor</th><th>Speed</th><th>Points</th><th>Melee Attacks</th><th>Range Attacks</th><th>Magic Attacks</th><th>Preferred Attack</th></tr></thead><tbody>";
|
||||
this.dataOutput += "<h3>Balancing Testing</h3>";
|
||||
this.dataOutput += "<table><thead><tr><th>Id</th>Short Name<th></th><th>Health</th><th>Melee</th><th>Range</th><th>Magic</th><th>Dodge</th><th>Armor</th><th>Speed</th><th>Points</th></tr></thead><tbody>";
|
||||
CharacterData.Heroes.forEach(hero => {
|
||||
this.dataOutput += `<tr><td>${hero.id}</td><td>${hero.shortName}</td><td>${hero.baseStats.health}</td><td>${hero.baseStats.melee.value}</td><td>${hero.baseStats.range.value}</td><td>${hero.baseStats.magic.value}</td><td>${hero.baseStats.dodge}</td><td>${hero.baseStats.armor}</td><td>${hero.baseStats.speed}</td><td>${getBaseStatsPoints(hero.baseStats)}</td><td>${getBaseStatAttacks(hero.baseStats.melee)}</td><td>${getBaseStatAttacks(hero.baseStats.range)}</td><td>${getBaseStatAttacks(hero.baseStats.magic)}</td><td>${attackPreferenceToText(hero.preferredAttack)}</td></tr>`
|
||||
this.dataOutput += `<tr><td rowspan="3" class="balancing-row-id">${hero.id}</td><td rowspan="3" class="balancing-row-id">${hero.shortName}</td><td>${hero.baseStats.health}</td><td>${hero.baseStats.melee.value}</td><td>${hero.baseStats.range.value}</td><td>${hero.baseStats.magic.value}</td><td>${hero.baseStats.dodge}</td><td>${hero.baseStats.armor}</td><td>${hero.baseStats.speed}</td><td rowspan="3">${getBaseStatsPoints(hero.baseStats)}</td></tr>`;
|
||||
this.dataOutput += `<tr><td rowspan="2"></td><td>${getBaseStatAttacks(hero.baseStats.melee)}</td><td>${getBaseStatAttacks(hero.baseStats.range)}</td><td>${getBaseStatAttacks(hero.baseStats.magic)}</td><td colspan="3"></td></tr>`;
|
||||
this.dataOutput += `<tr><td colspan="3">Preferred Attack: ${attackPreferenceToText(hero.preferredAttack)}</td><td colspan="3"></td></tr>`;
|
||||
});
|
||||
this.dataOutput += "</tbody></table>";
|
||||
}
|
||||
|
@ -604,5 +607,8 @@ export default class TestingControl extends Vue {
|
|||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
<style>
|
||||
.balancing-row-id {
|
||||
vertical-align: top;
|
||||
}
|
||||
</style>
|
||||
|
|
|
@ -3,6 +3,9 @@ import Attack from '@/models/Attack';
|
|||
import { AttackPreference } from '@/utilities/Enums';
|
||||
|
||||
export default class CharacterData {
|
||||
/**
|
||||
* Hero character data, used when creating a new hero.
|
||||
*/
|
||||
public static Heroes: CharacterModel[] = [
|
||||
{
|
||||
id: 1,
|
||||
|
@ -81,7 +84,7 @@ export default class CharacterData {
|
|||
value: 0,
|
||||
attacks: []
|
||||
},
|
||||
dodge: 6,
|
||||
dodge: 5,
|
||||
armor: 0,
|
||||
speed: 9
|
||||
},
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import BaseStats from '@/models/BaseStats';
|
||||
import BaseStat from '@/models/BaseStat';
|
||||
import { Parser } from 'rpg-dice-roller';
|
||||
import { Parser, DiceRoller, DiceRoll } from 'rpg-dice-roller';
|
||||
|
||||
/**
|
||||
* Given a set of base stats, determine how many points they total to.
|
||||
|
@ -19,12 +19,28 @@ export function getBaseStatsPoints(baseStats: BaseStats): number {
|
|||
// TODO magic = 0 gives extra points
|
||||
pointTotal += getCombatStatPoints(baseStats.magic.value);
|
||||
|
||||
// Get an extra point for every attack after the first.
|
||||
let attacksModifier = -1;
|
||||
if (baseStats.melee.attacks.length > 0) {
|
||||
attacksModifier++;
|
||||
pointTotal += getBaseAttackPoints(baseStats.melee.attacks[0].damage);
|
||||
}
|
||||
if (baseStats.range.attacks.length > 0) {
|
||||
attacksModifier++;
|
||||
pointTotal += getBaseAttackPoints(baseStats.range.attacks[0].damage);
|
||||
}
|
||||
if (baseStats.magic.attacks.length > 0) {
|
||||
attacksModifier++;
|
||||
pointTotal += getBaseAttackPoints(baseStats.magic.attacks[0].damage);
|
||||
}
|
||||
pointTotal += attacksModifier;
|
||||
|
||||
if (baseStats.dodge !== 6) {
|
||||
pointTotal += 2 * (baseStats.dodge - 6);
|
||||
}
|
||||
|
||||
if (baseStats.armor > 0) {
|
||||
pointTotal += baseStats.armor * 2;
|
||||
pointTotal += baseStats.armor * 3;
|
||||
}
|
||||
|
||||
if (baseStats.speed !== 10) {
|
||||
|
@ -48,9 +64,6 @@ export function getBaseStatAttacks(baseStat: BaseStat): string[] {
|
|||
results.push(attack.damage);
|
||||
console.log(damageSearch.exec(attack.damage));
|
||||
console.log(Parser.parse(attack.damage));
|
||||
console.log(Parser.parse('3d4+2'));
|
||||
console.log(Parser.parse('4d%'));
|
||||
console.log(Parser.parse('dF'));
|
||||
});
|
||||
}
|
||||
return results;
|
||||
|
@ -95,3 +108,16 @@ function getCombatStatPoints(value: number): number {
|
|||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the number of points an attack grants.
|
||||
*
|
||||
* @param attackValue Dice notation for the attack.
|
||||
* @returns Points for an attack value.
|
||||
*/
|
||||
function getBaseAttackPoints(attackValue: string): number {
|
||||
const roller = new DiceRoller();
|
||||
// TODO support characters with multiple attacks? dervish could be 1d6 and 1d4, for example, but would need to roll for hit with each attack
|
||||
const roll: DiceRoll = roller.roll(attackValue) as DiceRoll;
|
||||
return (roll.minTotal - 1) + roll.maxTotal;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue