diff options
author | rsiddharth <s@ricketyspace.net> | 2019-09-26 20:29:10 -0400 |
---|---|---|
committer | rsiddharth <s@ricketyspace.net> | 2019-09-26 20:29:10 -0400 |
commit | a1e1cabee935128a7b06f877f45c4d89058950e7 (patch) | |
tree | babf774eba7eb15c5a761266b305a867fb7333c3 | |
parent | 25eb685e5efded84e4f28640548169a26367e326 (diff) |
net: ror/ten/source.rkt: Update attacking.
Roll dice to decide the winner for the attack.
This kinda completes challenge one in ch. 10.
-rw-r--r-- | net/ricketyspace/ror/ten/source.rkt | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/net/ricketyspace/ror/ten/source.rkt b/net/ricketyspace/ror/ten/source.rkt index 8cb98dc..71c73b4 100644 --- a/net/ricketyspace/ror/ten/source.rkt +++ b/net/ricketyspace/ror/ten/source.rkt @@ -521,7 +521,14 @@ (define feasible (game-moves (dice-world-gt w))) (define attack (list source target)) (define next (find-move feasible attack)) - (if next (dice-world #f (game-board next) next) w)) + (define src-t (findf (lambda (t) (= (territory-index t) source)) + (dice-world-board w))) + (define dst-t (findf (lambda (t) (= (territory-index t) target)) + (dice-world-board w))) + (define win? (dice-attack-win src-t dst-t)) + (cond [(not next) w] + [win? (dice-world #f (game-board next) next)] + [else (dice-world-attack-lost w src-t)])) ;; [List-of Moves] [or '() [List Natural Natural]] -> [or #f Game-tree] ;; find the move from the current list of moves |