Skip to content

Commit

Permalink
Moves by name now works!
Browse files Browse the repository at this point in the history
  • Loading branch information
nixeagle committed Apr 1, 2011
1 parent 4ced18d commit 326990d
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 20 deletions.
29 changes: 22 additions & 7 deletions handle-command.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,11 @@
(when (cdr cmd)
(let ((int (parse-integer (cdr cmd) :junk-allowed t)))
(if (and int (< 0 int pokemon::+total-moves+))
(reply con msg (html-escape (princ-to-string (aref pokemon::*movedex* int))))
(reply con msg "Sorry that move number does not exist!"))))))
(reply con msg (move-to-html-string (aref pokemon::*movedex* int)))
(let ((poke (find (cdr cmd) pokemon::*movedex* :test #'string= :key #'pokemon::name)))
(if poke
(reply con msg (move-to-html-string poke))
(reply con msg "Sorry that move number does not exist!"))))))))

(defmethod handle-command ((cmd (eql :eval)) (con connection) (msg message))
(let ((cmd (split-at-first #\ (cdr (parse-nickname-and-message msg)))))
Expand All @@ -40,9 +43,10 @@

(defmethod handle-command ((cmd (eql :describe)) (con connection) (msg message))
(let ((cmd (split-at-first #\ (cdr (parse-nickname-and-message msg)))))
(when (cdr cmd)
(reply con msg (with-output-to-string (s) (pprint
(handler-case (describe-to-html-string (eval (let ((*package* (find-package :pokemon.po.client))) (read-from-string (cdr cmd) nil "Sorry malformed input. Did you forget a closing paren?")))) (error (condition) condition)) s))))))
(when (string= "nixeagle" (car (parse-nickname-and-message msg)))
(when (cdr cmd)
(reply con msg (with-output-to-string (s) (pprint
(handler-case (describe-to-html-string (eval (let ((*package* (find-package :pokemon.po.client))) (read-from-string (cdr cmd) nil "Sorry malformed input. Did you forget a closing paren?")))) (error (condition) condition)) s)))))))


(defun html-escape (input)
Expand All @@ -58,15 +62,26 @@
(flet ((header-col (text)
(cl-who:with-html-output (s *standard-output*)
(:td :align :center :bgcolor :black
(:font :color "white" (:b (cl-who:esc text)))))))
(:font :color "white" (:b (cl-who:esc text))))))
(stat-box (num)
(cl-who:with-html-output (s *standard-output*)
(:td :align :center :bgcolor :gray
(:font :color "black" (:b (cl-who:esc (princ-to-string num))))))))
(cl-who:with-html-output-to-string (*standard-output*)
(:table :width "80%" :align :center :cellspacing 0 :cellpadding 0 :border 1
(:tr (header-col "Move Name")
(header-col "Move Type")
(header-col "Move Category")
(header-col "Base Power")
(header-col "Accuracy")
(header-col "PP MAX"))))))
(header-col "PP MAX"))
(:tr (stat-box (pokemon::name move))
(stat-box (pokemon::poketype move))
(stat-box (pokemon::category move))
(stat-box (pokemon::power move))
(stat-box (pokemon::accuracy move))
(stat-box (pokemon::pp move)))
(:tr (:td (cl-who:esc (pokemon::effect-description move))))))))

(defmethod handle-command ((cmd (eql :test)) (con connection) (msg message))
(let ((cmd (split-at-first #\ (cdr (parse-nickname-and-message msg)))))
Expand Down
11 changes: 0 additions & 11 deletions po-data-import.lisp
Original file line number Diff line number Diff line change
@@ -1,17 +1,6 @@
(in-package :pokemon)

(defparameter *po-directory* "c:/cygwin/home/Tim/repos/pogeymon-online/"
"Full path to where Pokemon Online source/installation is.

Make sure your file path ends with a trailing slash!")

(defun import-csv-as-list (filepath)
(with-open-file (s filepath :direction :input)
(read-line s nil);; ignore the header line
(loop for line = (read-line s nil)
while line collect
(let ((sp (split-sequence #\, line)))
(list (parse-integer (car sp)) (cdr sp))))))

(defun make-po-data-filepath (file)
(declare (type string file))
Expand Down
7 changes: 6 additions & 1 deletion pokemon.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -597,4 +597,9 @@ Indexed by the pokemon's ID in the national pokedex.")
(format stream "~A HP: ~A ATK: ~A DEF: ~A SP-ATK ~A SP-DEF ~A SPD ~A"
(name obj) (hp stats) (attack stats) (defense stats)
(special-attack stats) (special-defense stats)
(speed stats)))))
(speed stats)))))

(defparameter *po-directory* "c:/cygwin/home/Tim/repos/pogeymon-online/"
"Full path to where Pokemon Online source/installation is.
Make sure your file path ends with a trailing slash!")
8 changes: 7 additions & 1 deletion shania.asd
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,10 @@
;;; written to mandate using multiple source files.

(asdf:defsystem :shania
:depends-on (:eos :hunchentoot :alexandria :split-sequence :iterate :cl-who))
:depends-on (:eos :hunchentoot :alexandria :split-sequence :iterate :cl-who)
:components ((:file "pokemon")
(:file "po-data-import" :depends-on ("pokemon"))
(:file "pokedex" :depends-on ("pokemon" "po-data-import"))
(:file "po-client")
(:file "movedex" :depends-on ("pokemon" "po-data-import"))
(:file "handle-command" :depends-on ("po-client" "pokemon"))))

0 comments on commit 326990d

Please sign in to comment.