I like to hold the state of the game in a data structure, and have every
function take the game state and return a new game state. Then, to
persist the game you can just serialize the whole thing to disk.
Here's a blackjack game I wrote a while back in that style:
https://github.com/sritchie/blackjack
Hope that helps!
Majen Ful <mailto:majen...@gmail.com>
June 23, 2014 at 1:54 PM
Hello all,
First, thank you all for your contribution and your help. I just
follow Clojure's news and groups, and I'm really impressed by how this
community is pleasant and helpful.
Well, I am new to Clojure world, I do programming as a hobby (I'm not
pro) and I don't have advanced knowledges. However I really enjoy
programming and I like games. In a "classic" language, as Ruby or
Java, I can use mutable states and objects so it is "easy" to reason.
In Clojure, I understand how immutability works, but I still miss some
reflexes.
My goal is to build a little card game
like http://boardgamegeek.com/boardgame/128667/samurai-sword
A lot of things to do, but I have some difficulties at beginning.
For example, I can define cards, I can define some function (isdead,
attack)... But how can I save the state of the game ? When a player
attacks another player, the second player must have its life reduced.
At this point, my OO reflexes are went back and don't find a solution.
Could you give me some tips and lead me to the right things to do.
Thanks by advance :-)
--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient
with your first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
---
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send
an email to clojure+unsubscr...@googlegroups.com
<mailto:clojure+unsubscr...@googlegroups.com>.
For more options, visit https://groups.google.com/d/optout.
--
Sam Ritchie (@sritchie)
Paddleguru Co-Founder
703.863.8561
www.paddleguru.com <http://www.paddleguru.com/>
Twitter <http://twitter.com/paddleguru>// Facebook
<http://facebook.com/paddleguru>
--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
---
You received this message because you are subscribed to the Google Groups "Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.