From 3fdb5f25916097a762a9f68121a5807e3974cea1 Mon Sep 17 00:00:00 2001 From: Marty Sluijtman Date: Mon, 22 Aug 2022 15:17:58 +0200 Subject: [PATCH] More trivia fields --- APKBUILD | 10 +++++----- Makefile | 2 +- example.json | 5 ++++- main.go | 23 +++++++++++++++-------- sheetContent.go | 7 +++++-- zsh.completion | 2 ++ 6 files changed, 32 insertions(+), 17 deletions(-) diff --git a/APKBUILD b/APKBUILD index c1dcb05..0bc5e95 100644 --- a/APKBUILD +++ b/APKBUILD @@ -1,8 +1,8 @@ # Contributor: Marty Sluijtman # Maintainer: Marty Sluijtman pkgname=sheet-parser -pkgver=0.1 -pkgrel=4 +pkgver=0.2 +pkgrel=0 pkgdesc="A little D&D character sheet parser written in go" url="https://gitlab.com/EternalWanderer/sheet-parser" arch="all" @@ -28,7 +28,7 @@ package() { } sha512sums=" -72039de0cb1faab57ac1d9c7118dd84517f020277d93f71168b0cc74012a0910932b75d241f7d45c1b1cf7a66f0c010568beb41f66f59c8a4dae2e2afe8f8154 sheet-parser-0.1.tar.gz -3e990e0e2aac58d0498d3fbb42e2a03bfee5c6614bdc5e258c2723ef24eb2c0e6ff96e696f3f7552a35bb3d8e9070635f38f37ecf26069a0ad2800e3732f73a4 zsh.completion -71177c48d8337abf048a7eaa924cb2f0ec0fc547f58ea2a2dd64ce4d549b39cfc1aa9cea369cd440fece484d32b8e09fccb9e5d402688b738df274d069b5fc93 example.json +35eec80feaa09c683759f996c8ad11f0c70a178fcae165a8921b58e4b3afbe8b6c92cc4000f084237cc1b80c6b7196035495227a6f689c081123159ea9c4ad62 sheet-parser-0.2.tar.gz +c772f393191ebd3b68b0c08cc916b1605ce8bd7d7f458da58f00cfbb6120bebe7bc86d3b70a3f7bacc4eac05cfd33846fd7ec757c054018f25d629f88bd6fec0 zsh.completion +7c1f79d8c4348a7928f81064f29fe52b8475a573e8a14d3d6bd448453b0501af60c03b43301b7049bcc249661e66213f3365ac8d34ca5c52be1cbbd7278c6f8c example.json " diff --git a/Makefile b/Makefile index 53cc88c..98a02c1 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -VERSION = 0.1 +VERSION = 0.2 PREFIX = /usr/local MANPREFIX = $(PREFIX)/share/man ZSH_COMPLETION_OUTPUT := zsh.completion diff --git a/example.json b/example.json index 4ae5b0b..2e8a304 100644 --- a/example.json +++ b/example.json @@ -1,7 +1,10 @@ { "misc":{ "level": 1, - "name": "Bob" + "name": "Bob", + "race": "Human", + "class": "Figher", + "background": "Generic" }, "stats":[ {"statName":"strength", "score":20, "proficient":false }, diff --git a/main.go b/main.go index 439f688..b9e3304 100644 --- a/main.go +++ b/main.go @@ -12,14 +12,14 @@ import ( ) var ( - path, skillString, saveString, statString string - exampleFile string = "/etc/sheet-parser/example.json" - modifier, diceThrows, surfaces int - X, Y int - char Character - skillMap = make(map[string]int) - statMap = make(map[string]int) - advantage, disadvantage, stat_list, skill_list, verbose bool + path, skillString, saveString, statString string + exampleFile string = "/etc/sheet-parser/example.json" + modifier, diceThrows, surfaces int + X, Y int + char Character + skillMap = make(map[string]int) + statMap = make(map[string]int) + advantage, disadvantage, stat_list, skill_list, verbose, trivia bool ) func parseFlags() { @@ -37,6 +37,9 @@ func parseFlags() { flag.BoolVar(&verbose, "verbose", false, "Print stat numbers, to be used in combination with -stat-list or -skill-list") flag.BoolVar(&verbose, "v", false, "Print stat numbers, to be used in combination with -stat-list or -skill-list") + flag.BoolVar(&trivia, "t", false, "Print character name, level and proficiency") + flag.BoolVar(&trivia, "trivia", false, "Print character name, level and proficiency") + flag.Parse() } @@ -76,6 +79,10 @@ func main() { switch { + case trivia: + fmt.Printf("Name: %s\tLevel: %d\tProficiency: %d\n", char.Misc.Name, char.Misc.Level, getProficiency()) + fmt.Printf("Race: %s\tClass: %s\tBackground: %s\n", char.Misc.Race, char.Misc.Class, char.Misc.Background) + case stat_list && verbose: var proficiency string for i := 0; i < len(char.Stats); i++ { diff --git a/sheetContent.go b/sheetContent.go index 71b5a8f..e1f2cb8 100644 --- a/sheetContent.go +++ b/sheetContent.go @@ -7,8 +7,11 @@ type Character struct { } type Misc struct { - Level int `json:"level"` - Name string `json:"name"` + Level int `json:"level"` + Name string `json:"name"` + Race string `json:"race"` + Class string `json:"class"` + Background string `json:"background"` } type Skill struct { SkillName string `json:"skillName"` diff --git a/zsh.completion b/zsh.completion index ae0dd2a..56973a1 100644 --- a/zsh.completion +++ b/zsh.completion @@ -1,6 +1,8 @@ #compdef sheet-parser arguments=( + '(--trivia -t)--trivia[Print character trivia]' + '(--trivia -t)-t[Print character trivia]' '(--file)-f=[Path to charactersheet]:character sheet:_files -g "*.(json)(-.)"' '(-f)--file=[Path to charactersheet]:character sheet:_files -g "*.(json)(-.)"' '(--save --stat --verbose)-v[To be used in conjuction with list parameters]'