Skip to content

Commit

Permalink
Merge Resyntax changes
Browse files Browse the repository at this point in the history
By resyntax-ci[bot] (6) and D. Ben Knoble (4)
* autofix-8-1:
  bestiary-editor: tidy up match-over-when
  Revert "Fix 1 occurrence of `single-clause-match-to-match-define`"
  fixup! Fix 14 occurrences of `build-list-const-to-make-list`
  fixup! Fix 1 occurrence of `let-to-define`
  Fix 3 occurrences of `zero-comparison-to-negative?`
  Fix 1 occurrence of `zero-comparison-to-positive?`
  Fix 1 occurrence of `single-clause-match-to-match-define`
  Fix 1 occurrence of `tidy-require`
  Fix 14 occurrences of `build-list-const-to-make-list`
  Fix 1 occurrence of `let-to-define`

Close #112
  • Loading branch information
benknoble committed Nov 23, 2024
2 parents 0c1f044 + 82ebb63 commit 4fb7ad6
Show file tree
Hide file tree
Showing 9 changed files with 88 additions and 90 deletions.
2 changes: 1 addition & 1 deletion defns/loot.rkt
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
[parse-herb-kind (-> string? herb-kind?)]
[struct money ([amount natural-number/c])]
[struct material ([name material-kind?]
[amount (apply list/c (build-list (sub1 max-players) (const natural-number/c)))])]
[amount (apply list/c (make-list (sub1 max-players) natural-number/c))])]
[material-amount* (-> material? num-players/c natural-number/c)]
[struct herb ([name herb-kind?]
[amount natural-number/c])]
Expand Down
4 changes: 2 additions & 2 deletions defns/monsters.rkt
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
[immunities (listof string?)])]
[struct monster-info ([set-name string?]
[name string?]
[normal-stats (apply list/c (build-list number-of-levels (const monster-stats?)))]
[elite-stats (apply list/c (build-list number-of-levels (const monster-stats?)))])]
[normal-stats (apply list/c (make-list number-of-levels monster-stats?))]
[elite-stats (apply list/c (make-list number-of-levels monster-stats?))])]
[struct monster-ability ([set-name string?]
[name string?]
[initiative initiative?]
Expand Down
6 changes: 3 additions & 3 deletions defns/players.rkt
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@

(define ((player-act-on-hp proc) p)
(define new-hp (proc (player-current-hp p)))
(if (not (>= new-hp 0))
(if (negative? new-hp)
p
(struct-copy player p [current-hp new-hp])))

Expand All @@ -81,7 +81,7 @@

(define ((player-act-on-xp proc) p)
(define new-xp (proc (player-xp p)))
(if (not (>= new-xp 0))
(if (negative? new-xp)
p
(struct-copy player p [xp new-xp])))

Expand Down Expand Up @@ -136,7 +136,7 @@

(define ((summon-act-on-hp proc) s)
(define new-hp (proc (summon-current-hp s)))
(if (not (>= new-hp 0))
(if (negative? new-hp)
s
(struct-copy summon s [current-hp new-hp])))

Expand Down
22 changes: 11 additions & 11 deletions defns/scenario.rkt
Original file line number Diff line number Diff line change
Expand Up @@ -66,14 +66,14 @@
[bless "Bless (x 2)"]))

(define monster-modifier-deck
(append (build-list 6 (const zero))
(build-list 5 (const minus1))
(build-list 5 (const plus1))
(append (make-list 6 zero)
(make-list 5 minus1)
(make-list 5 plus1)
(list minus2 plus2 null crit)))

(define monster-curse-deck (build-list 10 (const curse)))
(define monster-curse-deck (make-list 10 curse))

(define bless-deck (build-list 10 (const bless)))
(define bless-deck (make-list 10 bless))

(define-flow (shuffle-modifier-deck? _pulled-cards)
(~> sep (any (one-of? null crit))))
Expand Down Expand Up @@ -117,23 +117,23 @@
cards))
(append* (for/list ([(card num) (in-hash difference)]
#:when (moveable? card))
(build-list num (const card)))))
(make-list num card))))

