package game // Attributes type stat struct { name string short string value int } type attributes struct { health stat strength stat endurance stat dexterity stat wisdom stat intelligence stat } // Levels type level struct { experience int points int } // Inventory type Item struct { name string id int drop int } type Slot struct { amount int content Item } // Player and Non Player Characters type Player struct { name string levels []level money int stats attributes inventory []Slot } type Enemy struct { name string stats attributes loot []Item money int } // Initialization Functions func makeAttributes() attributes { return attributes{ health: stat{ name: "Health", short: "HP", value: 10, }, strength: stat{ name: "Strength", short: "Str", value: 1, }, endurance: stat{ name: "Endurance", short: "End", value: 1, }, dexterity: stat{ name: "Dexterity", short: "Dex", value: 1, }, wisdom: stat{ name: "Wisdom", short: "Wis", value: 1, }, intelligence: stat{ name: "Intelligence", short: "Int", value: 1, }, } } func makeLevelTable() []level { var ourLevels = make([]level, 0, 10) for i := 0; i < 11; i++ { var baseXP int = 100 var ourPoints int = 0 if i > 0 && i%2 == 0 { ourPoints = 5 } else if i > 0 && i%2 == 1 { ourPoints = 4 } ourLevels = append(ourLevels, level{ experience: baseXP*i, points: ourPoints, }) } return ourLevels } func MakeNewPlayer(playerName string) Player { return Player{ name: playerName, levels: makeLevelTable(), money: 0, stats: makeAttributes(), inventory: make([]Slot, 0, 15), } } func MakeNewEnemy(enemyName string) Enemy { return Enemy{ name: enemyName, stats: makeAttributes(), loot: make([]Item, 0, 5), money: 0, } }