Skip to content
Newer
Older
100644 45 lines (36 sloc) 2.36 KB
b190dd9 @yasht Updated utilities
yasht authored Feb 12, 2012
1 #| This file is part of MULCH.
3596e6e @yasht moved structs to structs.lisp
yasht authored Jan 15, 2012
2
b190dd9 @yasht Updated utilities
yasht authored Feb 13, 2012
3 MULCH is free software: you can redistribute it and/or modify
4 it under the terms of the GNU General Public License as published by
5 the Free Software Foundation, either version 3 of the License, or
6 (at your option) any later version. |# #|
7
8 MULCH is distributed in the hope that it will be useful,
9 but WITHOUT ANY WARRANTY; without even the implied warranty of
10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 GNU General Public License for more details.
12
13 You should have received a copy of the GNU General Public License
14 ;along with MULCH. If not, see <http://www.gnu.org/licenses/>.|#
15
16 ;structs.lisp
3596e6e @yasht moved structs to structs.lisp
yasht authored Jan 16, 2012
17
18 ;Rooms, people, objects...
b190dd9 @yasht Updated utilities
yasht authored Feb 13, 2012
19 (defstruct locale key name light north east south west northeast southwest northwest southeast players objects))))
20 ;Key identifies it for me.
21 ;Name is the name associated with it in-game, so while key could be "living-room-1", name would be "Fred Foobar's Living Room"
22 ;! Put this in a hash table, just like users!
23 (defparameter *rooms* (make-hash-table))
24
25 ;To prevent bugs with players and objects, create a "build-room" function that takes a name, setfs a var to the room, calls players-at and objects-at to define the objects and players....
a95828a @yasht Changed players-at function
yasht authored Feb 23, 2012
26 ;Edit: above comment will no longer be needed
b190dd9 @yasht Updated utilities
yasht authored Feb 13, 2012
27 (defun players-at ()
a95828a @yasht Changed players-at function
yasht authored Feb 24, 2012
28 (let ((player-list ()))
29 (labels ((players-at-indiv (room)
30 (maphash #'(lambda (players-i)
31 (if (equalp (player-location players-i) (locale-name room))
32 (cons players-i player-list))) *users*)
33 (setf (locale-players room) player-list)))
34 (maphash #'players-at-indiv *rooms*))))
35
36
3596e6e @yasht moved structs to structs.lisp
yasht authored Jan 16, 2012
37 ;Objects-at will probably have a cleaner design--I'll make an alist of objects and their locations, so it'll be easier to go through it...
b190dd9 @yasht Updated utilities
yasht authored Feb 13, 2012
38 (defstruct player name password gender species health mana level experience stream location saved-location con cha cre str dex inventory) ;Set some default values for these, maybe change to defclass. ALSO: make int wis str dex cha etc....
12a88c6 @yasht Added basic communication functions
yasht authored Jan 21, 2012
39 ;Also, write a function that dolists through the players and if their experience is above, say, 100, then incf their level and setf the experience to their experience minus 100. Have this running at all times.
b190dd9 @yasht Updated utilities
yasht authored Feb 13, 2012
40 (defun find-player-from-stream (stream)
41 (labels ((find-player-from-stream-aux (players-i)
42 (if (equalp (player-stream players-i) stream)
43 players-i)))
44 (maphash #'find-player-from-stream-aux *users*)))
Something went wrong with that request. Please try again.