package game import ( "fmt" "thehouseoficarus/internal/combat" "thehouseoficarus/internal/net" "thehouseoficarus/internal/object" "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) attackType := "crush" weaponName := "unarmed" var weaponType object.WeaponType var weaponDef *object.ItemDef if itemID, ok := p.Equipment[object.SlotMainHand]; ok { if def, err := g.ItemStore.Load(itemID); err == nil { weaponDef = def weaponName = def.Name weaponType = def.WeaponType if def.AttackType != "" { attackType = def.AttackType } else if def.WeaponType == object.WeaponRanged { attackType = "ranged" } else if def.WeaponType == object.WeaponScience { attackType = "science" } } } if weaponDef != nil { weaponName = g.itemColorize(sess, weaponDef, weaponName) } 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 == object.WeaponRanged { rangedBonus, _ := combat.RangedStyleBonus(string(p.AttackStyle)) attRoll = combat.AttackRoll(p.Level(player.Ranged), rangedBonus, totals.RangedAttack) maxHitVal = combat.MaxHit(p.Level(player.Ranged), rangedBonus, totals.RangedStrength) } else { attBonus, strBonus, _ := combat.AttackStyleBonus(string(p.AttackStyle)) equipAtt := combat.SelectAttackBonus(attackType, totals.StabAttack, totals.SlashAttack, totals.CrushAttack, totals.ScienceAttack, totals.RangedAttack) attRoll = combat.AttackRoll(p.Level(player.Attack), attBonus, equipAtt) maxHitVal = combat.MaxHit(p.Level(player.Strength), strBonus, totals.StrengthBonus) } sess.WriteLines( "", fmt.Sprintf("Style: %s Attack roll: %d Max hit: %d", p.AttackStyle, attRoll, maxHitVal), ) }