Advertisement
Guest User

Untitled

a guest
Jul 12th, 2017
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Go 0.69 KB | None | 0 0
  1. package main
  2.  
  3. type Item struct {
  4.     desc  string
  5.     value int
  6. }
  7.  
  8. type Recipe struct {
  9.     name     string
  10.     contents []RecipeItem
  11. }
  12.  
  13. type RecipeItem struct {
  14.     item   Item
  15.     amount int
  16. }
  17.  
  18. func main() {
  19.  
  20.     materials := map[string]Item{
  21.         "Iron": Item{
  22.             desc:  "Common metal",
  23.             value: 10,
  24.         },
  25.  
  26.         "Gold": Item{
  27.             desc:  "Less common metal",
  28.             value: 15,
  29.         },
  30.  
  31.         "Wood": Item{
  32.             desc:  "Common tree stuff",
  33.             value: 2,
  34.         },
  35.     }
  36.  
  37.     recipes := []Recipe{
  38.         Recipe{
  39.             name: "Pickaxe",
  40.             contents: []RecipeItem{
  41.                 RecipeItem{
  42.                     item:   materials["Iron"],
  43.                     amount: 3,
  44.                 },
  45.                 RecipeItem{
  46.                     item:   materials["Wood"],
  47.                     amount: 2,
  48.                 },
  49.             },
  50.         },
  51.     }
  52. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement