/
prototypes.py
138 lines (120 loc) · 3.87 KB
/
prototypes.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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
import webapp2
import jinja2
import os
#import jsonutil
import intops as ops
#import json
import json
from models import *
from google.appengine.api import users
from google.appengine.ext import ndb
from google.appengine.api import channel
class Spawn():
def Location(self):
nloc = Location()
nloc.name = 'Unnamed Location'
nloc.info = 'A new location.'
nloc.xloc = '500'
nloc.yloc = '500'
nloc.zloc = '500'
nloc.lattice = '0'
nloc.put()
def spawnLoca(para):
nloc = Location()
nloc.name = para.name
nloc.info = para.info
nloc.xloc = para.xloc
nloc.yloc = para.yloc
nloc.zloc = para.zloc
nloc.lattice = para.lattice
nloc.exits = 'n,s,e,w'
nloc.walls = 'nw,ne,se,sw'
nloc.put()
def CreateDataMine():
cmeta = ops.loadmeta()
spec = Item();
spec.name = 'Data Mine 4'
spec.info = 'This is a test item.'
spec.itype = 'Test'
spec.primertype = 'Generic'
spec.shardtype = 'Generic'
spec.fragtype = 'Generic'
spec.cowner = 'Meta'+str(cmeta.metaid)
spec.lattice = '0'
spec.metakind = 'Item'
spec.actions = ['Mine Node','Kick']
spec.supertype = 'Landmark'
spec.regtype = 'Mine'
spec.databit = 0
spec.ispopup = True
spec.xloc = '500'
spec.yloc = '500'
spec.zloc = '500'
spec.put()
spec.metaid = spec.key.id()
spec.put()
def CreateDigiFort():
cmeta = ops.loadmeta()
spec = Item();
spec.name = 'Digital Fortress of ' + cmeta.name
spec.info = 'This is a test item.'
spec.itype = 'Test'
spec.primertype = 'Generic'
spec.shardtype = 'Generic'
spec.fragtype = 'Generic'
spec.cowner = 'Meta'+str(cmeta.metaid)
spec.lattice = '0'
spec.metakind = 'Item'
spec.actions = ['Enter']
spec.supertype = 'Landmark'
spec.regtype = 'Mine'
spec.databit = 0
spec.put()
spec.metaid = spec.key.id()
spec.put()
class SpawnMeta(webapp2.RequestHandler):
def post(self):
meta = Meta()
meta.name = self.request.get('regname')
meta.info = self.request.get('reginfo')
meta.masterid = ops.cmasterid()
meta.email = ops.cemail()
meta.put()
meta.metaid = meta.key.id()
meta.put()
class CreateYTItem(webapp2.RequestHandler):
def post(self):
cmeta = ops.loadmeta()
spec = Item();
spec.name = self.request.get('title')
spec.info = self.request.get('info')
spec.itype = 'YouTube'
spec.primertype = 'Item'
spec.shardtype = 'Generic'
spec.fragtype = 'YouTube'
spec.cowner = 'Meta'+str(cmeta.metaid)
spec.lattice = '0'
spec.metakind = 'Item'
spec.ytlink = self.request.get('ytlink')
spec.actions = ['Kick','Watch']
spec.put()
spec.metaid = spec.key.id()
spec.put()
class Modify(webapp2.RequestHandler):
def post(self, metakind,metaid):
metaid = int(metaid)
metaobj = ndb.Key(metakind,metaid).get()
for data in self.request.arguments():
if data == 'createorder':
continue
setattr(metaobj,data,self.request.get(data))
metaobj.put()
ops.changed(metakind,metaid)
class Test(webapp2.RequestHandler):
def get(self):
self.response.out.write(ops.fetchLocalMetas('Meta', 37))
app = webapp2.WSGIApplication([('/unicon/test', Test),
(r'/unicon/modify/(.*)/(.*)', Modify),
('/unicon/spawn/meta', SpawnMeta),
('/unicon/create/ytitem', CreateYTItem),
],debug=True)