Permalink
Browse files

redesign game UI to make it slightly less atrocious

  • Loading branch information...
1 parent 001e6e4 commit f6053c53a6aec44634d1e3f2c5067621e2f1b02a @vii committed Jun 3, 2012
@@ -124,7 +124,7 @@
((my blackjack)
(<p :class "blackjack" "Blackjack!"))))))
-(my-defun blackjack-player 'object-to-ml ()
+(my-defun blackjack-player 'player-full-state-to-ml ()
(<div :class "blackjack-player"
(call-next-method)
(loop for h in (my hands)
View
@@ -12,7 +12,7 @@
do
(setf (player-controller-var p 'coins) (its coins p))))
-(my-defun coin-game-player 'object-to-ml ()
+(my-defun coin-game-player 'player-full-state-to-ml ()
(<div :class "coin-game-player"
(call-next-method)
(let ((coins (or (my coins) (my 'player-controller-var 'coins))))
View
@@ -28,7 +28,7 @@
(random-elt (choices-list choices)))
(my-defun game finished (&rest args)
- (setf (my game-over) t)
+ (setf (my game-over) (list* :game-over args))
(apply 'game-announce me :game-over args)
(values))
@@ -40,6 +40,11 @@
(my-defun player announce (message &rest args)
(apply 'game-announce (my game) message args))
+(defgeneric player-full-state-to-ml (player))
+
+(my-defun player full-state-to-ml ()
+ (object-to-ml me))
+
(my-defun game listeners ()
(append (mapcar 'player-controller (my players)) (my other-listeners)))
@@ -173,4 +178,4 @@
(defmethod (setf player-controller-var) (new-value (player player) var)
(setf (player-controller-var (player-controller player) var) new-value))
(defmethod player-controller-name-to-ml ((player player))
- (player-controller-name-to-ml (player-controller player)))
+ (player-controller-name-to-ml (player-controller player)))
View
@@ -1,21 +1,24 @@
(in-package #:tpd2.game)
(defmacro def-web-state-message (message args &body body)
- `(my-defun web-state 'inform (game-state (message (eql ,message)) &key ,@args &allow-other-keys)
- (declare (ignorable game-state))
- (macrolet ((a (&rest args)
- `(my add-announcement (<p :class "game-message" ,@args))))
- ,@body)))
+ `(progn
+ (defmethod message-to-ml ((message (eql ,message)) &key ,@args &allow-other-keys)
+ (declare (ignorable game-state))
+ (with-ml-output ,@body))
+ (my-defun web-state 'inform (game-state (message (eql ,message)) &key ,@args &allow-other-keys)
+ (declare (ignorable game-state))
+ (my add-announcement (<p :class "game-message" ,@body)))))
(macrolet ((messages (&body body)
`(progn
,@(loop for (keyword args . ml) in body
collect `(def-web-state-message ,keyword ,args
- (a ,@ml))))))
+ ,@ml)))))
(messages
(:talk (sender text)
(<span :class "game-talk-message" sender ": " (<q text)))
+ (:shuffle () "The deck has been shuffled.")
(:new-player (player)
player " has joined the game.")
(:resigned (player)
@@ -57,7 +60,7 @@
(t
(when result
(with-ml-output
- (friendly-string result) ".")
+ (friendly-string result) ". ")
"Game over."))))
(:demand (player amount)
player " demanded " amount ".")
Oops, something went wrong.

0 comments on commit f6053c5

Please sign in to comment.