Skip to content

Commit

Permalink
change score
Browse files Browse the repository at this point in the history
  • Loading branch information
Tobias committed Jan 25, 2021
1 parent becd794 commit ca931b1
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 5 deletions.
4 changes: 2 additions & 2 deletions gotrivia.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ var questions []*Question

func init() {
log.Print("init")
q, ok := scanLinesToArray("./questions.txt")
q, ok := scanLinesToArray("/questions.txt")
if !ok {
return
}

a, ok := scanLinesToArray("./answers.txt")
a, ok := scanLinesToArray("/answers.txt")
if !ok {
return
}
Expand Down
2 changes: 1 addition & 1 deletion manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ func (tg *Manager) GetScore(p *Player) {
if player, found := tg.Players[p.Id]; found {
tg.Send(fmt.Sprintf("...::%s Score: %d", p.Name, player.Correct), nil)
} else {
tg.Send("..::Unknown player, 0 answers::..", nil)
tg.Send(fmt.Sprintf("...::%s Score: 0", p.Name), nil)
}
}
// communication
Expand Down
1 change: 0 additions & 1 deletion player.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package GoTrivia


type Player struct {
Id string
Name string
Expand Down
8 changes: 7 additions & 1 deletion utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,16 @@ import (
"bufio"
"log"
"os"
"runtime"
"strings"
)

func scanLinesToArray(p string) (r []string, b bool) {
file, err := os.Open(p)
_, f, _, _ := runtime.Caller(0)
lastOccurrence := strings.LastIndex(f, "/")
dir := f[0:lastOccurrence]

file, err := os.Open(dir + p)
if err != nil {
log.Print(err)
return
Expand Down

0 comments on commit ca931b1

Please sign in to comment.