|
@@ -30,6 +30,9 @@
|
|
|
;; this just keeps us honest that this is playable with dice
|
|
|
(define *allowed-table-sizes* '(2 4 6 8 10 12 20 36 50 100))
|
|
|
|
|
|
+;; this is used in define-oracle to actually process the information, and ought to
|
|
|
+;; return a zero-argument function that will roll on the table
|
|
|
+;; TODO: also allow generating print structures from the same data!
|
|
|
(define (oracle table)
|
|
|
(cond [(andmap valid-oracle-result? table)
|
|
|
(if (member (length table) *allowed-table-sizes*)
|
|
@@ -40,13 +43,16 @@
|
|
|
(lambda () (table-index (d max) table)))]
|
|
|
[else (error 'oracle "Unexpected argument: ~a" table)]))
|
|
|
|
|
|
+;; given a range-based table, find the highest value to roll
|
|
|
(define (max-table-size table)
|
|
|
(let [(final (last table))]
|
|
|
(if (= (length final) 3) (cadr final) (car final))))
|
|
|
|
|
|
+;; true if the `thing` is a symbol or string
|
|
|
(define (valid-oracle-result? thing)
|
|
|
(or (symbol? thing) (string? thing)))
|
|
|
|
|
|
+;; true if the thing is a list of the form (num num string) or (num string)
|
|
|
(define (valid-table-member? member)
|
|
|
(and (list? member)
|
|
|
(or (and (= (length member) 3)
|
|
@@ -57,6 +63,9 @@
|
|
|
(number? (car member))
|
|
|
(valid-oracle-result? (cadr member))))))
|
|
|
|
|
|
+;; look up a number and find it in the table. (this assumes the table is sorted and
|
|
|
+;; includes all possible values covered!
|
|
|
+;; TODO: make this more resilient to bad input
|
|
|
(define (table-index idx table)
|
|
|
(if (null? table)
|
|
|
(error 'table-index "Unexpected empty table")
|
|
@@ -73,4 +82,7 @@
|
|
|
(define-syntax-rule [define-oracle name . table]
|
|
|
(define name (oracle (quote table))))
|
|
|
|
|
|
-(provide judge-outcome roll-plus-mod oracle define-oracle)
|
|
|
+(define-syntax-rule [define-asset-path name . table]
|
|
|
+ #f)
|
|
|
+
|
|
|
+(provide judge-outcome roll-plus-mod oracle define-oracle define-asset-path)
|