예제 #1
0
def initialize_testdata():
    # Sample game for quicker tests
    testgame = Game(-1001113216265, 15771023)
    GamesController.games[-1001113216265] = testgame
    players = [Player("Александр", 320853702), Player("Gustav", 305333239), Player("Rene", 318940765), Player("Susi", 290308460), Player("Renate", 312027975)]
    for player in players:
        testgame.add_player(player.uid, player)
예제 #2
0
	def __init__(self, name, uid):		
		BasePlayer.__init__(self, name, uid)		
		# Tokens que el jugador modificara cuando el resto de jugadores le diga. Marca que posible Fate tiene en mano
		self.playerFateTokens = PLAYERFATETOKENS[:]
		self.hiddenPlayerFateTokens = []
		# Fate Tokens que tiene el jugador en mano
		self.fateTokens = []
예제 #3
0
def command_join(update: Update, context: CallbackContext):
	bot = context.bot
	args = context.args
	# I use args for testing. // Remove after?
	groupName = update.message.chat.title
	cid = update.message.chat_id
	groupType = update.message.chat.type
	game = get_game(cid)
	if len(args) <= 0:
		# if not args, use normal behaviour
		fname = update.message.from_user.first_name.replace("_", " ")
		uid = update.message.from_user.id
	else:
		uid = update.message.from_user.id
		if uid == ADMIN:
			for i,k in zip(args[0::2], args[1::2]):
				fname = i.replace("_", " ")
				uid = int(k)
				player = Player(fname, uid)
				game.add_player(uid, player)
				log.info("%s (%d) joined a game in %d" % (fname, uid, game.cid))
				save_game(cid, "Game in join state", game)
	
	if groupType not in ['group', 'supergroup']:
		bot.send_message(cid, "Beni bir gruba eklemeli ve yeni bir oyun oluşturmak için /yenioyun yazmalısın!")
	elif not game:
		bot.send_message(cid, "Bu odada henüz bir oyun kurulmamış, lütfen /yenioyun ile bir oyun açın")
	elif game.board:
		bot.send_message(cid, "Oyun zaten başladı. Lütfen sonraki oyunu bekleyin.")
	elif uid in game.playerlist:
		bot.send_message(game.cid, "Zaten oyuna katıldın, %s!" % fname)
	elif len(game.playerlist) >= 10:
		bot.send_message(game.cid, "Maksimum oyuncu sayısına ulaştınız. Lütfen oyuna /oyunubaslat ile başlayın!")
	else:
		#uid = update.message.from_user.id
		player = Player(fname, uid)
		try:
			#Commented to dont disturb player during testing uncomment in production
			bot.send_message(uid, "Te has unido a un juego en %s. Pronto te dire cual es tu rol secreto." % groupName)
			choose_posible_role(bot, cid, uid)
			
			game.add_player(uid, player)
			log.info("%s (%d) joined a game in %d" % (fname, uid, game.cid))
			if len(game.playerlist) > 4:
				bot.send_message(game.cid, fname + " se ha unido al juego. Escribe /startgame si este es el último jugador y quieren comenzar con %d jugadores!" % len(game.playerlist))
			elif len(game.playerlist) == 1:
				bot.send_message(game.cid, "%s se ha unido al juego. Hay %d jugador en el juego y se necesita 5-10 jugadores." % (fname, len(game.playerlist)))
			else:
				bot.send_message(game.cid, "%s se ha unido al juego. Hay %d jugadores en el juego y se necesita 5-10 jugadores" % (fname, len(game.playerlist)))
			# Luego dicto los jugadores que se han unido
			jugadoresActuales = "Los jugadores que se han unido al momento son:\n"
			for uid in game.playerlist:
				jugadoresActuales += "%s\n" % game.playerlist[uid].name
			bot.send_message(game.cid, jugadoresActuales)
			save_game(cid, "Game in join state", game)
		except Exception:
			bot.send_message(game.cid,
				fname + ", No te puedo enviar un mensaje privado. Por favor, ve a @secrethitlertestlbot y has pincha \"Start\".\nLuego necesitas escribir /join de nuevo.")
예제 #4
0
 def __init__(self, name, uid):
     BasePlayer.__init__(self, name, uid)
     # Lost Expedition atributes
     self.hand = []
     self.food = 3
     self.bullets = 3
     self.vida_explorador_campero = 3
     self.vida_explorador_brujula = 3
     self.vida_explorador_hoja = 3
     self.skills = []
