Beispiel #1
0
 def test_register_good_guess(self):
     g = Game()
     g.add_player(u"Test1", u"Prof. Plum")
     g.add_player(u"Test2", u"Miss Scarlett")
     g._active_player = u"Test2"
     g._gameboard.enter_room(u"Miss Scarlett", 2)
     g._active_move = u"guess"
     g.register_guess(u"Test2", u"Mr. Green", u"study", u"candlestick")
     assert (isinstance(g._guess, Guess))
     assert (g._guess._guess_order[0].get_playername() == u"Test1")
Beispiel #2
0
 def test_add_player(self):
     g = Game()
     with pytest.raises(ValueError):
         g.add_player(u"TestPlayer1", "Mr. None")
     g.add_player(u"TestPlayer", u"Mrs. White")
     assert (u"Mrs. White" not in g.get_available_characters())
     with pytest.raises(ValueError):
         g.add_player(u"TestPlayer", u"Mr. Green")
Beispiel #3
0
 def test_register_guess_in_hall(self):
     g = Game()
     g.add_player(u"Test2", u"Miss Scarlett")
     g._active_move = u"guess"
     g._active_player = u"Test2"
     with pytest.raises(IllegalGuess):
         g.register_guess(u"Test2", u"Mr. Green", u"study", u"candlestick")
Beispiel #4
0
 def test_start_game(self):
     g = Game()
     g.add_player(u"Test1", u"Mrs. White")
     g.add_player(u"Test2", u"Mr. Green")
     g.start_game()
     assert (g._active_player == u"Test1")
     assert (g._active_move == u"move")
Beispiel #5
0
 def test_register_guess_wrong_room(self):
     g = Game()
     g.add_player(u"Test2", u"Miss Scarlett")
     g._active_player = u"Test2"
     g._gameboard.enter_room(u"Miss Scarlett", 2)
     g._active_move = u"guess"
     with pytest.raises(IllegalGuess):
         g.register_guess(u"Test2", u"Mr. Green", u"lounge", u"candlestick")
Beispiel #6
0
 def set_up_to_player_gb(self):
     g = Game()
     g.add_player(u"Test1", u"Prof. Plum")
     g.add_player(u"Test2", u"Miss Scarlett")
     g._active_player = u"Test2"
     g._gameboard.enter_room(u"Miss Scarlett", 2)
     return g
Beispiel #7
0
 def test_prepare_move(self):
     g = Game()
     g.add_player(u"Test1", u"Col. Mustard")
     g._active_player = u"Test1"
     g.prepare_move()
     assert (g._active_move == u"move")
     assert (g._dice[0] in range(1, 7))
     assert (g._dice[1] in range(1, 7))
Beispiel #8
0
 def test_register_guess_wrong_player(self):
     g = Game()
     g._active_move = u"guess"
     g._active_player = u"Test2"
     with pytest.raises(IllegalCommand):
         g.register_guess(u"Test1", u"Mr. Green", u"study", u"candlestick")
Beispiel #9
0
 def test_get_room_active_mob(self):
     g = Game()
     g.add_player(u"Test2", u"Miss Scarlett")
     g._active_player = u"Test2"
     g._gameboard.enter_room(u"Miss Scarlett", 4)
     assert (g.get_active_room() == u"lounge")
Beispiel #10
0
 def test_finish_movement_onboard(self):
     g = Game()
     g.add_player(u"Test1", u"Prof. Plum")
     g.add_player(u"Test2", u"Miss Scarlett")
     g.start_game()
     g.set_number_of_moves_for_active_player(2)
     assert (g._active_move == u"move")
     assert (g.move(u"Test1", u"right") == True)
     assert (g.move(u"Test1", u"right") == True)
     with pytest.raises(IllegalCommand):
         g.move(u"Test1", u"right")
     assert (g._active_move == u"move")
     assert (g._active_player == u"Test2")
Beispiel #11
0
 def test_get_player_mob(self):
     g = Game()
     g.add_player(u"Test1", u"Prof. Plum")
     g.add_player(u"Test2", u"Miss Scarlett")
     assert (g.get_player_character(u"Test1") == u"Prof. Plum")
     assert (g.get_player_character(u"Test2") == u"Miss Scarlett")
Beispiel #12
0
 def set_up_full_gb(self):
     g = Game()
     g.add_player(u"Test1", u"Prof. Plum")
     g.add_player(u"Test2", u"Miss Scarlett")
     g.add_player(u"Test3", u"Mrs. White")
     g.add_player(u"Test4", u"Mr. Green")
     g.add_player(u"Test5", u"Col. Mustard")
     g.add_player(u"Test6", u"Mrs. Peacock")
     g._active_player = u"Test2"
     g._gameboard.enter_room(u"Miss Scarlett", 2)
     return g
Beispiel #13
0
 def test_roll_die(self):
     g = Game()
     g.roll_dice()
     assert (g._dice[0] in range(1, 7))
     assert (g._dice[1] in range(1, 7))
Beispiel #14
0
 def test_get_available_mobs(self):
     g = Game()
     for itm in clue.cluestatics.get_character_names():
         assert (itm in g.get_available_characters())
     for itm in g.get_available_characters():
         assert (itm in clue.cluestatics.get_character_names())
Beispiel #15
0
 def test_init(self):
     g = Game()
     assert (hasattr(g, "_gameboard"))
     assert (hasattr(g, "_player"))
     assert (g._player == [])
Beispiel #16
0
 def test_move(self):
     g = Game()
     g.add_player(u"Test1", u"Prof. Plum")
     g.add_player(u"Test2", u"Miss Scarlett")
     with pytest.raises(IllegalCommand):
         g.move(u"Test1", u"right")
     g.start_game()
     with pytest.raises(IllegalCommand):
         g.move(u"Test2", u"up")
     assert (g.move(u"Test1", u"right") == True)
Beispiel #17
0
 def test_answer_question_wrong_step(self):
     g = Game()
     g._active_move == u"guess"
     with pytest.raises(IllegalCommand):
         g.register_answer(u"wrench")
Beispiel #18
0
from flask import Flask, request, session, render_template, abort, Response
from flask_socketio import SocketIO, join_room, emit, send
import json
import uuid

from clue.cluelogic import Game
import gui.guimisc as guimisc
import clue.cluestatics as cluestatics

app = Flask(__name__, template_folder="templates")
app.config[u"SECRET_KEY"] = 'mysecret'
#app.config[u"SESSION_COOKIE_SECURE"] = True # only send cookie for ssl connection.
app.config[u"SESSION_COOKIE_HTTPONLY"] = True
app.config[u"SESSION_COOKIE_SAMESITE"] = u"Strict"
socketio = SocketIO(app, cookie=None)
game = Game()
player = {}
comm = {}
id_rsid = {}

CERT_FILE = u"/etc/letsencrypt/live/clue-19.spdns.org/cert.pem"
KEY_FILE = u"/etc/letsencrypt/live/clue-19.spdns.org/privkey.pem"


def resolve_playername_send_update(func):
    def wrapper(*args, **kwargs):
        try:
            playername = player[request.sid]
        except KeyError:
            return
        res = func(playername, *args, **kwargs)