Skip to content

Commit

Permalink
Cleaned code, improved info output
Browse files Browse the repository at this point in the history
  • Loading branch information
VitorGoatman committed Aug 8, 2022
1 parent f2f4f91 commit a3abcd6
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 30 deletions.
2 changes: 1 addition & 1 deletion geomancer.nimble
Original file line number Diff line number Diff line change
@@ -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"
Expand Down
25 changes: 10 additions & 15 deletions src/geomancer.nim
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import geomancerpkg/[geomancy, figures, msgs]
import std/[strformat]
import std/[strformat,wordwrap]
import docopt

const
Expand All @@ -26,7 +26,6 @@ Options:
about a figure.
"""


let args = docopt doc

proc matchFig(fig:string): FigData =
Expand All @@ -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["<m1>"]).fig,
matchFig($args["<m2>"]).fig,
matchFig($args["<m3>"]).fig,
matchFig($args["<m4>"]).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

Expand All @@ -86,4 +79,6 @@ when isMainModule:
if args["sum"]: sum($args["<figure1>"],$args["<figure2>"])
if args["info"]:
let f = matchFig $args["<name>"]
echo fmt infomsg
echo infomsg.fmt
echo "Commentary: ",f.commentary.wrapWords(),"\n"
echo "Divinatory meaning: ",f.divination.wrapWords()
26 changes: 15 additions & 11 deletions src/geomancerpkg/geomancy.nim
Original file line number Diff line number Diff line change
Expand Up @@ -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]]

Expand All @@ -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)
3 changes: 0 additions & 3 deletions src/geomancerpkg/msgs.nim
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,4 @@ Image: {f.img}
Colors: {f.color}
Keyword: {f.keyword}
Quality: {f.quality}
Divinatory meaning: {f.divination}
Commentary: {f.commentary}
"""

0 comments on commit a3abcd6

Please sign in to comment.