(module+ test
(test-not-exn "absent-from-modifier-deck: does not fail on non-subset keys"
(thunk (absent-from-modifier-deck (list curse))))
(test-exn "absent-from-modifier-deck: fails on too many cards" #rx"subset"
(thunk (absent-from-modifier-deck (build-list 10 (const crit)))))
(thunk (absent-from-modifier-deck (make-list 10 crit))))
(test-case "absent-from-modifier-deck: computes the difference from the standard modifier deck"
(check-equal? (counter (absent-from-modifier-deck monster-modifier-deck)) (counter empty))
(check-equal? (counter (absent-from-modifier-deck (shuffle monster-modifier-deck))) (counter empty))
(check-equal? (counter (absent-from-modifier-deck empty)) (counter monster-modifier-deck))
(check-equal? (counter (absent-from-modifier-deck
(shuffle (append (build-list 6 (const zero))
(build-list 2 (const minus1))
(build-list 5 (const plus1))
(shuffle (append (make-list 6 zero)
(make-list 2 minus1)
(make-list 5 plus1)
(list plus2 null crit)))))
(counter (append (build-list 3 (const minus1))
(counter (append (make-list 3 minus1)
(list minus2))))))

(define-serializable-enum-type condition
Expand Down
126 changes: 62 additions & 64 deletions gui/bestiary-editor.rkt
Original file line number Diff line number Diff line change
Expand Up @@ -6,23 +6,22 @@
;; (require racket/gui/easy/debugger)
;; (start-debugger))

(require (only-in racket/gui
application-about-handler)
racket/gui/easy
(only-in pretty-expressive pretty-print)
frosthaven-manager/observable-operator
frosthaven-manager/curlique
frosthaven-manager/qi/utils
(require frosthaven-manager/curlique
frosthaven-manager/defns
frosthaven-manager/monster-db
frosthaven-manager/parsers/monster
frosthaven-manager/pp/bestiary
frosthaven-manager/files
frosthaven-manager/gui/common-menu
frosthaven-manager/gui/mixins
frosthaven-manager/gui/counter
frosthaven-manager/gui/helpers
frosthaven-manager/gui/mixins
frosthaven-manager/gui/stacked-tables
frosthaven-manager/gui/counter
frosthaven-manager/files)
frosthaven-manager/monster-db
frosthaven-manager/observable-operator
frosthaven-manager/parsers/monster
frosthaven-manager/pp/bestiary
frosthaven-manager/qi/utils
racket/gui/easy
(only-in racket/gui application-about-handler)
(only-in pretty-expressive pretty-print))

(define modifier
(case (system-type 'os)
Expand Down Expand Up @@ -80,58 +79,57 @@
(<@ @info-db {(hash-update monster-set {(hash-remove monster-name)})})]
['stats
(match (cdr xs)
[(list* data f args)
(when data
(match-define (struct stats-editor-data [set name level elite? _info _name->info]) data)
(define current-value (f (stats-editor-data-stats data)))
(define (update-statss the-statss)
(list-update
the-statss
level
(λ (stats)
;; TODO: should not cause contract violation: but the edit
;; function don't know what they're operating on
;; TODO: need to handle formulas for stats that can be?
(match* (f args)
[{(== monster-stats-max-hp) (list proc)}
(struct-copy monster-stats stats [max-hp (proc current-value)])]
[{(== monster-stats-move) (list proc)}
(struct-copy monster-stats stats [move (proc current-value)])]
[{(== monster-stats-attack) (list proc)}
(struct-copy monster-stats stats [attack (proc current-value)])]
[{(== monster-stats-bonuses) '(new)}
(struct-copy monster-stats stats [bonuses (append current-value '(""))])]
[{(== monster-stats-bonuses) (list index 'remove)}
(struct-copy monster-stats stats [bonuses (list-remove current-value index)])]
[{(== monster-stats-bonuses) (list index value)}
(struct-copy monster-stats stats [bonuses (list-set current-value index value)])]
[{(== monster-stats-effects) '(new)}
(struct-copy monster-stats stats [effects (append current-value '(""))])]
[{(== monster-stats-effects) (list index 'remove)}
(struct-copy monster-stats stats [effects (list-remove current-value index)])]
[{(== monster-stats-effects) (list index value)}
(struct-copy monster-stats stats [effects (list-set current-value index value)])]
[{(== monster-stats-immunities) '(new)}
(struct-copy monster-stats stats [immunities (append current-value '(""))])]
[{(== monster-stats-immunities) (list index 'remove)}
(struct-copy monster-stats stats [immunities (list-remove current-value index)])]
[{(== monster-stats-immunities) (list index value)}
(struct-copy monster-stats stats [immunities (list-set current-value index value)])]))))
(<@ @info-db
(λ (info-db)
(hash-update
info-db
set
(λ (name->info)
(hash-update
name->info
name
(λ (info)
(define ->stats (if elite? monster-info-elite-stats monster-info-normal-stats))
(define the-statss (->stats info))
(if elite?
[(cons #f _) (void)]
[(list* (and data (struct stats-editor-data [set name level elite? _info _name->info])) f args)
(define current-value (f (stats-editor-data-stats data)))
(define (update-statss the-statss)
(list-update
the-statss
level
(λ (stats)
;; TODO: should not cause contract violation: but the edit
;; function don't know what they're operating on
;; TODO: need to handle formulas for stats that can be?
(match* (f args)
[{(== monster-stats-max-hp) (list proc)}
(struct-copy monster-stats stats [max-hp (proc current-value)])]
[{(== monster-stats-move) (list proc)}
(struct-copy monster-stats stats [move (proc current-value)])]
[{(== monster-stats-attack) (list proc)}
(struct-copy monster-stats stats [attack (proc current-value)])]
[{(== monster-stats-bonuses) '(new)}
(struct-copy monster-stats stats [bonuses (append current-value '(""))])]
[{(== monster-stats-bonuses) (list index 'remove)}
(struct-copy monster-stats stats [bonuses (list-remove current-value index)])]
[{(== monster-stats-bonuses) (list index value)}
(struct-copy monster-stats stats [bonuses (list-set current-value index value)])]
[{(== monster-stats-effects) '(new)}
(struct-copy monster-stats stats [effects (append current-value '(""))])]
[{(== monster-stats-effects) (list index 'remove)}
(struct-copy monster-stats stats [effects (list-remove current-value index)])]
[{(== monster-stats-effects) (list index value)}
(struct-copy monster-stats stats [effects (list-set current-value index value)])]
[{(== monster-stats-immunities) '(new)}
(struct-copy monster-stats stats [immunities (append current-value '(""))])]
[{(== monster-stats-immunities) (list index 'remove)}
(struct-copy monster-stats stats [immunities (list-remove current-value index)])]
[{(== monster-stats-immunities) (list index value)}
(struct-copy monster-stats stats [immunities (list-set current-value index value)])]))))
(<@ @info-db
(λ (info-db)
(hash-update
info-db
set
(λ (name->info)
(hash-update
name->info
name
(λ (info)
(define ->stats (if elite? monster-info-elite-stats monster-info-normal-stats))
(define the-statss (->stats info))
(if elite?
(struct-copy monster-info info [elite-stats (update-statss the-statss)])
(struct-copy monster-info info [normal-stats (update-statss the-statss)])))))))))])]
(struct-copy monster-info info [normal-stats (update-statss the-statss)]))))))))])]
['abilities (void)]))
(render
(window
Expand Down
2 changes: 1 addition & 1 deletion gui/loot.rkt
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@
label max-cards type)
(define @n (@> @type->cards {(hash-ref type 0)}))
(define (subtract-card)
(when (> (@! @n) 0)
(when (positive? (@! @n))
(on-card `(remove ,type))))
(define (add-card)
(when (< (@! @n) max-cards)
Expand Down
10 changes: 5 additions & 5 deletions rich-text-helpers.rkt
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@

;; f: x -> listof y
(define (only-on-text f . xs)
(let ([f* (if (null? xs) f (apply curry f xs))])
(λ (x)
(cond
[(string? x) (f* x)]
[else (list x)]))))
(define f* (if (null? xs) f (apply curry f xs)))
(λ (x)
(cond
[(string? x) (f* x)]
[else (list x)])))

(define-syntax-parser match-loop
[(_ input:expr [pat:expr e ... res:expr] ...)
Expand Down
2 changes: 1 addition & 1 deletion scribblings/defns/loot.scrbl
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ Serializable.

@defstruct*[material
([name material-kind?]
[amount (apply list/c (build-list (sub1 max-players) (const natural-number/c)))])
[amount (apply list/c (make-list (sub1 max-players) natural-number/c))])
#:transparent]{
Represents a loot card for a material; the amount varies by number of players.
May have +1 stickers.
Expand Down
4 changes: 2 additions & 2 deletions scribblings/defns/monsters.scrbl
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ The monster statistic representation, usually used with pre-fabs.
@defstruct*[monster-info
([set-name string?]
[name string?]
[normal-stats (apply list/c (build-list number-of-levels (const monster-stats?)))]
[elite-stats (apply list/c (build-list number-of-levels (const monster-stats?)))])
[normal-stats (apply list/c (make-list number-of-levels monster-stats?))]
[elite-stats (apply list/c (make-list number-of-levels monster-stats?))])
#:prefab]{
The monster information representation, often for reading pre-fab structs.
}
Expand Down

0 comments on commit 4fb7ad6

Please sign in to comment.