diff options
| author | historia <[not public]> | 2026-06-20 03:20:01 -0400 |
|---|---|---|
| committer | historia <[not public]> | 2026-06-20 03:20:01 -0400 |
| commit | e4400c5f1e84c18d2126f2cb502ae10685977cbb (patch) | |
| tree | 0523e9d68f1cfdc6f81b862e3068fe12c1a85054 /internal/game/sys_science.go | |
| parent | 5ea082ab4e82409aebc889b496f43e52b003d4f7 (diff) | |
| download | thehouseoficarus-e4400c5f1e84c18d2126f2cb502ae10685977cbb.tar.gz | |
refactor: combined all station crafting
Diffstat (limited to 'internal/game/sys_science.go')
| -rw-r--r-- | internal/game/sys_science.go | 32 |
1 files changed, 29 insertions, 3 deletions
diff --git a/internal/game/sys_science.go b/internal/game/sys_science.go index e35105a..376d7c7 100644 --- a/internal/game/sys_science.go +++ b/internal/game/sys_science.go @@ -9,6 +9,7 @@ import ( "gopkg.in/yaml.v3" "thehouseoficarus/internal/action" + "thehouseoficarus/internal/net" "thehouseoficarus/internal/object" "thehouseoficarus/internal/player" ) @@ -182,7 +183,7 @@ func (g *Game) hasDeckEquipped(p *player.Player) bool { return def.WeaponType == object.WeaponScience } -func (g *Game) equippedProvidesJunk(p *player.Player) string { +func (g *Game) providesJunk(p *player.Player) string { itemID, ok := p.Equipment[object.SlotMainHand] if !ok { return "" @@ -206,7 +207,7 @@ func (g *Game) effectiveJunkCost(p *player.Player, mod *ModDef) map[string]int { delete(cost, "scrap_metal") } - providesJunk := g.equippedProvidesJunk(p) + providesJunk := g.providesJunk(p) if providesJunk != "" { delete(cost, providesJunk) } @@ -235,6 +236,31 @@ func (g *Game) consumeJunkCost(p *player.Player, mod *ModDef) bool { return true } +func (g *Game) triggerModReward(sess *net.Session, p *player.Player, mod *ModDef, multiplier float64, extraGains ...xpGain) int { + g.consumeJunkCost(p, mod) + + sciXP := int(float64(mod.BaseXP) * multiplier) + if sciXP < 1 { + sciXP = 1 + } + g.awardSkillXP(sess, p, player.Science, sciXP) + + for _, gain := range extraGains { + g.awardSkillXP(sess, p, player.SkillName(gain.Skill), gain.XP) + } + + g.AccountStore.SaveCharacter(p) + + if p.OptionBool("xp_drops") { + parts := []string{fmt.Sprintf("+%dxp %s", sciXP, player.SkillAbbr[player.Science])} + for _, gain := range extraGains { + parts = append(parts, fmt.Sprintf("+%dxp %s", gain.XP, player.SkillAbbr[player.SkillName(gain.Skill)])) + } + sess.WriteLine(g.colorize(sess, "xp", "("+strings.Join(parts, ", ")+")")) + } + return sciXP +} + func (g *Game) junkCostString(p *player.Player, mod *ModDef) string { cost := g.effectiveJunkCost(p, mod) delete(cost, "scrap_metal") @@ -259,7 +285,7 @@ func (g *Game) junkCostString(p *player.Player, mod *ModDef) string { return strings.Join(parts, ", ") } -func (g *Game) totalEquipScienceAttack(p *player.Player) int { +func (g *Game) totalScienceAttack(p *player.Player) int { total := 0 for _, itemID := range p.Equipment { def, err := g.ItemStore.Load(itemID) |
