summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJed Barber <jjbarber@y7mail.com>2014-04-03 21:00:02 +1100
committerJed Barber <jjbarber@y7mail.com>2014-04-03 21:00:02 +1100
commit133d71983ea4e39e6e971ca052b2eb0bf7437cc6 (patch)
tree4597b5908638ce483b6da9dfa3bc3d72d54482c1
parent171d92ab3de4874e981f567603ec38d9a0885bc1 (diff)
Basic commands added
-rw-r--r--command.prolog38
1 files changed, 37 insertions, 1 deletions
diff --git a/command.prolog b/command.prolog
index 4e8c5d7..b8989f4 100644
--- a/command.prolog
+++ b/command.prolog
@@ -3,9 +3,45 @@
:- module(command, [getCommand/2]).
+:- consult('parser.prolog').
+
+
% functions for parsing a list of words into a recognised command
-getCommand(L,C) :- C =.. L. % placeholder
+getCommand(['quit'],C) :- C = [quit].
+getCommand(['exit'],C) :- C = [quit].
+
+
+getCommand(['go',X],C) :- C = [move,X].
+getCommand(['move',X],C) :- C = [move,X].
+
+
+getCommand(['n'],C) :- C = [move,north].
+getCommand(['north'],C) :- C = [move,north].
+getCommand(['s'],C) :- C = [move,south].
+getCommand(['south'],C) :- C = [move,south].
+getCommand(['e'],C) :- C = [move,east].
+getCommand(['east'],C) :- C = [move,east].
+getCommand(['w'],C) :- C = [move,west].
+getCommand(['west'],C) :- C = [move,west].
+
+
+getCommand(['nw'],C) :- C = [move,northwest].
+getCommand(['northwest'],C) :- C = [move,northwest].
+getCommand(['ne'],C) :- C = [move,northeast].
+getCommand(['northeast'],C) :- C = [move,northeast].
+getCommand(['sw'],C) :- C = [move,southwest].
+getCommand(['southwest'],C) :- C = [move,southwest].
+getCommand(['se'],C) :- C = [move,southeast].
+getCommand(['southeast'],C) :- C = [move,southeast].
+
+
+getCommand(['take',X],C) :- C = [take,X].
+getCommand(['shoot',X],C) :- C = [shoot,X].
+
+
+getCommand(['l'],C) :- C = [look].
+getCommand(['look'],C) :- C = [look].