Skip to content

Commit

Permalink
checkin
Browse files Browse the repository at this point in the history
  • Loading branch information
garbados committed Nov 16, 2023
1 parent e88ab33 commit a019bad
Show file tree
Hide file tree
Showing 2 changed files with 82 additions and 16 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ $ java -jar {jarfile}

## Acknowledgements

I owe much to Dwarf Fortress, Rimworld, and Frostpunk for the city-builder heart of *The Longtime*. But I don't want to watch my pawns scurry, compelled by my inscrutable menus. I want the inspiration I bestow to be succinct and decisive, abstracted from physicality just as the player's very avatar is. I want to be the heart of their dreams. So I made this game.
I owe much to Dwarf Fortress, Rimworld, Kitten Game, and Frostpunk for the city-builder heart of *The Longtime*. But I don't want to watch my pawns scurry, compelled by my inscrutable menus. I want the inspiration I bestow to be succinct and decisive, abstracted from physicality just as the player's very avatar is. I want to be the heart of their dreams. So I made this game.

Thanks are also owed to my loving partner Lucia Brody for collaboratively developing the world of *The Shepherd*, of which Minots are only a part.

Expand Down
96 changes: 81 additions & 15 deletions src/the_longtime_game/web.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,9 @@
(-> (delete-doc name)
(.then #(when (= @game name)
(reset! game nil)
(reset! herd nil)))
(reset! herd nil)
(reset! gamestate :intro)
(reset! monthstep :event)))
(.then find-games)
(.then #(if (zero? (count @games))
(reset! state :new-game)
Expand All @@ -103,6 +105,14 @@
(when (= 13 (.-which e))
(on-submit @value)))}])

(defn- prompt-int [value maximum]
[:input.input
{:type "number"
:min 0
:max maximum
:value @value
:on-change #(reset! value (-> % .-target .-value))}])

(defn- init-new-game []
(let [value (r/atom "")]
[:div.container
Expand All @@ -123,7 +133,7 @@
[:div.block
[:div.columns
[:div.column
[:button.button.is-text.is-fullwidth
[:button.button.is-link.is-fullwidth
{:on-click #(load-game game)}
(str game)]]
[:div.column.is-narrow
Expand Down Expand Up @@ -504,26 +514,82 @@
(reset! monthstep :upkeep)))

(defn- handle-upkeep []
(let [herd* @herd]
(swap! herd core/apply-herd-upkeep)
(if (core/has-lost? @herd)
[:div.box>div.content
[:h3 "End of the month"]
(when-let [contact (and (core/new-contact? herd*)
(core/get-next-contact herd*))]
(swap! herd update :contacts conj contact)
[:p (contact-text/contact->blurb contact)])
(when (core/should-add-syndicate? herd*)
(let [votes (core/tally-votes (:individuals herd*))
candidates (core/rank-candidates votes)]
(when-let [candidate (core/select-candidate (:syndicates herd*) candidates)]
(swap! herd update :syndicates conj candidate)
[:p (meta-text/announce-syndicate candidate)])))]))
[:h3 "Game over!"]
[:p meta-text/gameover-text]
[:button.button.is-primary.is-fullwidth
{:on-click #(delete-game @game)}
"Try again!"]]
(let [herd* @herd]
[:div.box>div.content
[:h3 "End of the month"]
(when-let [contact (and (core/new-contact? herd*)
(core/get-next-contact herd*))]
(swap! herd update :contacts conj contact)
[:p (contact-text/contact->blurb contact)])
(when (core/should-add-syndicate? herd*)
(let [votes (core/tally-votes (:individuals herd*))
candidates (core/rank-candidates votes)]
(when-let [candidate (core/select-candidate (:syndicates herd*) candidates)]
(swap! herd update :syndicates conj candidate)
[:p (meta-text/announce-syndicate candidate)])))
[:button.button.is-primary.is-fullwidth
{:on-click #(reset! monthstep :leave)}
"Select your next location"]])))

(defn- handle-leave-behind []
(let [stores (->> (:stores @herd)
seq
(filter (comp pos-int? second))
(map #(conj % (r/atom (second %)))))
disabled? (> (reduce + (map #(deref (nth % 2)) stores))
(core/carry-limit @herd))
get-carrying #(into {} (for [[resource _ value] stores]
[resource @value]))
finish #(do (swap! herd core/keep-and-leave-behind (get-carrying))
(reset! monthstep :next))]
[:div.box>div.content
[:h3 "Leave things behind?"]
(for [[resource amount value] stores]
^{:key resource}
[:div.field
[:label.label (text/normalize-name resource)]
[:div.control
[prompt-int value amount]]])
(if (core/must-leave-some? @herd)
[:button.button.is-info.is-fullwidth
{:on-click finish
:disabled disabled?}
"Carry this!"]
[:button.button.is-info.is-fullwidth
{:on-click finish
:disabled disabled?}
"Carry everything!"])]))

(defn- handle-next-location []
[:div.box>div.content
[:h3 "Choose your next location"]
(let [stage (second (:path @herd))]
(for [i (range (count stage))
:let [location (get-in @herd [:path 1 i])]]
^{:key i}
[:p
[:button.button.is-info.is-fullwidth
{:on-click #(do (swap! herd core/next-location i)
(swap! herd core/end-month)
(reset! monthstep :event))}
(:name location)]]))])

(defn- playing []
(case @monthstep
:event [handle-event]
:projects [handle-projects]
:dream [handle-dream (r/atom nil)]
:upkeep [:p "TODO"]))
:upkeep [handle-upkeep]
:leave [handle-leave-behind]
:next [handle-next-location]))

(defn- app []
[:section.section
Expand Down

0 comments on commit a019bad

Please sign in to comment.