diff --git a/geomancer.nimble b/geomancer.nimble index 885f11f..6a28255 100644 --- a/geomancer.nimble +++ b/geomancer.nimble @@ -1,6 +1,6 @@ # Package -version = "1.0.1" +version = "1.0.2" author = "VitorGoatman" description = "A library and program for getting geomancy charts and figures." license = "Unlicense" diff --git a/src/geomancer.nim b/src/geomancer.nim index 83292fe..5036eb4 100644 --- a/src/geomancer.nim +++ b/src/geomancer.nim @@ -1,5 +1,5 @@ import geomancerpkg/[geomancy, figures, msgs] -import std/[strformat] +import std/[strformat,wordwrap] import docopt const @@ -26,7 +26,6 @@ Options: about a figure. """ - let args = docopt doc proc matchFig(fig:string): FigData = @@ -40,30 +39,24 @@ proc matchFig(fig:string): FigData = quit("Unknown figure: "&fig, 1) proc chart() = - var - ms,ds,ns: figSet - lw,rw,ju: Figure + var reading:Reading if args["--build"]: - ms = [ + let m = [ matchFig($args[""]).fig, matchFig($args[""]).fig, matchFig($args[""]).fig, matchFig($args[""]).fig] - ds = getDaughters ms - ns = getNieces(ms,ds) - rw = sumFigures(ns[0],ns[1]) - lw = sumFigures(ns[2],ns[3]) - ju = sumFigures(lw,rw) - echo fmt shieldmsg + reading = geomancy m else: - let reading = geomancy() + reading = geomancy() + let ms = reading.ms ds = reading.ds ns = reading.ns lw = reading.lw rw = reading.rw ju = reading.ju - echo fmt shieldmsg + echo fmt shieldmsg if args["house"]: echo fmt housemsg @@ -86,4 +79,6 @@ when isMainModule: if args["sum"]: sum($args[""],$args[""]) if args["info"]: let f = matchFig $args[""] - echo fmt infomsg + echo infomsg.fmt + echo "Commentary: ",f.commentary.wrapWords(),"\n" + echo "Divinatory meaning: ",f.divination.wrapWords() diff --git a/src/geomancerpkg/geomancy.nim b/src/geomancerpkg/geomancy.nim index e513e64..6ef0266 100644 --- a/src/geomancerpkg/geomancy.nim +++ b/src/geomancerpkg/geomancy.nim @@ -8,19 +8,23 @@ const type Figure* = array[4,string] - figSet* = array[4,Figure] + FigSet* = array[4,Figure] + Reading* = tuple + ms,ds,ns: FigSet + lw,rw,ju: Figure -proc getFigure(): Figure = +proc getFigure*(): Figure = for n in 0..3: - case [true,false].sample - of true: result[n] = dp - of false: result[n] = sp + case rand 1 + of 0: result[n] = dp + of 1: result[n] = sp + else: discard -proc getMothers(): figSet = +proc getMothers*():FigSet = for n in 0..3: result[n] = getFigure() -func getDaughters*(mothers: figSet): figSet = +func getDaughters*(mothers: FigSet): FigSet = for d in 0..3: result[d] = [mothers[0][d],mothers[1][d],mothers[2][d],mothers[3][d]] @@ -31,18 +35,18 @@ func sumFigures*(fig1,fig2: Figure):Figure = else: result[n] = sp -func getNieces*(mothers,daughters:figSet): figSet = +func getNieces*(mothers,daughters:FigSet): FigSet = result[0] = sumFigures(mothers[0],mothers[1]) result[1] = sumFigures(mothers[2],mothers[3]) result[2] = sumFigures(daughters[0],daughters[1]) result[3] = sumFigures(daughters[2],daughters[3]) -proc geomancy*():tuple[ms,ds,ns:figSet, rw,lw,ju:Figure] = +proc geomancy*(mothers = getMothers()):Reading = let - ms = getMothers() + ms = mothers ds = getDaughters ms ns = getNieces(ms,ds) rw = sumFigures(ns[0],ns[1]) lw = sumFigures(ns[2],ns[3]) ju = sumFigures(rw,lw) - return (ms,ds,ns,rw,lw,ju) + return (ms,ds,ns,lw,rw,ju) diff --git a/src/geomancerpkg/msgs.nim b/src/geomancerpkg/msgs.nim index f842432..24d9a61 100644 --- a/src/geomancerpkg/msgs.nim +++ b/src/geomancerpkg/msgs.nim @@ -82,7 +82,4 @@ Image: {f.img} Colors: {f.color} Keyword: {f.keyword} Quality: {f.quality} - -Divinatory meaning: {f.divination} -Commentary: {f.commentary} """