Skip to content

Commit

Permalink
game of truc working again but with messed up css
Browse files Browse the repository at this point in the history
  • Loading branch information
vii committed Jan 3, 2009
1 parent 50f082b commit 458dca0
Show file tree
Hide file tree
Showing 9 changed files with 66 additions and 92 deletions.
25 changes: 12 additions & 13 deletions src/blog/entry.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -93,19 +93,18 @@
("${static-base}" (blog-static-base-url (my blog)))))))

(defun parse-time (str)
(match-bind ( (- #\0 #\9)
(year (and ((string) a0 (month

(flet ((parse-number (str)
(or (and str (parse-integer str)) 0)))
(regex-bind ((#'parse-number year)
(#'parse-number month)
(#'parse-number date)
(#'parse-number hour)
(#'parse-number minute)
(#'parse-number second))
("(\\d\\d\\d\\d)\\D*(\\d\\d?)\\D*(\\d\\d?)\\D*(?:(\\d\\d?)\\D*(\\d\\d?)\\D*(?:(\\d\\d?))?)?" str)
(apply 'encode-universal-time (mapcar (lambda(x) (or x 0)) (list second minute hour date month year))))))
(match-bind
(macrolet ((int (name &optional (len 2))
`(progn t (,name (unsigned-byte :max-len ,len) 0))))
(int year 4)
(int month)
(int day)
(:?
(int hour)
(int minute)
(:? (int second))))
str
(encode-universal-time second minute hour day month year)))

(defun read-in-blog-entry (name)
(let ((blog-entry (make-blog-entry :name name)))
Expand Down
81 changes: 40 additions & 41 deletions src/game/web.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -137,10 +137,10 @@

friendly-move-type
"? "
(output-raw-ml (html-action-link "Yes" (my queue-choice t) (values)))

(html-action-link "Yes" (my queue-choice t) (values))
" "
(output-raw-ml (html-action-link "No" (my queue-choice nil) (values)))))
(html-action-link "No" (my queue-choice nil) (values))))
((eql :select-card (my move-type))
(<p friendly-move-type "."))
(t
Expand All @@ -150,13 +150,12 @@
(apply 'max (choices-list (my choices))) ". "))
(t
(with-ml-output (format nil " ~{~A ~}" (my args)) " from " (format nil "~A" (my choices) ))))

(output-raw-ml
(html-action-form
""
((choice (first (choices-list (my choices)))))
(my queue-choice (read-safely-from-string choice))
(values)))))))))

(html-action-form
""
((choice (first (choices-list (my choices)))))
(my queue-choice (read-safely-from-string choice))
(values))))))))



Expand All @@ -167,7 +166,7 @@
unless once do (<div :class "separate")
do (output-object-to-ml p))
(<div :style (css-attrib :clear "both" :float "none" :border "none"))))


(my-defun game 'object-to-ml :around ()
(if (my game-over)
Expand All @@ -191,40 +190,40 @@
(<div :class "game-header"
(<h2 :class "game-title"
(string-capitalize (force-string (game-name (my game-state))))))



(call-next-method)

(<div :class "talk"
(html-action-form "Talk "
(text)
(without-ml-output
(game-talk (my game-state) me text))))))

(my-defun web-state 'simple-channel-body-ml ()
(<div :class "game-state-body"
(<p :class "close-game"
(cond ((its game-over (my game-state))
(html-replace-link "Play again"
(web-game-start (game-generator (my game-state)))))
(t
(html-action-link "Resign"
(my resign))))))

(<div :class "messages-and-talk"
(<div :class tpd2.webapp::+html-class-scroll-to-bottom+
(output-object-to-ml (my announcements))))

(cond ((my resigned)
(<p "Resigned."))
(t
(output-object-to-ml (my game-state))

(when (my waiting-for-input)
(<div :class "moves"
(loop for m in (my waiting-for-input)
do
(output-object-to-ml m)))))))
(<div :class "game-state"
(<div :class "game-state-body"
(<p :class "close-game"
(cond ((its game-over (my game-state))
(html-replace-link "Play again"
(web-game-start (game-generator (my game-state)))))
(t
(html-action-link "Resign"
(my resign))))))

(<div :class "messages-and-talk"
(<div :class tpd2.webapp::+html-class-scroll-to-bottom+
(output-object-to-ml (my announcements))))

(cond ((my resigned)
(<p "Resigned."))
(t
(output-object-to-ml (my game-state))

(when (my waiting-for-input)
(<div :class "moves"
(loop for m in (my waiting-for-input)
do
(output-object-to-ml m))))))))

(my-defun player 'object-to-ml ()
(<div :class "player"
Expand Down Expand Up @@ -303,9 +302,9 @@
`(<head
(<title "mopoko.com " (output-raw-ml ,title))
(output-raw-ml
(<noscript
(output-raw-ml
(<meta :http-equiv "refresh" :content (byte-vector-cat "1000;" (page-link))))))
(<noscript
(output-raw-ml
(<meta :http-equiv "refresh" :content (byte-vector-cat "1000;" (page-link))))))
(css)
(webapp-default-page-head-contents))))

Expand Down Expand Up @@ -342,7 +341,7 @@

#+sbcl
(with-preserve-specials (*trace-output* *standard-output* *error-output* *debug-io*
#+tpd2-has-swank swank::*emacs-connection*)
#+tpd2-has-swank swank::*emacs-connection*)
(sb-thread:make-thread
(lambda()
(with-specials-restored
Expand Down
4 changes: 3 additions & 1 deletion src/http/request.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
(defprotocol http-read-chunked (con)
(let ((body
(loop
for len = (match-bind ((len (integer 16)) (* (space)) (last))
for len = (match-bind ((len (unsigned-byte :base 16
:max-len 7 ; maximum chunk size of (expt 16 7) = 268435456
)) (* (space)) (last))
(io 'recvline con)
len)
until (zerop len)
Expand Down
29 changes: 0 additions & 29 deletions src/lib/one-liners.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -41,35 +41,6 @@
:displaced-to vector
:displaced-index-offset start)))



(declaim (inline cdr-assoc))
(defun cdr-assoc (alist key &key (test 'eq))
(cdr (assoc key alist :test test)))


(define-setf-expander cdr-assoc (place key &key (test ''eq) &environment env)
(multiple-value-bind (dummies vals newval setter getter)
(get-setf-expansion place env)
(with-unique-names (store key-val test-val)
(values
(append dummies (list key-val test-val))
(append vals (list key test))
`(,store ,@newval)
(with-unique-names (tmp cur)
`(let (,@(loop for d in dummies
for v in vals
collect `(,d ,v))
(,cur ,getter))
(let ((,tmp (assoc ,key-val ,cur :test ,test-val)))
(cond (,tmp
(rplacd ,tmp ,store))
(t
(setf ,(first newval) (acons ,key ,store ,cur))
,setter))
,store)))
`(cdr-assoc ,getter)))))

(defmacro without-call/cc (&body body)
`(locally ,@body))

Expand Down
1 change: 1 addition & 0 deletions src/packages.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#:match-bind #:if-match-bind
#:match-failed )
(:import-from #:cl-irregsexp.utils
#:cdr-assoc
#:defun-consistent
#:declaim-defun-consistent-ftype
#:defun-speedy
Expand Down
6 changes: 3 additions & 3 deletions src/webapp/actions.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -69,12 +69,12 @@
(defpage-lambda +action-page-name+ #'action-respond-body (.id. .channels. .javascript. all-http-params)))


(my-defun frame 'object-to-ml ()
(my-defun frame 'simple-channel-body-ml ()
(<div :class "frame"
(<div :class "change-name"
(html-action-form "Your name " ((new-name (my username)))
(setf (my username) new-name)
(my notify)
(values)))
(output-object-to-ml (my messages))
(output-raw-ml (call-next-method))))
(output-object-to-ml (my messages))))

6 changes: 3 additions & 3 deletions src/webapp/list-channel.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
(my-defun list-channel del (message)
(deletef message (my list)))

(my-defun list-channel 'object-to-ml ()
(my-defun list-channel 'simple-channel-body-ml ()
(<div :class "list-channel"
(loop for x in (reverse (my list)) do
(output-object-to-ml x))
(output-raw-ml (call-next-method))))
(output-object-to-ml x))))

4 changes: 3 additions & 1 deletion src/webapp/simple-channel.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,6 @@
(simple-channel-body-ml me))))))))

(my-defun simple-channel 'object-to-ml ()
(<div :id (my id) (simple-channel-body-ml me)))
(<div :id (my id)
(simple-channel-body-ml me)
(call-next-method)))
2 changes: 1 addition & 1 deletion teepeedee2.asd
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

(pushnew "../cl-irregsexp/" asdf:*central-registry* :test #'equal)

#+comment-out
#+tpd2-debug
(progn
(proclaim '(optimize debug))
(pushnew :tpd2-debug-assert *features*))
Expand Down

0 comments on commit 458dca0

Please sign in to comment.