RosettaCodeData/Task/RPG-attributes-generator/Min/rpg-attributes-generator.min

18 lines
870 B
Plaintext

randomize ; Seed the rng with current timestamp.
; Implement some general operators we'll need that aren't in the library.
(() 0 shorten) :new
((new (over -> swons)) dip times nip) :replicate
(('' '' '') => spread if) :if?
((1 0 if?) concat map sum) :count
(5 random succ) :d6 ; Roll a 1d6.
('d6 4 replicate '< sort 3 take sum) :attr ; Roll an attribute.
('attr 6 replicate) :attrs ; Roll 6 attributes.
(sum 75 >=) :big? ; Is a set of attributes "big?"
(attrs (dup big?) () (pop attrs) () linrec) :big ; Roll a set of big attributes.
((15 >=) count 2 >=) :special? ; Is a set of atributes "special?"
(big (dup special?) () (pop big) () linrec) :stats ; Roll a set of big and special attributes.
stats puts "Total: " print! sum puts!