-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathnatures.go
More file actions
66 lines (54 loc) · 2.08 KB
/
natures.go
File metadata and controls
66 lines (54 loc) · 2.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
package natures
import (
"flag"
"fmt"
"os"
"strings"
"github.com/charmbracelet/lipgloss"
"github.com/charmbracelet/lipgloss/table"
"github.com/digitalghost-dev/poke-cli/cmd/utils"
"github.com/digitalghost-dev/poke-cli/styling"
)
func NaturesCommand() (string, error) {
var output strings.Builder
flag.Usage = func() {
helpMessage := styling.HelpBorder.Render(
"Get details about all natures.\n\n",
styling.StyleBold.Render("USAGE:"),
fmt.Sprintf("\n\t%s %s", "poke-cli", styling.StyleBold.Render("natures")),
)
output.WriteString(helpMessage)
}
if utils.CheckHelpFlag(&output, flag.Usage) {
return output.String(), nil
}
flag.Parse()
if err := utils.ValidateArgs(os.Args, utils.Validator{MaxArgs: 3, CmdName: "natures", RequireName: false, HasFlags: false}); err != nil {
output.WriteString(err.Error())
return output.String(), err
}
output.WriteString("Natures affect the growth of a Pokémon.\n" +
"Each nature increases one of its stats by 10% and decreases one by 10%.\n" +
"Five natures increase and decrease the same stat and therefore have no effect.\n\n" +
styling.StyleBold.Render("Nature Chart:") + "\n")
chart := [][]string{
{" ", styling.Red.Render("-Attack"), styling.Red.Render("-Defense"), styling.Red.Render("-Sp. Atk"), styling.Red.Render("-Sp. Def"), styling.Red.Render("Speed")},
{styling.Green.Render("+Attack"), "Hardy", "Lonely", "Adamant", "Naughty", "Brave"},
{styling.Green.Render("+Defense"), "Bold", "Docile", "Impish", "Lax", "Relaxed"},
{styling.Green.Render("+Sp. Atk"), "Modest", "Mild", "Bashful", "Rash", "Quiet"},
{styling.Green.Render("+Sp. Def"), "Calm", "Gentle", "Careful", "Quirky", "Sassy"},
{styling.Green.Render("Speed"), "Timid", "Hasty", "Jolly", "Naive", "Serious"},
}
t := table.New().
Border(lipgloss.NormalBorder()).
BorderStyle(lipgloss.NewStyle().Foreground(styling.Gray)).
BorderRow(true).
BorderColumn(true).
Rows(chart...).
StyleFunc(func(row, col int) lipgloss.Style {
return lipgloss.NewStyle().
Padding(0, 1)
})
output.WriteString(t.Render() + "\n")
return output.String(), nil
}