Skip to content

Commit

Permalink
todo
Browse files Browse the repository at this point in the history
  • Loading branch information
nu50218 committed May 31, 2019
1 parent 63e0b11 commit 5104822
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions pattern/tags.go
Original file line number Diff line number Diff line change
Expand Up @@ -161,9 +161,16 @@ func ConvertTags(message, targetName string, emojiNumber int) string {
// combineMultiplePatterns: 複数のパターンをnumber分ランダムにつなげる
func combineMultiplePatterns(patterns []string, number int) string {
result := ""
// TODO: 同じパターンは使い回さないようにしたほうが自然か?
for i := 0; i < number; i++ {
result += patterns[rand.Intn(len(patterns))]
if number <= len(patterns) {
for i := 0; i < number; i++ {
index := rand.Intn(len(patterns) - i)
result += patterns[index]
patterns[index], patterns[len(patterns)-1-i] = patterns[len(patterns)-1-i], patterns[index]
}
} else {
for i := 0; i < number; i++ {
result += patterns[rand.Intn(len(patterns))]
}
}
return result
}
Expand Down

0 comments on commit 5104822

Please sign in to comment.