Skip to content

Commit

Permalink
And a bit of refactoring brings me to v0.2!
Browse files Browse the repository at this point in the history
The player can now interact with items, talk to NPCs and fight
against monsters. We're getting somewhere :-)
  • Loading branch information
veddox committed Jul 8, 2015
1 parent b085da3 commit f370c57
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 19 deletions.
13 changes: 10 additions & 3 deletions atlantis.txt
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ Networking: does Common Lisp support networking? threading? If not the latter,
too difficult. The threading is probably more of a challenge.
(If it's necessary, that is?)
-> actually, clisp does support networking via sockets. Yeah! :-)
(But that means I would have to change the Atlantis license to
GPL. I should have a look at the cl-iolib...)


Implementation: presumably Atlantis will have to have a server-client model.
Expand All @@ -40,12 +42,13 @@ Implementation: presumably Atlantis will have to have a server-client model.
with string representations of objects in Lisp. (Just pass
the *world* object to the client, for instance.)
-> SECURITY RISK!
-> I would like to implement this in a way that keeps the
entire game logic on the server. The only thing the client
should do is take input from the user and send it to the
server.
-> For the sake of better code separation, it would probably
be wise to create two Lisp packages (server and client).

Combat system: Here I have to think of something clever... The OpenWorld method
would be an option, but I'm not too keen on it.


PLAN OF ACTION - TODO

Expand All @@ -58,3 +61,7 @@ Networking: as described above. I would tend to leave this for quite late, the
Game features: Currently (v0.1), creating the world using ATL works, and the
player can move around. Now I need to add game items, NPCs,
monsters, a combat system, etc.

Targets: I am almost at v0.2. After that, I should start building a real game
world to mature the game on. Also, I should keep thinking about how
to implement the networking. By v0.4 I hope to have that up and running.
12 changes: 12 additions & 0 deletions lisp/game-objects.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -96,3 +96,15 @@
(defun list-place-objects (object-type place)
"Get a list of the names of all the place's objects of this type."
(funcall list-function object-type place)))

(defun get-object-description (object-name place)
"Get a description of this object in place (or nil if not there)"
(let ((p (if (place-p place) place (get-game-object 'place place))))
(cond ((member object-name (list-place-objects 'item p) :test #'equalp)
(item-description (get-game-object 'item object-name)))
((member object-name (list-place-objects 'monster p) :test #'equalp)
(monster-description (get-game-object 'monster object-name)))
((member object-name (list-place-objects 'npc p) :test #'equalp)
(npc-description (get-game-object 'npc object-name)))
(t NIL))))

21 changes: 6 additions & 15 deletions lisp/ui.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -217,21 +217,12 @@ save <game-file> - Save the game to file")
;; A bit of syntactic sugar...
(cond ((equalp object-name "me") (player player) (return-from about))
((equalp object-name "here") (place player) (return-from about)))
;; FIXME What about objects that the player is carrying?
;; TODO Outsource this to game-objects.lisp (or player.lisp)
(let ((place (get-game-object 'place (player-place player)))
(description NIL))
(macrolet ((set-descr (type)
(let ((place-descr (build-symbol type "-description")))
`(when (member object-name
(list-place-objects ',type place)
:test #'equalp)
(setf description (,place-descr
(get-game-object ',type
object-name)))))))
(set-descr item)
(set-descr monster)
(set-descr npc))
(let ((description (get-object-description object-name
(player-place player))))
;; Don't forget items the player is carrying
(when (member object-name (player-item player) :test #'equalp)
(setf description
(item-description (get-game-object 'item object-name))))
(if description
(format t "~&(~A) ~A" object-name description)
(format t "~&Could not find ~A!" object-name))))
Expand Down
2 changes: 1 addition & 1 deletion lisp/util.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ specified type in the container struct"
(format t "~&~S" (eval expr)))
(simple-input expr "lisp >"))))

;; FIXME Interesting phenomenon of repl (security bug?):
;; XXX Interesting phenomenon of repl (security bug?):
;; Enter two Lisp expressions that have not had a value assigned to them in the
;; current session (e.g. 'foo ls'). The first will cause the interpreter to
;; exit with an error. The second, however, is still printed to stdout (which is
Expand Down

0 comments on commit f370c57

Please sign in to comment.