Beispiel #1
0
import os
import re
from sqlalchemy import func
from attr import attrs, attrib
import gsb
import game
import models
import i18n

command_substitutions = {
    "'": "say",
    ".": "chat",
}

parser = gsb.Parser(command_substitutions=command_substitutions)
duel_parser = gsb.Parser(command_substitutions=command_substitutions)


class LoginParser(gsb.Parser):

    nickname_re = re.compile(r'^[A-Za-z][a-zA-Z0-9]+$')

    def on_attach(self, connection, old_parser=None):
        connection.login_state = ("nickname",
                                  "Nickname (or new to create a new account):")
        self.prompt(gsb.Caller(connection=connection))

    def huh(self, caller):
        state_fn = getattr(self, "handle_" + caller.connection.login_state[0])
        state_fn(caller)
Beispiel #2
0
from twisted.python import log

from ..constants import *
from ..duel import Duel
from .. import globals
from ..room import Room
from ..utils import process_duel, process_duel_replay
from ..websockets import start_websocket_server
from .deck_editor_parser import DeckEditorParser
from .duel_parser import DuelParser
from .room_parser import RoomParser
from .. import models

__ = lambda x: x

LobbyParser = gsb.Parser(command_substitutions=COMMAND_SUBSTITUTIONS)

@LobbyParser.command(names=['afk'])
def afk(caller):
	conn = caller.connection
	if conn.player.afk is False:
		conn.notify(conn._("You are now AFK."))
		conn.player.afk = True
		return
	else:
		conn.notify(conn._("You are no longer AFK."))
		conn.player.afk = False
		return

@LobbyParser.command(names='deck', args_regexp=r'(.*)', allowed = lambda c: c.connection.player.duel is None and c.connection.player.room is None and c.connection.parser is LobbyParser)
def deck(caller):