from py.page_maker.chunks import chunks
from py.page_maker.Settings import Settings
from py.lib.bottle.bottle import template
from py.getAsteroid import byName

CHUNKS = chunks()

def asteroidTrackResponder(asteroidName, user, webSock, OOIs):
    # responds to asteroid track requests by sending html for a tile to be added to the content section
    message = '{"cmd":"addToContent","data":"'
    
    if user.purchase('asteroidTrack'):
        print 'request to track '+asteroidName+' accepted.'
        
        OOIs.addObject(byName(asteroidName), user.name)
        # write the new js file(s)
        OOIs.write2JSON(Settings('default').asteroidDB,Settings('default').ownersDB)
        print 'object '+asteroidName+' added to OOIs'
        message+= template('tpl/content/tiles/asteroidAdd',
            objectName=asteroidName,
            chunks=CHUNKS,
            config=Settings('default'),
            pageTitle='Asteroid Add Request Approved',
            user=user)
    else:
        print 'request to track '+asteroidName+' denied. insufficient funds.'
        message+= template('tpl/content/tiles/insufficientFunds',
            objectName=asteroidName,
            chunks=CHUNKS,
            config=Settings('default'),
            pageTitle='Asteroid Add Request Denied',
예제 #2
0
from py.query_parsers.DemoUsers import getDemoProfile, demoIDs

# game logic:
from py.game_logic.user.User import User
from py.game_logic.GameList import GameList
from py.game_logic.UserList import UserList

# server setup settings:
import config


#=====================================#
#              GLOBALS                #
#=====================================#
app = Bottle()
CHUNKS = chunks()  # static chunks or strings for the site
DOMAIN = config.DOMAIN  # domain name
GAMES = GameList()  # list of ongoing games on server
GAMES.unpickle()  # restores any games that were saved last time server shut down

USERS = UserList()  # list of users on the server TODO: replace use of this w/ real db.
MASTER_CONFIG = 'default'  # config keyword for non-test pages. (see Config.py for more info)
loginTokens = []


#=====================================#
#            Static Routing           #
#=====================================#
@app.route('/css/<filename:path>')
def css_static(filename):
    return static_file(filename, root='./css/')
예제 #3
0
import json
from ast import literal_eval

from bottle import template

from py.game_logic.user.User import User
from py.generate_traj import gen_traj
from py.page_maker.chunks import chunks
from py.page_maker.Settings import Settings
from asteroid_tracker import asteroid_track_request_responder

CHUNKS = chunks()


class SetEncoder(json.JSONEncoder):
    def default(self, obj):
        if isinstance(obj, set):
            return list(obj)
        return json.JSONEncoder.default(self, obj)


def registerUserConnection(user, ws):
    # saves user websocket connetion so that updates to the user object can push to the client
    user.websocket = ws
    user.disconnected = False


def researchResponder(user, researchType):
    message = '{"cmd":"addToContent","data":"'

    if user.purchase('research_' + researchType):