Beispiel #1
0
	},
	"c": aAlias("cast"),
	"cast": {
		exec: func(s *Session, arg string) {
			usage := func() {
				s.printError("Usage: cast <spell> [target]")
			}

			spell, targetName := utils.Argify(arg)

			if spell == "" {
				usage()
				return
			}

			var skill types.Skill
			skills := model.GetSkills(s.pc.GetSkills())
			index := utils.BestMatch(spell, skills.Names())

			if index == -1 {
				s.printError("Skill not found")
			} else if index == -2 {
				s.printError("Which skill do you mean?")
			} else {
				skill = skills[index]
			}

			if skill != nil {
				var target types.Character

				if targetName == "" {
Beispiel #2
0
func specificSkillMenu(s *Session, skill types.Skill) {
	utils.ExecMenu(fmt.Sprintf("Skill - %s", skill.GetName()), s, func(menu *utils.Menu) {
		menu.AddAction("e", fmt.Sprintf("Effect - %v", skill.GetEffect()), func() bool {
			return true
		})
		menu.AddAction("p", fmt.Sprintf("Power - %v", skill.GetPower()), func() bool {
			dmg, valid := s.getInt("New power: ", 0, 1000)
			if valid {
				skill.SetPower(dmg)
			}
			return true
		})
		menu.AddAction("c", fmt.Sprintf("Cost - %v", skill.GetCost()), func() bool {
			cost, valid := s.getInt("New cost: ", 0, 1000)
			if valid {
				skill.SetCost(cost)
			}
			return true
		})
		menu.AddAction("v", fmt.Sprintf("Variance - %v", skill.GetVariance()), func() bool {
			variance, valid := s.getInt("New variance: ", 0, 1000)
			if valid {
				skill.SetVariance(variance)
			}
			return true
		})
		menu.AddAction("s", fmt.Sprintf("Speed - %v", skill.GetSpeed()), func() bool {
			speed, valid := s.getInt("New speed: ", 0, 1000)
			if valid {
				skill.SetSpeed(speed)
			}
			return true
		})
		menu.AddAction("d", "Delete", func() bool {
			model.DeleteSkill(skill.GetId())
			return false
		})
	})
}