From 9ca84462fb49f4b32699c649fd649bb32dfb3f91 Mon Sep 17 00:00:00 2001 From: Florian Fischer Date: Fri, 10 Feb 2017 14:30:02 +0100 Subject: cmd: change return value of CmdHelp from string to []string --- logic/cmd.go | 84 ++++++++++++++++++++++++++++++------------------------------ 1 file changed, 42 insertions(+), 42 deletions(-) (limited to 'logic') diff --git a/logic/cmd.go b/logic/cmd.go index 078da36..26a3385 100644 --- a/logic/cmd.go +++ b/logic/cmd.go @@ -93,58 +93,58 @@ func ParseCmd(s string) (Cmd, error) { return Cmd{split[0], argv[0:argc], argc}, nil } -func CmdHelp(cmd int) string { - s := "" +func CmdHelp(cmd int) []string { + s := make([]string, 0, 6) switch cmd { case 1: - s += fmt.Sprintln("d - print dices") - s += fmt.Sprintln("Print out the dices") + s = append(s, fmt.Sprint("d - print dices")) + s = append(s, fmt.Sprint("Print out the dices")) case 2: - s += fmt.Sprintln("p - print score") - s += fmt.Sprintln("Print out your score") + s = append(s, fmt.Sprint("p - print score")) + s = append(s, fmt.Sprint("Print out your score")) case 3: - s += fmt.Sprintln("q - quit the game") - s += fmt.Sprintln("Terminates the game") + s = append(s, fmt.Sprint("q - quit the game")) + s = append(s, fmt.Sprint("Terminates the game")) case 4: - s += fmt.Sprintln("h [cmd] - print help") - s += fmt.Sprintln("Print the help for a specific command or gernal help.") + s = append(s, fmt.Sprint("h [cmd] - print help")) + s = append(s, fmt.Sprint("Print the help for a specific command or gernal help.")) case 5: - s += fmt.Sprintln("i [pos] - insert into score") - s += fmt.Sprintln("Insert your current dices into your score.") - s += fmt.Sprintln("See \"h pos\" for a explenation of the score entries") + s = append(s, fmt.Sprint("i [pos] - insert into score")) + s = append(s, fmt.Sprint("Insert your current dices into your score.")) + s = append(s, fmt.Sprint("See \"h pos\" for a explenation of the score entries")) case 6: - s += fmt.Sprintln("c [pos] - cancel a entry") - s += fmt.Sprintln("Write 0 into your score.") - s += fmt.Sprintln("See \"h pos\" for a explenation of the score entries") + s = append(s, fmt.Sprint("c [pos] - cancel a entry")) + s = append(s, fmt.Sprint("Write 0 into your score.")) + s = append(s, fmt.Sprint("See \"h pos\" for a explenation of the score entries")) case 7: - s += fmt.Sprintln("r [dices] - reroll some dices") - s += fmt.Sprintln("Reroll the specified dices.") - s += fmt.Sprintln("The dices to reroll are represented by a list of their indices in the dice set.") - s += fmt.Sprintln("Example:") - s += fmt.Sprintln("\t\"r 1 4 5\" rerolls dice number 1, 4 and 5") - s += fmt.Sprintln("\t\"r\" rerolls all dices") + s = append(s, fmt.Sprint("r [dices] - reroll some dices")) + s = append(s, fmt.Sprint("Reroll the specified dices.")) + s = append(s, fmt.Sprint("The dices to reroll are represented by a list of their indices in the dice set.")) + s = append(s, fmt.Sprint("Example:")) + s = append(s, fmt.Sprint("\t\"r 1 4 5\" rerolls dice number 1, 4 and 5")) + s = append(s, fmt.Sprint("\t\"r\" rerolls all dices")) case 8: - s += fmt.Sprintln("Positions:") - s += fmt.Sprintln("\t1: Aces") - s += fmt.Sprintln("\t2: Twos") - s += fmt.Sprintln("\t3: Threes") - s += fmt.Sprintln("\t4: Fours") - s += fmt.Sprintln("\t5: Fives") - s += fmt.Sprintln("\t6: Sixes") - s += fmt.Sprintln("\t7: ThreeOfAKind") - s += fmt.Sprintln("\t8: FourOfAKind") - s += fmt.Sprintln("\t9: FullHouse") - s += fmt.Sprintln("\t10: SmallStraight") - s += fmt.Sprintln("\t11: LargeStraight") - s += fmt.Sprintln("\t12: Yahtzee") - s += fmt.Sprintln("\t13: Chance") + s = append(s, fmt.Sprint("Positions:")) + s = append(s, fmt.Sprint("1: Aces")) + s = append(s, fmt.Sprint("2: Twos")) + s = append(s, fmt.Sprint("3: Threes")) + s = append(s, fmt.Sprint("4: Fours")) + s = append(s, fmt.Sprint("5: Fives")) + s = append(s, fmt.Sprint("6: Sixes")) + s = append(s, fmt.Sprint("7: ThreeOfAKind")) + s = append(s, fmt.Sprint("8: FourOfAKind")) + s = append(s, fmt.Sprint("9: FullHouse")) + s = append(s, fmt.Sprint("10: SmallStraight")) + s = append(s, fmt.Sprint("11: LargeStraight")) + s = append(s, fmt.Sprint("12: Yahtzee")) + s = append(s, fmt.Sprint("13: Chance")) default: - s += fmt.Sprintln("h [cmd] - print help") - s += fmt.Sprintln("p - print score") - s += fmt.Sprintln("d - print dices") - s += fmt.Sprintln("i [pos] - insert into score") - s += fmt.Sprintln("r [dices] - reroll some dices") - s += fmt.Sprintln("c [pos] - cancel a entry") + s = append(s, fmt.Sprint("h [cmd] - print help")) + s = append(s, fmt.Sprint("p - print score")) + s = append(s, fmt.Sprint("d - print dices")) + s = append(s, fmt.Sprint("i [pos] - insert into score")) + s = append(s, fmt.Sprint("r [dices] - reroll some dices")) + s = append(s, fmt.Sprint("c [pos] - cancel a entry")) } return s } -- cgit v1.2.3