diff --git a/src/atlantis.lisp b/src/atlantis.lisp index 8fc7d4c..b6b0011 100644 --- a/src/atlantis.lisp +++ b/src/atlantis.lisp @@ -14,13 +14,19 @@ (defun start-server () "Start a new game on a server" - ) + (format t "~&What world file do you want to load?") + ;Gonna have a problem with Lisp smashing case on the file name + (input world-file) + (format t "~&What port should the game run on?") + (while (not (numberp (input port))) + (format t "~&Not a number: ~A. Please reenter:" port)) + (format t "~&Loading file ~A on port ~A" (string world-file) port)) (defun join-game () "Join a running game on the server" (format t "~&What is the IP address of the server you want to join?") (input ip) - (while (not (= (count-instances "." (symbol-name ip)) 3)) + (while (not (= (count-instances #\. (to-list (string ip))) 3)) (format t "~&Not an IP address: ~A. Please reenter:" ip) (input ip)) (format t "~&What port does the game run on?") diff --git a/src/atlantis.lisp b/src/atlantis.lisp index 8fc7d4c..b6b0011 100644 --- a/src/atlantis.lisp +++ b/src/atlantis.lisp @@ -14,13 +14,19 @@ (defun start-server () "Start a new game on a server" - ) + (format t "~&What world file do you want to load?") + ;Gonna have a problem with Lisp smashing case on the file name + (input world-file) + (format t "~&What port should the game run on?") + (while (not (numberp (input port))) + (format t "~&Not a number: ~A. Please reenter:" port)) + (format t "~&Loading file ~A on port ~A" (string world-file) port)) (defun join-game () "Join a running game on the server" (format t "~&What is the IP address of the server you want to join?") (input ip) - (while (not (= (count-instances "." (symbol-name ip)) 3)) + (while (not (= (count-instances #\. (to-list (string ip))) 3)) (format t "~&Not an IP address: ~A. Please reenter:" ip) (input ip)) (format t "~&What port does the game run on?") diff --git a/src/interpreter.lisp b/src/interpreter.lisp new file mode 100644 index 0000000..3a1fe40 --- /dev/null +++ b/src/interpreter.lisp @@ -0,0 +1,10 @@ +;;; +;;; Atlantis is a framework for creating multi-user dungeon worlds. +;;; This is the Common Lisp implementation. +;;; +;;; The interpreter file loads an ATL source file and parses it. +;;; +;;; Licensed under the terms of the GPLv3 +;;; author: Daniel Vedder +;;; date: 09/05/2015 +;;; diff --git a/src/atlantis.lisp b/src/atlantis.lisp index 8fc7d4c..b6b0011 100644 --- a/src/atlantis.lisp +++ b/src/atlantis.lisp @@ -14,13 +14,19 @@ (defun start-server () "Start a new game on a server" - ) + (format t "~&What world file do you want to load?") + ;Gonna have a problem with Lisp smashing case on the file name + (input world-file) + (format t "~&What port should the game run on?") + (while (not (numberp (input port))) + (format t "~&Not a number: ~A. Please reenter:" port)) + (format t "~&Loading file ~A on port ~A" (string world-file) port)) (defun join-game () "Join a running game on the server" (format t "~&What is the IP address of the server you want to join?") (input ip) - (while (not (= (count-instances "." (symbol-name ip)) 3)) + (while (not (= (count-instances #\. (to-list (string ip))) 3)) (format t "~&Not an IP address: ~A. Please reenter:" ip) (input ip)) (format t "~&What port does the game run on?") diff --git a/src/interpreter.lisp b/src/interpreter.lisp new file mode 100644 index 0000000..3a1fe40 --- /dev/null +++ b/src/interpreter.lisp @@ -0,0 +1,10 @@ +;;; +;;; Atlantis is a framework for creating multi-user dungeon worlds. +;;; This is the Common Lisp implementation. +;;; +;;; The interpreter file loads an ATL source file and parses it. +;;; +;;; Licensed under the terms of the GPLv3 +;;; author: Daniel Vedder +;;; date: 09/05/2015 +;;; diff --git a/src/util.lisp b/src/util.lisp index 50a07d8..a6aca58 100644 --- a/src/util.lisp +++ b/src/util.lisp @@ -23,9 +23,17 @@ ,@body)) -;TODO -(defun count-instances (search-term search-vector) - "Count the number of instances of search-term in search-vector" - (let (n (find-if #'(lambda (a) (equalp a search-term)) search-vector)) - (if (null n) 0 - ()))) +(defun count-instances (search-term search-list) + "Count the number of instances of search-term in search-list" + (do ((lst (cdr (member search-term search-list)) + (cdr (member search-term lst))) + (counter 0 (1+ counter))) + ((null lst) counter))) + +; Probably quite inefficient, maybe remove this function later +(defun to-list (vector) + "Turn the vector into a list" + (do* ((i 0 (1+ i)) + (e (aref vector i) (aref vector i)) + (lst (list e) (cons e lst))) + ((= i (1- (length vector))) (reverse lst))))