예제 #5
0
파일: Commands.py 프로젝트: ib90/colordice
def command_join(bot, update, args):
	# I use args for testing. // Remove after?
	groupName = update.message.chat.title
	cid = update.message.chat_id
	groupType = update.message.chat.type
	game = GamesController.games.get(cid, None)
	if len(args) <= 0:
		# if not args, use normal behaviour
		fname = update.message.from_user.first_name.replace("_", " ")
		uid = update.message.from_user.id
	else:
		uid = update.message.from_user.id
		if uid == ADMIN:
			for i,k in zip(args[0::2], args[1::2]):
				fname = i.replace("_", " ")
				uid = int(k)
				player = Player(fname, uid)
				game.add_player(uid, player)
				log.info("%s (%d) joined a game in %d" % (fname, uid, game.cid))
	
	if groupType not in ['group', 'supergroup']:
		bot.send_message(cid, "Tienes que agregarme a un grupo primero y escribir /newgame allá!")
	elif not game:
		bot.send_message(cid, "No hay juego en este chat. Crea un nuevo juego con /newgame")
	elif game.board:
		bot.send_message(cid, "El juego ha comenzado. Por favor espera el proximo juego!")
	elif uid in game.playerlist:
		bot.send_message(game.cid, "Ya te has unido al juego, %s!" % fname)
	elif len(game.playerlist) >= 10:
		bot.send_message(game.cid, "Han llegado al maximo de jugadores. Por favor comiencen el juego con /startgame!")
	else:
		#uid = update.message.from_user.id
		player = Player(fname, uid)
		try:
			#Commented to dont disturb player during testing uncomment in production
			bot.send_message(uid, "Te has unido a un juego en %s. Pronto te dire cual es tu rol secreto." % groupName)			 
			game.add_player(uid, player)
			log.info("%s (%d) joined a game in %d" % (fname, uid, game.cid))
			if len(game.playerlist) > 4:
				bot.send_message(game.cid, fname + " se ha unido al juego. Escribe /startgame si este es el último jugador y quieren comenzar con %d jugadores!" % len(game.playerlist))
			elif len(game.playerlist) == 1:
				bot.send_message(game.cid, "%s se ha unido al juego. Hay %d jugador en el juego y se necesita 5-10 jugadores." % (fname, len(game.playerlist)))
			else:
				bot.send_message(game.cid, "%s se ha unido al juego. Hay %d jugadores en el juego y se necesita 5-10 jugadores" % (fname, len(game.playerlist)))
			# Luego dicto los jugadores que se han unido
			jugadoresActuales = "Los jugadores que se han unido al momento son:\n"
			for uid in game.playerlist:
				jugadoresActuales += "%s\n" % game.playerlist[uid].name
			bot.send_message(game.cid, jugadoresActuales)
			save_game(cid, "Game in join state", game)
		except Exception:
			bot.send_message(game.cid,
				fname + ", No te puedo enviar un mensaje privado. Por favor, ve a @secrethitlertestlbot y has pincha \"Start\".\nLuego necesitas escribir /join de nuevo.")
예제 #6
0
def command_join(bot, update):
    groupName = update.message.chat.title
    cid = update.message.chat_id
    groupType = update.message.chat.type
    game = GamesController.games.get(cid, None)
    fname = update.message.from_user.first_name

    if groupType not in ['group', 'supergroup']:
        bot.send_message(cid, "You have to add me to a group first and type /newgame there!")
    elif not game:
        bot.send_message(cid, "There is no game in this chat. Create a new game with /newgame")
    elif game.board:
        bot.send_message(cid, "The game has started. Please wait for the next game!")
    elif update.message.from_user.id in game.playerlist:
        bot.send_message(game.cid, "You already joined the game, %s!" % fname)
    elif len(game.playerlist) >= 10:
        bot.send_message(game.cid, "You have reached the maximum amount of players. Please start the game with /startgame!")
    else:
        uid = update.message.from_user.id
        player = Player(fname, uid)
        try:
            bot.send_message(uid, "You joined a game in %s. I will soon tell you your secret role." % groupName)
            game.add_player(uid, player)
        except Exception:
            bot.send_message(game.cid,
                             fname + ", I can\'t send you a private message. Please go to @thesecrethitlerbot and click \"Start\".\nYou then need to send /join again.")
        log.info("%s (%d) joined a game in %d" % (fname, uid, game.cid))
        if len(game.playerlist) > 4:
            bot.send_message(game.cid, fname + " has joined the game. Type /startgame if this was the last player and you want to start with %d players!" % len(game.playerlist))
        elif len(game.playerlist) == 1:
            bot.send_message(game.cid, "%s has joined the game. There is currently %d player in the game and you need 5-10 players." % (fname, len(game.playerlist)))
        else:
            bot.send_message(game.cid, "%s has joined the game. There are currently %d players in the game and you need 5-10 players." % (fname, len(game.playerlist)))
