MCPcopy Create free account
hub / github.com/GoMudEngine/GoMud / TrainSkill

Method TrainSkill

internal/scripting/actor_func.go:338–364  ·  view source on GitHub ↗
(skillName string, skillLevel int)

Source from the content-addressed store, hash-verified

336}
337
338func (a ScriptActor) TrainSkill(skillName string, skillLevel int) bool {
339
340 if a.userRecord == nil {
341 return false
342 }
343
344 skillName = strings.ToLower(skillName)
345 currentLevel := a.characterRecord.GetSkillLevel(skills.SkillTag(skillName))
346
347 if currentLevel < skillLevel {
348 newLevel := a.characterRecord.TrainSkill(skillName, skillLevel)
349
350 skillData := struct {
351 SkillName string
352 SkillLevel int
353 }{
354 SkillName: skillName,
355 SkillLevel: newLevel,
356 }
357 skillUpTxt, _ := templates.Process("character/skillup", skillData, a.userRecord.UserId)
358 a.SendText(skillUpTxt)
359
360 return true
361
362 }
363 return false
364}
365
366func (a ScriptActor) GetSkillLevel(skillName string) int {
367 return a.characterRecord.GetSkillLevel(skills.SkillTag(skillName))

Callers

nothing calls this directly

Calls 4

SendTextMethod · 0.95
SkillTagTypeAlias · 0.92
ProcessFunction · 0.92
GetSkillLevelMethod · 0.45

Tested by

no test coverage detected