Exemplo n.º 1
0
    def testGameStoreLoadNSave(self):
        gs = server.GameStore()
        p1 = server.Player("aaa", "bbb", "ccc")
        p2 = server.Player("zzz", "yyy", "xxx")
        g = server.Game(p1.name,p2.name)
        gs.players.addPlayer(p1)
        gs.players.addPlayer(p2)
        gs.games.addGame(g)
        gs.save("test_db.dat")
        gs1 = server.loadGameStore("test_db.dat")
        self.assertNotEqual(gs1.games.getGame(g.id),None)
	self.assertEqual(gs1.games.getGame(g.id).id, g.id)
	self.assertEqual(gs1.games.getGame(g.id).lastTurnOn, g.lastTurnOn)
Exemplo n.º 2
0
# -*- coding: utf-8 -*-
from bottle import route, request, run, get, template, static_file, post, response
import json
import server

gameStore = server.loadGameStore("sample_db.dat")

@route('/shabetz_mila')
@route('/shabetz_mila/index.html')
def main_html():
    return static_file("app.html", root="./")

@route('/<script>.js')
def app_js(script):
    if script in ("app", "jquery.cookie", "knockout.mapping-2.4.1"):
        return static_file(script + ".js", root="./")
    else:
        abort(404, "No such script")

@route('/<stylesheet>.css')
def app_css(stylesheet):
    if stylesheet in ("bootstrap.min", "app"):
        return static_file(stylesheet + ".css", root="./")
    else:
        abort(404, "no such stylesheet")
   
@post('/shabetz_mila/login')
def login():
    name     = request.forms.get('username')
    password = request.forms.get('password')
    player = gameStore.players.findPlayer(name)