aboutsummaryrefslogtreecommitdiff
path: root/internal/game/cmd_stats.go
blob: 69422728a8c11ed5efc884a9eeb360200980a70c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
package game

import (
	"fmt"

	"thehouseoficarus/internal/combat"
	"thehouseoficarus/internal/item"
	"thehouseoficarus/internal/net"
	"thehouseoficarus/internal/player"
)

func (g *Game) executeStats(sess *net.Session, args []string, rawInput string) {
	g.doStats(sess)
}

func (g *Game) doStats(sess *net.Session) {
	p := sess.Player
	totals := g.playerEquipBonuses(p)

	weaponName := "unarmed"
	attackType, weaponType, weaponDef := g.resolvePlayerAttackType(p)
	if weaponDef != nil {
		weaponName = g.itemColorize(sess, weaponDef, weaponDef.Name)
	}
	sess.WriteLines(
		"",
		fmt.Sprintf("Weapon: %s (attack type: %s)", weaponName, attackType),
		"",
		"Attack bonuses:       Defense bonuses:",
		fmt.Sprintf("  Stab:   %+4d          Stab:   %+4d", totals.StabAttack, totals.StabDefense),
		fmt.Sprintf("  Slash:  %+4d          Slash:  %+4d", totals.SlashAttack, totals.SlashDefense),
		fmt.Sprintf("  Crush:  %+4d          Crush:  %+4d", totals.CrushAttack, totals.CrushDefense),
		fmt.Sprintf("  Science:%+4d          Science:%+4d", totals.ScienceAttack, totals.ScienceDefense),
		fmt.Sprintf("  Ranged: %+4d          Ranged: %+4d", totals.RangedAttack, totals.RangedDefense),
		"",
		"Other bonuses:",
		fmt.Sprintf("  Melee strength:  %+d", totals.StrengthBonus),
		fmt.Sprintf("  Ranged strength: %+d", totals.RangedStrength),
		fmt.Sprintf("  Science damage:  %+d", totals.ScienceDamage),
		fmt.Sprintf("  Technology:      %+d", totals.TechnologyBonus),
	)

	var attRoll, maxHitVal int
	if weaponType == item.EquipRangedWeapon {
		rangedBonus, _ := combat.RangedStyleBonus(string(p.AttackStyle))
		attRoll = combat.AttackRoll(combat.PlayerEffective(p.Level(player.Ranged), rangedBonus), totals.RangedAttack)
		maxHitVal = combat.MaxHit(combat.PlayerEffective(p.Level(player.Ranged), rangedBonus), totals.RangedStrength)
	} else {
		attBonus, strBonus, _ := combat.AttackStyleBonus(string(p.AttackStyle))
		equipAtt := combat.SelectBonus(attackType,
			totals.StabAttack, totals.SlashAttack, totals.CrushAttack,
			totals.ScienceAttack, totals.RangedAttack)
		attRoll = combat.AttackRoll(combat.PlayerEffective(p.Level(player.Accuracy), attBonus), equipAtt)
		maxHitVal = combat.MaxHit(combat.PlayerEffective(p.Level(player.Strength), strBonus), totals.StrengthBonus)
	}

	sess.WriteLines(
		"",
		fmt.Sprintf("Style: %s  Attack roll: %d  Max hit: %d",
			p.AttackStyle, attRoll, maxHitVal),
	)
}