summaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
authorrsiddharth <s@ricketyspace.net>2019-09-26 20:27:52 -0400
committerrsiddharth <s@ricketyspace.net>2019-09-26 20:27:52 -0400
commit70f921d266de4dab51052a7306b7732808428531 (patch)
tree163e6c83633857e01690f6e512267c7b78ec277c /net
parent2348fd34c507844861acc3068edb88fb7074cb8a (diff)
net: ror/ten/sourc.rkt: Add dice-attack-win.
Diffstat (limited to 'net')
-rw-r--r--net/ricketyspace/ror/ten/source.rkt13
1 files changed, 13 insertions, 0 deletions
diff --git a/net/ricketyspace/ror/ten/source.rkt b/net/ricketyspace/ror/ten/source.rkt
index 4bffdd0..b4fb6f2 100644
--- a/net/ricketyspace/ror/ten/source.rkt
+++ b/net/ricketyspace/ror/ten/source.rkt
@@ -534,6 +534,19 @@
(define (no-more-moves? g)
(empty? (game-moves g)))
+;; Territory Territory -> Boolean
+;; attack from src territory to destination territory
+;; and see who wins
+(define (dice-attack-win src-t dst-t)
+ (define (roll-dice n)
+ (for/list ([i n])
+ (random 1 7)))
+ (define (sum l)
+ (foldl + 0 l))
+ (define src-attack (sum (roll-dice (territory-dice src-t))))
+ (define dst-defend (sum (roll-dice (territory-dice dst-t))))
+ (if (> src-attack dst-defend) #t #f))
+
;
;
;