-
Notifications
You must be signed in to change notification settings - Fork 0
/
tokenhandler.py
98 lines (59 loc) · 2.02 KB
/
tokenhandler.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
from classes import *
from locations import *
from items import *
import random
import pygame
import time
import threading
from pgmap import *
from methods import *
from methods import singleverbs
#one token command handler
def onetoken(command): #command = verb
verb = str(command[0])
if verb in singleverbs:
verbs[verb]()
else:
print("I'm gonna need more than that :( ")
pass
#two token command handler
def twotoken(command):#command = verb , item
#verb = string of first command token
verb = command[0]
#currentItem = string of second command token
currentItem = command[1]
#if item is in locaiton inventory
if currentItem in me.location.inventory:
itemobject = me.location.inventory[currentItem]
#pass item object to verb method if verb method in item's verbs dictionary
if verb in itemobject.verbs:
itemobject.verbs[verb](itemobject) #aka verb(item)
#valid item but invalid verb for item
else:
print('Cannot {} {}'.format(verb,currentItem))
#if item is in player inventory
elif currentItem in me.inventory:
itemobject = me.inventory[currentItem]
#pass item object to verb method if verb method in item's verbs dictionary
if verb in itemobject.verbs:
itemobject.verbs[verb](itemobject) #aka verb(item)
#valid item but invalid verb for item
else:
print('Cannot {} {}'.format(verb,currentItem))
else:
print("There is no {} here! ".format(currentItem))
#do not include for Midterm GDD / alpha build
def fourtoken(command):
pass
#token number identifier / handler
def tokenhandler(command):
length = len(command)
if length == 1:
onetoken(command)
elif length ==2:
#add walking / go condition
twotoken(command)
elif length ==3:
print("I dont understand")
elif length == 4:
fourtoken(command)