コード例 #1
0
ファイル: actionop.py プロジェクト: jthantranon/mealpha8
def DepthPerception(before,after,vision=False):
    cmeta = ops.loadmeta()
    cloc = ops.loadcloc()
    bMetaIDs = ops.fetchXYZMIDs(before.xyz)
    aMetaIDs = ops.fetchXYZMIDs(after.xyz)
    eMetaIDs = ops.conKIDs(bMetaIDs, aMetaIDs)
    pack = Packet()
    pack.refresh = True
    pack.who = cmeta.kid
    
    if before.databits != after.databits:
        pack.type = 'Databits'
        pack.metakind = before.metakind
        pack.metaid = before.metaid
        pack.kid = before.kid
        pack.medo = after
        for metaID in eMetaIDs:
            channel.send_message(str(metaID), ops.jsonify(pack))
    elif before.xyz != after.xyz: #Relocation
        pack.metakind = before.metakind
        pack.metaid = before.metaid
        pack.kid = before.kid
        pack.fromkind = before.cokind
        pack.tokind = after.cokind 
        pack.fromkid = before.cokind + str(before.coid)
        pack.tokid = after.cokind + str(after.coid)
        pack.medo = after
#        for metaID in eMetaIDs:
#            channel.send_message(str(metaID), ops.jsonify(pack))
        for bMeta in bMetaIDs:
            pack.type = 'MedoMove'
            channel.send_message(str(bMeta), ops.jsonify(pack))
        for aMeta in aMetaIDs:
            if after.metakind != 'Meta':
                if after.cowner == cmeta.kid:
                    pack.type = 'ItemUpdate'
                else:
                    pack.type = 'ItemArrive'
            elif aMeta == cmeta.metaid:
                #ops.mdb(aMeta, 'test')
                pack.type = 'YouArrive'
                pack.cloc = cloc
                pack.nMetas = ops.fetchLocalMetas(after.metakind, after.metaid)
                pack.nItems = ops.fetchLocalItems(after.metakind, after.metaid)
            else:
                pack.type = 'MetaArrive'    
            channel.send_message(str(aMeta), ops.jsonify(pack))
    else:
        ops.mdb('This is else')

    if vision:
        for metaID in eMetaIDs:
            pack = Packet()
            pack.type = 'vision'
            pack.vision = True
            pack.formatted = vision
            channel.send_message(str(metaID), ops.jsonify(pack))
コード例 #2
0
ファイル: edenop.py プロジェクト: Charkova/MetaEden09a
def SelfEcho(content):
    cmeta = ops.loadmeta()
    pack = Packet()
    sloc = ops.loadcloc()
    
    pack.scopename = sloc.name
    pack.type = 'action'
    pack.scope = 'local'
    pack.formatted = content
    pack.content = content + " hohum"
    pack.masterid = str(cmeta.masterid)
    pack.name = cmeta.name
    pack.metakind = cmeta.metakind
    pack.metaid = cmeta.metaid
    channel.send_message(str(cmeta.metaid), ops.jsonify(pack))
コード例 #3
0
ファイル: edenop.py プロジェクト: Charkova/MetaEden09a
def MetaEcho(content):
    cmeta = ops.loadmeta()
    pack = Packet()
    localmetas = ops.fetchLocalMetaMetaIDs('Meta',cmeta.metaid)
    sloc = ops.loadcloc()
    formatted = "["+sloc.name+"]<b> " + cmeta.name + "</b>: " + content + " haha"
    for localmeta in localmetas:
        pack.scopename = sloc.name
        pack.type = 'broadcast'
        pack.scope = 'local'
        pack.formatted = formatted
        pack.content = content + " hoho"
        pack.masterid = str(cmeta.masterid)
        pack.name = cmeta.name
        pack.metakind = cmeta.metakind
        pack.metaid = cmeta.metaid
        channel.send_message(str(localmeta), ops.jsonify(pack))
コード例 #4
0
ファイル: edenop.py プロジェクト: Charkova/MetaEden09a
    def post(self,metakind,metaid,dkind,did):
        
        mobject = ndb.Key(metakind, int(metaid)).get()
        
        
        
        if 'Location' in mobject.cowner:
            ops.updateclocstate()    
        
        mobject.cowner = dkind+'.'+did
        
        if metakind == 'Meta':
            pass
        elif dkind == 'Location':
            cloc = ops.loadcloc()
            mobject.xloc = cloc.xloc
            mobject.yloc = cloc.yloc
            mobject.zloc = cloc.zloc
            mobject.put()
            ops.updateclocstate()
            
        elif dkind == 'Meta':
            
            cmeta = ops.loadmeta()
            
            nowner = ndb.Key('Meta', int(did)).get()
            pack = Packet()
            pack.type = 'reinv'
            pack.masterid = str(cmeta.masterid)
            pack.name = cmeta.name
            pack.metakind = 'Meta'
            pack.metaid = cmeta.metaid
            pack = json.dumps(pack.to_dict())
            channel.send_message(nowner.masterid, pack)
            
            
            mobject.xloc = ''
            mobject.yloc = ''
            mobject.zloc = ''
            mobject.put()
        
        mobject = mobject.to_dict()
        jsonData = json.dumps(mobject)

        self.response.out.write(jsonData)
コード例 #5
0
ファイル: edenop.py プロジェクト: Charkova/MetaEden09a
    def post(self,dest):
        cmeta = ops.loadmeta()
        sloc = ops.loadcloc()
        content = self.request.get('content')
        pack = Packet()
        
        if dest == 'command':
            cProc(self.request.get('content'))
            ops.mdb(self.request.get('content'), 'command pack')
            formatted = "["+sloc.name+"]<b> " + cmeta.name + "</b>: " + self.request.get('content')
            packtype = 'broadcast'
            scopename = sloc.name
            scope = 'local'

        if dest == 'local':
            
            packtype = 'broadcast'
            scopename = sloc.name
            scope = 'local'
            formatted = "["+sloc.name+"]<b> " + cmeta.name + "</b>: " + self.request.get('content')
            console = True
            
            PackPacket(console,packtype,scopename,scope,formatted,content)
            
        if dest == 'global':