예제 #7
0
def command_participar(bot, update):
    groupName = update.message.chat.title
    cid = update.message.chat_id
    groupType = update.message.chat.type
    game = GamesController.games.get(cid, None)
    fname = update.message.from_user.first_name

    if groupType not in ['group', 'supergroup']:
        bot.send_message(cid, "Primeiro você tem que me adicionar a um grupo e digitar /novojogo")
    elif not game:
        bot.send_message(cid, "Não tem nenhum jogo em andamento no chat. Para começar digite /novojogo")
    elif game.board:
        bot.send_message(cid, "O jogo já começou, espera o próximo.")
    elif update.message.from_user.id in game.playerlist:
        bot.send_message(game.cid, "Você já está participando do jogo, %s, seu arrombado!" % fname)
    elif len(game.playerlist) >= 10:
        bot.send_message(game.cid, "Esse jogo já está com capacidade máxima, para começar digite /comecarjogo!")
    else:
        uid = update.message.from_user.id
        player = Player(fname, uid)
        try:
            bot.send_message(uid, "Você está participando de um jogo em %s. Logo vou falar seu papel." % groupName)
            game.add_player(uid, player)
        except Exception:
            bot.send_message(game.cid,
                             fname + ", Eu não consigo te mandar uma mensagem privada, abra um chat com @SecretBonoroBot e clique em \"start\".\nDepois envie neste chat /participar de novo")
        else:
            log.info("%s (%d) joined a game in %d" % (fname, uid, game.cid))
            if len(game.playerlist) > 4:
                bot.send_message(game.cid, fname + " está participando do jogo. Digite /comecarjogo se você quiser começar o jogo com %d jogadores!" % len(game.playerlist))
            elif len(game.playerlist) == 1:
                bot.send_message(game.cid, "%s está participando do jogo. Por enquanto temos %d jogadores participando, e precisamos de 5 a 10 jogadores." % (fname, len(game.playerlist)))
            else:
                bot.send_message(game.cid, "%s está participando do jogo. Por enquanto temos %d jogadores participando, e precisamos de 5 a 10 jogadores." % (fname, len(game.playerlist)))
예제 #8
0
 def __init__(self, name, uid):
     BasePlayer.__init__(self, name, uid)
     # Lost Expedition atributes
     self.puntaje = 0
예제 #9
0
def command_join(bot, update):
    groupName = update.message.chat.title
    cid = update.message.chat_id
    groupType = update.message.chat.type
    game = GamesController.games.get(cid, None)
    fname = update.message.from_user.first_name

    if groupType not in ['group', 'supergroup']:
        bot.send_message(
            cid,
            "You have to add me to a group first and type /newgame there!")
    elif not game:
        bot.send_message(
            cid,
            "There is no game in this chat. Create a new game with /newgame")
    elif game.board:
        bot.send_message(
            cid, "The game has started. Please wait for the next game!")
    elif update.message.from_user.id in game.playerlist:
        bot.send_message(game.cid, "You already joined the game, %s!" % fname)
    elif len(game.playerlist) >= 10:
        bot.send_message(
            game.cid,
            "You have reached the maximum amount of players. Please start the game with /startgame or /startrebalanced!"
        )
    else:
        uid = update.message.from_user.id
        player = Player(fname, uid)
        try:
            bot.send_message(
                uid,
                "You joined a game in %s. I will soon tell you your secret role."
                % groupName)
            game.add_player(uid, player)
        except Exception:
            bot.send_message(
                game.cid, fname +
                ", I can\'t send you a private message. Please go to @secrectfascistbr_bot and click \"Start\".\nYou then need to send /join again."
            )
        else:
            log.info("%s (%d) joined a game in %d" % (fname, uid, game.cid))
            try:
                bot.kick_chat_member(SPECTATORS_GROUP, uid, 30)
            except:
                log.error("Unable to ban user " + fname + ", " +
                          sys.exc_info()[0])
                bot.send_message(
                    SPECTATORS_GROUP,
                    "%s, you joined a game but I couldn't kick you from the spectators group. "
                    "Please leave the chat to prevent cheating" % fname)
            if len(game.playerlist) > 4:
                bot.send_message(
                    game.cid, fname +
                    " has joined the game. Type /startgame or /startrebalanced if this was the last player and you want to start with %d players!"
                    % len(game.playerlist))
            elif len(game.playerlist) == 1:
                bot.send_message(
                    game.cid,
                    "%s has joined the game. There is currently %d player in the game and you need 5-10 players."
                    % (fname, len(game.playerlist)))
            else:
                bot.send_message(
                    game.cid,
                    "%s has joined the game. There are currently %d players in the game and you need 5-10 players."
                    % (fname, len(game.playerlist)))