Skip to content

Commit

Permalink
Progress
Browse files Browse the repository at this point in the history
  • Loading branch information
bobtfish committed Jun 13, 2020
1 parent d5cdb5c commit 9014cf9
Show file tree
Hide file tree
Showing 6 changed files with 582 additions and 3 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
mayhem
39 changes: 39 additions & 0 deletions character.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
package main

import (
"gopkg.in/yaml.v2"
"io/ioutil"
)

type Character struct {
Name string `yaml:"name"`
Combat int `yaml:"combat"`
RangedCombat int `yaml:"ranged_combat"`
Range int `yaml:"range"`
Defence int `yaml:"defence"`
Movement int `yaml:"movement"`
MagicalResistance int `yaml:"magical_resistance"`
Manoeuvre int `yaml:"manoeuvre"`
Unknown int `yaml:"unknown"`
LawChaos int `yaml:"law_chaos"`
Strength int `yaml:"strength"`
}

type CharacterTypes map[string]Character

func LoadCharacters(fn string) CharacterTypes {
yamlFile, err := ioutil.ReadFile(fn)
if err != nil {
panic(err)
}
cl := make([]Character, 0)
err = yaml.Unmarshal(yamlFile, &cl)
if err != nil {
panic(err)
}
ct := make(CharacterTypes, 0)
for _, v := range cl {
ct[v.Name] = v
}
return ct
}
Loading

0 comments on commit 9014cf9

Please sign in to comment.