1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374 |
- package main
- import (
- "encoding/json"
- "fmt"
- "os"
- )
- func main() {
- /*SetupApp()
- SetupHome()
- HOME.Show()
- APP.Run()*/
- p := Parser{Debug: false}
- root, err := p.Load("Test Dummy.txt")
- if err != nil {
- fmt.Println("parser.load", err)
- return
- }
- /*pay, err := json.MarshalIndent(root, "", " ")
- if err != nil {
- fmt.Println("marshalindent", err)
- return
- }
- err = os.WriteFile("_debug0.json", pay, 0660)
- if err != nil {
- fmt.Println("writefile", err)
- return
- }*/
- me := Profile{}
- err = me.Parse(root)
- if err != nil {
- fmt.Println("profile.parse", err)
- return
- }
- //fmt.Printf("%#v\n", me)
- pay, err := json.MarshalIndent(me, "", " ")
- if err != nil {
- fmt.Println("marshalindent", err)
- return
- }
- err = os.WriteFile("_debug.json", pay, 0660)
- if err != nil {
- fmt.Println("writefile", err)
- return
- }
- me.Ships[0].Attributes.Others["bunks"] = 100
- me.Ships[0].Attributes.Others["cargo space"] = 100
- me.Ships[0].Attributes.Others["required crew"] = 1
- me.Ships[0].Name = "Test Me II"
- me.Ships[0].Hull = int(me.Ships[0].Attributes.Others["hull"])
- me.Ships[0].Shields = int(me.Ships[0].Attributes.Others["shields"])
- me.Ships[0].Fuel = int(me.Ships[0].Attributes.Others["fuel capacity"])
- err = me.Update()
- if err != nil {
- fmt.Println("profile.update", err)
- return
- }
- err = p.Save("+Test Dummy.txt", root)
- if err != nil {
- fmt.Println("parser.save", err)
- return
- }
- pay, err = json.MarshalIndent(me, "", " ")
- if err != nil {
- fmt.Println("marshalindent", err)
- return
- }
- err = os.WriteFile("_debug1.json", pay, 0660)
- if err != nil {
- fmt.Println("writefile", err)
- return
- }
- }
|