aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFlorian Fischer <florian.fl.fischer@fau.de>2017-02-10 14:30:02 +0100
committerFlorian Fischer <florian.fl.fischer@fau.de>2017-02-10 14:30:02 +0100
commit9ca84462fb49f4b32699c649fd649bb32dfb3f91 (patch)
tree15931b03debde63886821079491641523196a1de
parent7ed9825ea766672ba6fa05987b868cb3ab131185 (diff)
downloadgoffel-9ca84462fb49f4b32699c649fd649bb32dfb3f91.tar.gz
goffel-9ca84462fb49f4b32699c649fd649bb32dfb3f91.zip
cmd: change return value of CmdHelp from string to []string
-rw-r--r--logic/cmd.go84
1 files changed, 42 insertions, 42 deletions
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
}