|
@@ -1,7 +1,6 @@
|
|
|
package main
|
|
|
|
|
|
import (
|
|
|
- "database/sql"
|
|
|
"fmt"
|
|
|
"math/rand"
|
|
|
"os"
|
|
@@ -302,10 +301,12 @@ func panel_demo(d *door.Door) {
|
|
|
d.Write(p.Output() + door.CRNL)
|
|
|
}
|
|
|
|
|
|
+/*
|
|
|
func createTable(db *sql.DB) {
|
|
|
db.Exec("CREATE TABLE IF NOT EXISTS settings(username TEXT, setting TEXT, value TEXT, PRIMARY KEY(username, setting));")
|
|
|
db.Exec("CREATE TABLE IF NOT EXISTS scores ( \"username\" TEXT, \"when\" INTEGER, \"date\" INTEGER, \"hand\" INTEGER, \"won\" INTEGER, \"score\" INTEGER, PRIMARY KEY(\"username\", \"date\", \"hand\"));")
|
|
|
}
|
|
|
+*/
|
|
|
|
|
|
func main() {
|
|
|
var message string
|
|
@@ -320,16 +321,54 @@ func main() {
|
|
|
rng := rand.New(mt19937.New())
|
|
|
rng.Seed(time.Now().UnixNano())
|
|
|
|
|
|
- sqliteDatabase, err := sql.Open("sqlite3", "./space-database.db")
|
|
|
- if err != nil {
|
|
|
- fmt.Printf("%#v\n", err)
|
|
|
- }
|
|
|
- defer sqliteDatabase.Close()
|
|
|
- createTable(sqliteDatabase)
|
|
|
+ /*
|
|
|
+ sqliteDatabase, err := sql.Open("sqlite3", "./space-database.db")
|
|
|
+ if err != nil {
|
|
|
+ fmt.Printf("%#v\n", err)
|
|
|
+ }
|
|
|
+ defer sqliteDatabase.Close()
|
|
|
+ createTable(sqliteDatabase)
|
|
|
+ */
|
|
|
d := door.Door{}
|
|
|
|
|
|
d.Init("space-ace")
|
|
|
|
|
|
+ db := DBData{}
|
|
|
+ db.Open("space-database.db")
|
|
|
+ defer db.Close()
|
|
|
+ db.User = d.Config.Real_name // or d.Config.Handle
|
|
|
+
|
|
|
+ var Config map[string]string
|
|
|
+ const config_filename = "space-ace.yaml"
|
|
|
+
|
|
|
+ if FileExists(config_filename) {
|
|
|
+ Config = LoadConfig(config_filename)
|
|
|
+ } else {
|
|
|
+ Config = make(map[string]string)
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ var update_config bool = false
|
|
|
+
|
|
|
+ config_defaults := map[string]string{"hands_per_day": "3",
|
|
|
+ "date_format": "%B %d",
|
|
|
+ "date_score": "%m/%d/%Y",
|
|
|
+ "makeup_per_day": "5",
|
|
|
+ "play_days_ahead": "2",
|
|
|
+ "date_monthly": "%B %Y"}
|
|
|
+
|
|
|
+ // _seed
|
|
|
+
|
|
|
+ for key, value := range config_defaults {
|
|
|
+ if SetConfigDefault(&Config, key, value) {
|
|
|
+ update_config = true
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if update_config {
|
|
|
+ SaveConfig(config_filename, Config)
|
|
|
+ }
|
|
|
+
|
|
|
s := StarField{}
|
|
|
s.Regenerate()
|
|
|
|