|
|
@ -14,7 +14,7 @@ type Game struct {
|
|
|
|
func gamesTable() {
|
|
|
|
func gamesTable() {
|
|
|
|
stmnt := `create table if not exists games (
|
|
|
|
stmnt := `create table if not exists games (
|
|
|
|
id integer not null primary key autoincrement,
|
|
|
|
id integer not null primary key autoincrement,
|
|
|
|
start text,
|
|
|
|
start text not null,
|
|
|
|
end text,
|
|
|
|
end text,
|
|
|
|
winner text,
|
|
|
|
winner text,
|
|
|
|
win_method text
|
|
|
|
win_method text
|
|
|
@ -23,3 +23,23 @@ func gamesTable() {
|
|
|
|
log_error("couldn't create games table: %v", err)
|
|
|
|
log_error("couldn't create games table: %v", err)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func NewGame() *Game {
|
|
|
|
|
|
|
|
game := &Game{
|
|
|
|
|
|
|
|
start: time.Now(),
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if err := game.Create(); err != nil {
|
|
|
|
|
|
|
|
log_error("%v", err)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return game
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func (g *Game) Create() error {
|
|
|
|
|
|
|
|
_, err := db.Exec(`
|
|
|
|
|
|
|
|
insert into games
|
|
|
|
|
|
|
|
(start)
|
|
|
|
|
|
|
|
values
|
|
|
|
|
|
|
|
(?)
|
|
|
|
|
|
|
|
;`, g.start)
|
|
|
|
|
|
|
|
return err
|
|
|
|
|
|
|
|
}
|
|
|
|