mirror of
https://gitlab.com/EternalWanderer/sheet-parser.git
synced 2024-11-28 21:13:51 +01:00
Initial commit
This commit is contained in:
commit
579dfc40d9
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
sheet-parser
|
3
README.md
Normal file
3
README.md
Normal file
|
@ -0,0 +1,3 @@
|
|||
# Sheet Parser
|
||||
|
||||
An attempt at creating a system for (at the monent) parsing JSON D&D character sheets.
|
5
go.mod
Normal file
5
go.mod
Normal file
|
@ -0,0 +1,5 @@
|
|||
module gitlab.com/EternalWanderer/sheet-parser/v2
|
||||
|
||||
go 1.19
|
||||
|
||||
require gitlab.com/EternalWanderer/dice-roller v0.0.0-20220819131953-2d560c42a087 // indirect
|
4
go.sum
Normal file
4
go.sum
Normal file
|
@ -0,0 +1,4 @@
|
|||
gitlab.com/EternalWanderer/dice-roller v0.0.0-20220819100404-bed2f3df016e h1:pPt+f195MjWCtUITpZ65rNB/X+M9S3UiP8A1jCSwiXQ=
|
||||
gitlab.com/EternalWanderer/dice-roller v0.0.0-20220819100404-bed2f3df016e/go.mod h1:SNEEOhMarhxX2gBUZ4RIDgEvlKaZorPKfhaqpD09/bs=
|
||||
gitlab.com/EternalWanderer/dice-roller v0.0.0-20220819131953-2d560c42a087 h1:0UCn74xm94G26W+6/LNb+Zc2dFFHKVgCVhVgam4zw/A=
|
||||
gitlab.com/EternalWanderer/dice-roller v0.0.0-20220819131953-2d560c42a087/go.mod h1:SNEEOhMarhxX2gBUZ4RIDgEvlKaZorPKfhaqpD09/bs=
|
67
main.go
Normal file
67
main.go
Normal file
|
@ -0,0 +1,67 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"flag"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"math/rand"
|
||||
"os"
|
||||
"time"
|
||||
|
||||
"gitlab.com/EternalWanderer/dice-roller/Dice"
|
||||
)
|
||||
|
||||
var (
|
||||
path string
|
||||
modifier, diceThrows, surfaces int
|
||||
char Character
|
||||
)
|
||||
|
||||
func isError(err error) bool {
|
||||
if err != nil {
|
||||
fmt.Println(err.Error())
|
||||
}
|
||||
return (err != nil)
|
||||
}
|
||||
func parseFlags() {
|
||||
flag.StringVar(&path, "file", "stats.json", "fock me")
|
||||
flag.Parse()
|
||||
}
|
||||
|
||||
func readJson() {
|
||||
fmt.Println("Opening file...", path)
|
||||
var file, err = os.Open(path)
|
||||
if isError(err) {
|
||||
return
|
||||
}
|
||||
defer file.Close()
|
||||
|
||||
byteValue, _ := ioutil.ReadAll(file)
|
||||
json.Unmarshal(byteValue, &char)
|
||||
}
|
||||
|
||||
func main() {
|
||||
rand.Seed(time.Now().Unix())
|
||||
parseFlags()
|
||||
readJson()
|
||||
|
||||
Dice.SimpleCast()
|
||||
charismaChecks()
|
||||
}
|
||||
|
||||
func charismaChecks() {
|
||||
die := Dice.SimpleCast()
|
||||
proficiencyScore := char.Misc.Proficiency
|
||||
expertiseScore := char.Misc.Proficiency * 2
|
||||
fmt.Println("proficiencyScore:", proficiencyScore)
|
||||
fmt.Println("expertiseScore:", expertiseScore)
|
||||
fmt.Println("die:", die)
|
||||
if char.Skills.Charisma.Intimidation.Expertise {
|
||||
fmt.Printf("%s's Intimidation check results in %d\n", char.Misc.Name, die+char.Skills.Charisma.Intimidation.Modifier+expertiseScore)
|
||||
fmt.Printf("After all, %s has expertise in intimidation\n", char.Misc.Name)
|
||||
} else if char.Skills.Charisma.Intimidation.Proficient {
|
||||
fmt.Printf("%s's Intimidation check results in %d\n", char.Misc.Name, die+char.Skills.Charisma.Intimidation.Modifier+proficiencyScore)
|
||||
fmt.Printf("After all, %s is proficient with intimidation\n", char.Misc.Name)
|
||||
}
|
||||
}
|
160
sheetContent.go
Normal file
160
sheetContent.go
Normal file
|
@ -0,0 +1,160 @@
|
|||
package main
|
||||
|
||||
type Acrobatics struct {
|
||||
Modifier int `json:"modifier"`
|
||||
Proficient bool `json:"proficient"`
|
||||
Expertise bool `json:"expertise"`
|
||||
}
|
||||
type Animal_handling struct {
|
||||
Modifier int `json:"modifier"`
|
||||
Proficient bool `json:"proficient"`
|
||||
Expertise bool `json:"expertise"`
|
||||
}
|
||||
type Arcana struct {
|
||||
Modifier int `json:"modifier"`
|
||||
Proficient bool `json:"proficient"`
|
||||
Expertise bool `json:"expertise"`
|
||||
}
|
||||
type Athletics struct {
|
||||
Modifier int `json:"modifier"`
|
||||
Proficient bool `json:"proficient"`
|
||||
Expertise bool `json:"expertise"`
|
||||
}
|
||||
type Character struct {
|
||||
Misc Misc `json:"misc"`
|
||||
Stats Stats `json:"stats"`
|
||||
Skills Skills `json:"skills"`
|
||||
}
|
||||
type Charisma struct {
|
||||
Score int `json:"score"`
|
||||
Modifier int `json:"modifier"`
|
||||
Proficient bool `json:"proficient"`
|
||||
Deception Deception `json:"deception"`
|
||||
Intimidation Intimidation `json:"intimidation"`
|
||||
Performance Performance `json:"performance"`
|
||||
Persuasion Persuasion `json:"persuasion"`
|
||||
}
|
||||
type Constitution struct {
|
||||
Score int `json:"score"`
|
||||
Modifier int `json:"modifier"`
|
||||
Proficient bool `json:"proficient"`
|
||||
}
|
||||
type Deception struct {
|
||||
Modifier int `json:"modifier"`
|
||||
Proficient bool `json:"proficient"`
|
||||
Expertise bool `json:"expertise"`
|
||||
}
|
||||
type Dexterity struct {
|
||||
Score int `json:"score"`
|
||||
Modifier int `json:"modifier"`
|
||||
Proficient bool `json:"proficient"`
|
||||
Acrobatics Acrobatics `json:"acrobatics"`
|
||||
Sleight_of_hand Sleight_of_hand `json:"sleight_of_hand"`
|
||||
Stealth Stealth `json:"stealth"`
|
||||
}
|
||||
type History struct {
|
||||
Modifier int `json:"modifier"`
|
||||
Proficient bool `json:"proficient"`
|
||||
Expertise bool `json:"expertise"`
|
||||
}
|
||||
type Insight struct {
|
||||
Modifier int `json:"modifier"`
|
||||
Proficient bool `json:"proficient"`
|
||||
Expertise bool `json:"expertise"`
|
||||
}
|
||||
type Intelligence struct {
|
||||
Score int `json:"score"`
|
||||
Modifier int `json:"modifier"`
|
||||
Proficient bool `json:"proficient"`
|
||||
Arcana Arcana `json:"arcana"`
|
||||
History History `json:"history"`
|
||||
Investigation Investigation `json:"investigation"`
|
||||
Nature Nature `json:"nature"`
|
||||
Religion Religion `json:"religion"`
|
||||
}
|
||||
type Intimidation struct {
|
||||
Modifier int `json:"modifier"`
|
||||
Proficient bool `json:"proficient"`
|
||||
Expertise bool `json:"expertise"`
|
||||
}
|
||||
type Investigation struct {
|
||||
Modifier int `json:"modifier"`
|
||||
Proficient bool `json:"proficient"`
|
||||
Expertise bool `json:"expertise"`
|
||||
}
|
||||
type Medicine struct {
|
||||
Modifier int `json:"modifier"`
|
||||
Proficient bool `json:"proficient"`
|
||||
Expertise bool `json:"expertise"`
|
||||
}
|
||||
type Misc struct {
|
||||
Proficiency int `json:"proficiency"`
|
||||
Inspiration int `json:"inspiration"`
|
||||
Level int `json:"level"`
|
||||
Name string `json:"name"`
|
||||
}
|
||||
type Nature struct {
|
||||
Modifier int `json:"modifier"`
|
||||
Proficient bool `json:"proficient"`
|
||||
Expertise bool `json:"expertise"`
|
||||
}
|
||||
type Performance struct {
|
||||
Modifier int `json:"modifier"`
|
||||
Proficient bool `json:"proficient"`
|
||||
Expertise bool `json:"expertise"`
|
||||
}
|
||||
type Persuasion struct {
|
||||
Modifier int `json:"modifier"`
|
||||
Proficient bool `json:"proficient"`
|
||||
Expertise bool `json:"expertise"`
|
||||
}
|
||||
type Religion struct {
|
||||
Modifier int `json:"modifier"`
|
||||
Proficient bool `json:"proficient"`
|
||||
Expertise bool `json:"expertise"`
|
||||
}
|
||||
type Skills struct {
|
||||
Strength Strength `json:"strength"`
|
||||
Dexterity Dexterity `json:"dexterity"`
|
||||
Intelligence Intelligence `json:"intelligence"`
|
||||
Wisdom Wisdom `json:"wisdom"`
|
||||
Charisma Charisma `json:"charisma"`
|
||||
}
|
||||
type Sleight_of_hand struct {
|
||||
Modifier int `json:"modifier"`
|
||||
Proficient bool `json:"proficient"`
|
||||
Expertise bool `json:"expertise"`
|
||||
}
|
||||
type Stats struct {
|
||||
Strength Strength `json:"strength"`
|
||||
Dexterity Dexterity `json:"dexterity"`
|
||||
Constitution Constitution `json:"constitution"`
|
||||
Intelligence Intelligence `json:"intelligence"`
|
||||
Wisdom Wisdom `json:"wisdom"`
|
||||
Charisma Charisma `json:"charisma"`
|
||||
}
|
||||
type Stealth struct {
|
||||
Modifier int `json:"modifier"`
|
||||
Proficient bool `json:"proficient"`
|
||||
Expertise bool `json:"expertise"`
|
||||
}
|
||||
type Strength struct {
|
||||
Score int `json:"score"`
|
||||
Modifier int `json:"modifier"`
|
||||
Proficient bool `json:"proficient"`
|
||||
Athletics Athletics `json:"athletics"`
|
||||
}
|
||||
type Survival struct {
|
||||
Modifier int `json:"modifier"`
|
||||
Proficient bool `json:"proficient"`
|
||||
Expertise bool `json:"expertise"`
|
||||
}
|
||||
type Wisdom struct {
|
||||
Score int `json:"score"`
|
||||
Modifier int `json:"modifier"`
|
||||
Proficient bool `json:"proficient"`
|
||||
Animal_handling Animal_handling `json:"animal_handling"`
|
||||
Insight Insight `json:"insight"`
|
||||
Medicine Medicine `json:"medicine"`
|
||||
Survival Survival `json:"survival"`
|
||||
}
|
45
stats.json
Normal file
45
stats.json
Normal file
|
@ -0,0 +1,45 @@
|
|||
{
|
||||
"misc":{
|
||||
"proficiency": 3,
|
||||
"inspiration": 0,
|
||||
"level": 0,
|
||||
"name": "Bob"
|
||||
},
|
||||
"stats":{
|
||||
"strength": { "score":10, "modifier":0, "proficient":false },
|
||||
"dexterity": { "score":10, "modifier":0, "proficient":false },
|
||||
"constitution": { "score":10, "modifier":0, "proficient":false },
|
||||
"intelligence": { "score":10, "modifier":0, "proficient":false },
|
||||
"wisdom": { "score":10, "modifier":0, "proficient":false },
|
||||
"charisma": { "score":10, "modifier":0, "proficient":false }
|
||||
},
|
||||
"skills":{
|
||||
"strength":{
|
||||
"athletics": {"modifier":123, "proficient":false, "expertise":false }
|
||||
},
|
||||
"dexterity":{
|
||||
"acrobatics": {"modifier":0, "proficient":false, "expertise":false },
|
||||
"sleight-of-hand": {"modifier":0, "proficient":false, "expertise":false },
|
||||
"stealth": {"modifier":0, "proficient":false, "expertise":false }
|
||||
},
|
||||
"intelligence":{
|
||||
"arcana": {"modifier":0, "proficient":false, "expertise":false },
|
||||
"history": {"modifier":0, "proficient":false, "expertise":false },
|
||||
"investigation": {"modifier":0, "proficient":false, "expertise":false },
|
||||
"nature": {"modifier":0, "proficient":false, "expertise":false },
|
||||
"religion": {"modifier":0, "proficient":false, "expertise":false }
|
||||
},
|
||||
"wisdom":{
|
||||
"animal-handling": {"modifier":0, "proficient":false, "expertise":false },
|
||||
"insight": {"modifier":0, "proficient":false, "expertise":false },
|
||||
"medicine": {"modifier":0, "proficient":false, "expertise":false },
|
||||
"survival": {"modifier":0, "proficient":false, "expertise":false }
|
||||
},
|
||||
"charisma":{
|
||||
"deception": {"modifier":0, "proficient":false, "expertise":false },
|
||||
"intimidation": {"modifier":0, "proficient":false, "expertise":true },
|
||||
"performance": {"modifier":0, "proficient":true, "expertise":false },
|
||||
"persuasion": {"modifier":0, "proficient":false, "expertise":false }
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue