1package server 2 3import ( 4 "fmt" 5 "slices" 6 7 "tinyadventure/internal/sim" 8) 9 10const ( 11 trapPC = 15 12 cacheBase = 20 13 cachePerLv = 12 14) 15 16var disarmers = []string{"rogue", "ranger"} 17 18func (g *game) visit(x, y int) { 19 for i := range g.state.Map.Landmarks { 20 l := &g.state.Map.Landmarks[i] 21 if l.Used || l.X != x || l.Y != y { 22 continue 23 } 24 l.Used = true 25 switch l.Kind { 26 case "lookout": 27 g.note("From the lookout you see far across the land") 28 case "shrine": 29 g.heal(false) 30 g.note("The shrine's light mends the wounds of the living") 31 case "cache": 32 for i := range g.state.Party.Units { 33 if u := &g.state.Party.Units[i]; !u.Fallen() { 34 sim.Grant(u, cacheBase+cachePerLv*u.Level) 35 } 36 } 37 g.note("An old cache of maps and journals: the party gains experience") 38 } 39 } 40} 41 42func (g *game) spring() { 43 for _, u := range g.state.Party.Units { 44 if slices.Contains(disarmers, u.Class) { 45 g.note(fmt.Sprintf("%s disarms a trap on the chest", u.Name)) 46 return 47 } 48 } 49 for i := range g.state.Party.Units { 50 if u := &g.state.Party.Units[i]; !u.Fallen() { 51 u.Stats.HP = max(1, u.Stats.HP-max(1, sim.Effective(*u).MaxHP*trapPC/100)) 52 } 53 } 54 g.note("A trap springs as the chest opens, wounding the party") 55}