#            if self.request.get('content')[0] == '@':
#                formatted = self.request.get('content')[1:]
#            else:
#                formatted = "[Global]<b> " + cmeta.name + "</b>: " + self.request.get('content')

            packtype = 'broadcast'
            scopename = 'Global'
            scope = 'global'
            formatted = "[Global]<b> " + cmeta.name + "</b>: " + self.request.get('content')
            console = True
            
            PackPacket(console,packtype,scopename,scope,formatted,content)

        elif dest == 'login':
          
            packtype = 'userlogin'
            scopename = 'System'
            scope = 'system'
            content = cmeta.name + "</b> has logged into MetaEden."
            formatted = "[System]<b> " + cmeta.name + "</b> has logged into MetaEden."
            console = 'edenop.ChanRouter.dest==login'
            
            PackPacket(console,packtype,scopename,scope,formatted,content,cmeta)
            
        elif dest == 'pm':
            metakind = self.request.get('metakind')
            metaid = self.request.get('metaid')
            content = self.request.get('content')
            formatted = "[PM]<b> " + cmeta.name + "</b>: " + content
            pack.type = 'pm'
            pack.scope = 'private'
            pack.formatted = formatted
            pack.content = content
            pack.masterid = str(cmeta.masterid)
            pack.name = cmeta.name
            pack.metakind = cmeta.metakind
            pack.metaid = str(cmeta.metaid)
            channel.send_message(str(metaid), ops.jsonify(pack))
            pack.name = metakind+metaid 
            pack.metakind = metakind
            pack.metaid = metaid
            self.response.out.write(ops.jsonify(pack))
        else:
            pack.type = 'msg'
            pack.content = content
            pack.to = str(dest)
            pack.masterid = str(cmeta.masterid)
            pack.name = cmeta.name
            pack.metakind = 'Meta'
            pack.metaid = cmeta.metaid
            pack = json.dumps(pack.to_dict())
            channel.send_message(str(dest), pack)
            self.response.out.write(pack)
コード例 #6
0
ファイル: TEMPmodels.py プロジェクト: Charkova/MetaEden09a
 def locname(self):
     cloc = ops.loadcloc()
     return cloc.name
コード例 #7
0
ファイル: actionop.py プロジェクト: jthantranon/mealpha8
 def post(self, direction):
     cmeta = ops.loadmeta()
     cmeta.cokind = 'Location' #Not robust
     premove = copy.copy(ops.loadmeta())
     
     
     
     cloc = ops.loadcloc()
     localmetas = ops.fetchLocalMetaMetaIDs('Meta',cmeta.metaid)
     
     pack = Packet()
     pack.scope = 'local'
     pack.type = 'move'
     
     
     for localmeta in localmetas:
         if localmeta == cmeta.metaid:
             pack.content = "You move " + ops.dirFull(direction) + "."
             pack.type = 'usermove'
             channel.send_message(str(localmeta), ops.jsonify(pack))
         else:
             pack.content = cmeta.name + " has moved " + ops.dirFull(direction)
             pack.name = cmeta.name
             pack.destination = ops.dirFull(direction)
             pack.type = 'userleave'
             channel.send_message(str(localmeta), ops.jsonify(pack))
     
     
     
     if direction == 'n':
         cmeta.yloc = str(int(cmeta.yloc)+1)
     elif direction == 's':
         cmeta.yloc = str(int(cmeta.yloc)-1)
     elif direction == 'e':
         cmeta.xloc = str(int(cmeta.xloc)+1)
     elif direction == 'w':
         cmeta.xloc = str(int(cmeta.xloc)-1)
     elif direction == 'u':
         cmeta.zloc = str(int(cmeta.zloc)+1)
     elif direction == 'd':
         cmeta.zloc = str(int(cmeta.zloc)-1)
     elif direction == 'ne':
         cmeta.xloc = str(int(cmeta.xloc)+1)
         cmeta.yloc = str(int(cmeta.yloc)+1)
     elif direction == 'se':
         cmeta.xloc = str(int(cmeta.xloc)+1)
         cmeta.yloc = str(int(cmeta.yloc)-1)
     elif direction == 'sw':
         cmeta.xloc = str(int(cmeta.xloc)-1)
         cmeta.yloc = str(int(cmeta.yloc)-1)
     elif direction == 'nw':
         cmeta.xloc = str(int(cmeta.xloc)-1)
         cmeta.yloc = str(int(cmeta.yloc)+1)
     cmeta.put()
     
     newlocalmetas = ops.fetchLocalMetaMetaIDs('Meta',cmeta.metaid)
     
     for newlocalmeta in newlocalmetas:
         if newlocalmeta == cmeta.metaid:
             pass
         else:
             pack.content = cmeta.name + " has arrived from the " + ops.dirOpp(direction)
             pack.type = 'userenter'
             pack.name = cmeta.name
             pack.destination = ops.dirOpp(direction)
             channel.send_message(str(newlocalmeta), ops.jsonify(pack))
     
     DepthPerception(premove,cmeta)
     #self.response.out.write(cmeta.xloc+cmeta.yloc+cmeta.zloc+cmeta.lattice)
     nLocaMetas = ops.fetchLocalMetas(Meta, cmeta.metaid)
     nloc = Packet()
     nloc.locdata = cloc
     nloc.metashere = nLocaMetas
     self.response.out.write(ops.jsonify(nloc))