Create preset generators

This commit is contained in:
2024-04-11 22:03:56 +02:00
parent 5bd8f9e6a7
commit 5b853a9752
3 changed files with 14 additions and 10 deletions

View File

@@ -27,10 +27,9 @@
(produce-items items nights i18n))))
(defn produce-all [store profile nights i18n]
(let [nights (util/ask-int (:nights? i18n))]
(->> store
keys
(map (fn [category] [category (filter #(.contains profile (:key %)) (get store category))]))
(filter #(not (empty? (second %))))
(map #(produce-category (first %) (second %) nights i18n))
(clojure.string/join "\n\n"))))
(clojure.string/join "\n\n")))

View File

@@ -1,6 +1,7 @@
(ns packer.database
(:use packer.model)
(:require packer.i18n.pl)
(:require packer.i18n.pl)
(:require [packer.util :as util])
(:gen-class))
; Choose language to Polish
@@ -19,9 +20,12 @@
]
})
(defn simple-preset [question items seq]
(if (util/ask-bool question)
(concat seq items)
seq))
; Define profile getter
(defn get-profile []
(->> store
vals
flatten
(map #(:key %))))
(defn get-profile [nights]
(->> [:t-shirt]
(simple-preset "Bierzesz telefon?" [:smartphone])))

View File

@@ -1,8 +1,9 @@
(ns packer.main
(:use packer.model)
(:require packer.core packer.database)
(:require packer.core packer.database packer.util)
(:gen-class))
(defn -main
[& args]
(println (packer.core/produce-all packer.database/store (packer.database/get-profile) 15 packer.database/i18n)))
(let [nights (packer.util/ask-int (:nights? packer.database/i18n))]
(println (packer.core/produce-all packer.database/store (packer.database/get-profile nights) nights packer.database/i18n))))