Exemplo n.º 1
0
 def __init__(self):
     #cleanConsole used to clean the console.
     cleanConsole()
     print("---"*37)
     self.player1 = Players()
     print("---"*37)
     time.sleep(0.4)
     cleanConsole()
     print("---"*37)
     self.player2 = Players()
     print("---"*37)
     time.sleep(0.4)
     self.PackOfCards = Deck()
     self.PackOfCards.fillDeck()
     self.player1.fillHandCard(self.PackOfCards)
     self.player2.fillHandCard(self.PackOfCards)
     cleanConsole()
     print(self.player1.show())
     print("---"*37)
     
     self.cardToAdd = self.PackOfCards.sendCard()
     print("New Letter Added: ",self.player1.addCard(self.cardToAdd))
     self.turnOfPlayer = self.player1
     self.turn(True)
     self.choice() 
Exemplo n.º 2
0
 def display_board(self):
     print("\n")
     print(
         Players(board[0][0]).name + "|" + Players(board[0][1]).name + "|" +
         Players(board[0][2]).name)
     print(
         Players(board[1][0]).name + "|" + Players(board[1][1]).name + "|" +
         Players(board[1][2]).name)
     print(
         Players(board[2][0]).name + "|" + Players(board[2][1]).name + "|" +
         Players(board[2][2]).name)
Exemplo n.º 3
0
def main():

    p1, p2 = introduction()

    p1 = Players(p1, "X")
    p2 = Players(p2, "O")

    check_for_name(p1, p2)

    ready = ready_check()

    rules()

    p1.turn()
    p2.turn()
Exemplo n.º 4
0
    def __init__(self, current_players):

        self._current_players = current_players
        self._deck = DeckOfCards()
        self._current_players.append(Players("Kurpiye"))

        print("Game started..")
Exemplo n.º 5
0
 def load_info_for_human(self):
     """this is a method to load username and all information for the human player"""
     human_player = Players(self._username, self._character, True)
     character_index = self.LIST_OF_CHARACTERS.index(self._character)
     character_name = str(self.LIST_OF_CHARACTERS.pop(character_index))+'.png'
     self._human_character_img = pygame.image.load(character_name)
     return human_player
def main():

    cards = Cards()
    coins = Coins()

    x = int(input("Indique la cantidad de jugadores (3-4): "))
    players = Players(x)
    players.add_players()

    cards.shuffle_deck()
    cards.distribute_cards(x)

    cont = 0
    rounds = 0

    while len(players.deadplayers) != (x - 1):

        if cont == (x):
            cont = 0
            rounds += 1
            print("\nRonda " + str(rounds) + " terminada")

        if players.jugadores[cont] in players.deadplayers:
            cont += 1
        else:
            print("\nEs el turno de " + players.jugadores[cont] + "\n")
            action = interface(cont, players, cards, coins)
            action_played(cont, action, players, cards, coins)

            cont += 1

    for i in players.jugadores:
        if i not in players.deadplayers:
            print("\n" + i + " ha ganado el juego")
Exemplo n.º 7
0
    def isvalid_player(self):
        if self.comboBox.currentText() in Login.selected_color:
            self.comboBox.removeItem(self.comboBox.currentIndex())
            self.has_taken()
        elif len(Login.players) <= 3:
            user_ = self.lineEdit.text()
            pass_ = self.lineEdit_2.text()
            color_ = self.comboBox.currentText()
            with open('users') as f:
                li = []
                for i in f.readlines():
                    i = i.strip()
                    i = i.split(',')
                    li.extend(i)

                if (user_ and pass_
                        in li) and li.index(pass_) - li.index(user_) == 1:
                    Login.players.append(Players(f'{user_}', f'{color_}'))
                    x = self.comboBox.currentIndex()
                    self.comboBox.removeItem(x)
                    Login.selected_color.append(color_)
                    self.add()
                    self.par.close()
                else:
                    self.error_notexist()
            if len(Login.players) == 4:
                self.par_1.ui.add.setEnabled(False)

        else:
            pass
        self.lineEdit.setText('')
        self.lineEdit_2.setText('')
Exemplo n.º 8
0
 def __init__(self):
     self.root = Tk()
     self.root.title('Tic Tac Toe')
     self.label = Label(
         self.root, text='How big board should be?\t\nSmall | Medium | Big')
     self.label.grid(row=0, column=0)
     self.entry = Entry(self.root)
     self.entry.grid(row=1, column=0)
     self.button = Button(
         self.root,
         text='Ok',
         command=lambda: [self.get_value(),
                          self.root.destroy()])
     self.button.grid(row=2, column=0)
     self.id_buttons = {}
     self.id_label = None
     self.size = {"SMALL": '3x3', "MEDIUM": '4x4', "BIG": '5x5'}
     self.answer = None
     self.x_length = 0
     self.y_length = 0
     self.val_players = Players()
     self.char_value = list(self.val_players.players.values())
     self.player_value = list(self.val_players.players.keys())
     self.player_number = 1
     self.root.mainloop()
Exemplo n.º 9
0
    def __init__(self):
        self.players = Players([])
        self.p1_S = None
        self.p2_S = None
        self.p3_S = None
        self.p4_S = None

        Player.player_num = 0
Exemplo n.º 10
0
def create_game():
    for i in posibilities_names:
        for j in range(0, players_num):
            influences.append(i)
    random.shuffle(influences)
    for i in range(0, players_num):
        card1 = select_influence()
        card2 = select_influence()
        players.append(Players(str(i + 1), card1, card2, 2))
Exemplo n.º 11
0
def test_constructor():
    board = Board(300, 300)
    pl = Players(board)
    assert pl.bd is board
    assert pl.tile_colors == ['black', 'white']
    assert pl.take_turns == 0
    assert pl.ai is False
    assert pl.game_over is False
    assert pl.TEXT_X == 150
    assert pl.TEXT_Y == 150
Exemplo n.º 12
0
 def update_table(self, nickname, current_scores):
     player_exists = self.session.query(Players).filter(
         Players.nickname == nickname).first()
     if player_exists.nickname:
         if self.get_scores(nickname) < current_scores:
             self.__session.query(Players).filter()
             Players.nickname == nickname.update(
                 {"highscore": current_scores})
             self.__session.commit()
         else:
             player = Players(nickname=nickname, highscore=current_scores)
             self.__session.add(player)
             self.__session.commit()
Exemplo n.º 13
0
 def parse_data(self, raw_data):
     data = []
     for row in raw_data['resultSets'][0]['rowSet']:
         obj = []
         obj.append(row[2])
         obj.append(row[3])
         obj.append(row[4])
         obj.append(row[5])
         obj.append(row[6])
         obj.append(row[10])
         data.append(tuple(obj))
         Players(obj[0]).poll()
     return data
Exemplo n.º 14
0
 def load_info_for_ai(self):
     """This is a method to return a dictionary with all ai players"""
     ai_players = dict()
     for i in range(0, self._number_opponents):
         opponent_name = 'Player' + str(i+1)
         character_ai = self.LIST_OF_CHARACTERS.pop()
         ai_img = str(character_ai)+'.png'
         ai_ = Players(opponent_name, character_ai)
         if self._ai1_char_img is None:
             self._ai1_char_img = pygame.image.load(ai_img)
         else:
             self._ai2_char_img = pygame.image.load(ai_img)
         ai_players[i] = ai_
     return ai_players
Exemplo n.º 15
0
def test_play():
    board = Board(300, 300)
    pl = Players(board)
    pl.take_turns = 0
    x1, y1 = 133, 216
    x2, y2 = 226, 151
    c = 'black'
    pl.bd.avail_moves(c)
    pl.bd.get_center(x1, y1)
    pl.bd.get_center(x2, y2)
    assert pl.bd.input_tile(x1, y1, c) is None
    assert pl.bd.input_tile(x2, y2, c) is True
    assert pl.bd.valid_moves == {
        (0, 1): [1, [[(2, 1), (1, 0)]]],
        (1, 0): [1, [[(1, 2), (0, 1)]]],
        (2, 3): [1, [[(2, 1), (0, -1)]]],
        (3, 2): [1, [[(1, 2), (-1, 0)]]]
    }
Exemplo n.º 16
0
def test_constructor():
    board = Board(300, 300)
    players = Players(board)
    gc = GameController(board, players, 300, 300)
    assert gc.WIDTH == 300
    assert gc.HEIGHT == 300
    assert gc.TEXT_X == 150
    assert gc.GO_Y == 140
    assert gc.RESULT_Y == 160
    assert gc.RESTART_Y == 180
    assert gc.bd is board
    assert gc.pl is players
    assert gc.RECT_W == 150
    assert gc.RECT_H == 300
    assert gc.RECT_C == 7
    assert gc.player_b_wins is False
    assert gc.player_w_wins is False
    assert gc.tie is False
Exemplo n.º 17
0
def main():
    print("""######\tTests players.py\t######""")
    a = Players()
    a.see_all()

    print("""######\tTests PlayerStats\t######""")
    b = PlayerStats(a)
    b.see_all()
    print()

    print("""######\tTests Events\t######""")
    d = Events()
    d.see_all()
    print()

    print("""######\tTests Teams\t######""")
    c = Teams(a, d)
    c.see_all()
    print()

    print("""######\tTests Awards\t######""")
    e = Awards()
    e.see_all()
    print()
Exemplo n.º 18
0
    '''
    Main method to call 
    '''
    print("Enter Player 1 odds of winning")
    p1_p = float(input())
    print("Enter Player 1 inital wealth")
    p1_w = int(input())

    print("Enter Player 2 odds of winning")
    p2_p = float(input())
    print("Enter Player 2 inital wealth")
    p2_w = int(input())

    player1 = Player(p1_p,p1_w)
    player2 = Player(p2_p,p2_w)
    players = Players([player1,player2])

    answer = 'y'
    game_num = 1;
    while(answer == 'y'):
        print("How many Games?")
        games = int(input())

        print("Gamble Number: " + str(game_num))
        gamble = Gamble(players)
        game_num = gamble.play(games, game_num)
        print("Would you like to Gamble Again?(y/n)")
        answer = input()


    print("Thanks for Playing!!")
Exemplo n.º 19
0
def test_get_move():
    board = Board(300, 300)
    pl = Players(board)
    assert pl.get_move() == (1, 0)
Exemplo n.º 20
0
import config
import threading
import re
from flask import Flask, render_template, request, url_for, session, redirect
from flask_socketio import SocketIO, emit
from players import Players
from words import Words
from game_state import GameState
from leaderboard import LeaderBoard
from authentication import player_required


app = Flask(__name__)
config.load(app)
words = Words(app)
players = Players(app)
game_state = GameState(app)
leaderboard = LeaderBoard(app)
socketio = SocketIO(app, async_mode=None)

thread = None
stop_game = go_next = False
# TODO: look into using thread events instead of these flags

@app.route('/')
def index():
    return render_template('index.html', leaderboard=leaderboard.rankings(), player=session.get("player"))

@app.route("/signout")
def signout():
    session.clear()
Exemplo n.º 21
0
import random

print("""
Welcome to Definitely NOT Mario Kart

  ___
    _-_-  _/\______\\__
 _-_-__  / ,-. -|-  ,-.`-.
    _-_- `( o )----( o )-'
           `-'      `-'

A text-based racing game.

Choose your driver and get racing!""")

player1 = Players(1)
Computer1 = Players(2)
Computer2 = Players(3)
Computer3 = Players(4)
Computers = [Computer1, Computer2, Computer1]

game_menu = """
    1: Pick a Driver
    2: Pick a Kart
    3: View your selections
    4: RACE!!!
    5: Exit
    """

# GAME MENU AND FUNCTIONS--------------------------------------------------------------------------
Exemplo n.º 22
0
import threading
from argparse import ArgumentParser
from socket import socket, AF_INET, SOCK_STREAM
import pickle
import sys

import logging

from games import Games
from players import Players

__PLAYERS = Players()
__GAMES = Games()

FORMAT = '%(asctime)-15s %(levelname)s %(message)s'
logging.basicConfig(level=logging.DEBUG, format=FORMAT)
LOG = logging.getLogger()
LOG.setLevel(logging.INFO)

from common import __MSG_FIELD_SEP, __REQ_REG_USER, __REQ_GET_GAMES, \
    __REQ_CREATE_GAME, __REQ_ADD_PLAYER_TO_GAMEROOM, __REQ_MAKE_MOVE, \
    __REQ_INIT_GAME, __RSP_OK, __REQ_CONNECT_SERVER_PORT, __RSP_GAME_FULL_ERROR, __REQ_GET_STATE, __REQ_REMOVE_PLAYER, \
    __REQ_REMOVE_PLAYER_LOBBY


def parse_msg(message, client_sock):
    """
    Method for parsing message and sending response to client
    :param message: message received by server
    :param client_sock: Client socket
    :return: None
Exemplo n.º 23
0
from turtle import Screen
from table import Table
from players import Players
from ball import Ball
from score import Score

screen = Screen()
screen.tracer(0)
table = Table()

player1 = Players(0)
player2 = Players(1)

score = Score()
ball = Ball()
l_score = 0
r_score = 0

stoppage = 0
while 1 > stoppage:
    screen.update()
    ball.move()
    score.display(l_score, r_score)

    if ball.ycor() > 280 or ball.ycor() < -280:
        ball.bounce_y()

    if ball.xcor() > 330 and ball.distance(player2) < 50:
        ball.bounce_x()

    if ball.xcor() < -330 and ball.distance(player1) < 50:
    def play(self):
        self.turn = 0
        num_of_players = int(input('Cuantos jugadores?: '))
        while num_of_players < 3 or num_of_players > 4:
            print('Cantidad invalida')
            num_of_players = int(input('Cuantos jugadores?: '))
        for i in range(num_of_players):
            name = input('Nombre jugador: ')
            self.players.append(Players(name, self.deck))
        #crear condicion para que no se repitan nombres

        while not self.GameOver():
            self.currentPlayer = self.players[self.turn]
            self.game_status()
            print('\n', '[' + self.currentPlayer.name + ']', '\n')
            self.print_cards()
            action = self.currentPlayer.pickAction()

            #Acciones Generales
            if action == 1 or action == 2 or action == 3:
                if action == 1:
                    self.action.Income(self.currentPlayer)
                elif action == 2:
                    #se pregunta si se quiere contraatacar
                    ca = self.askcounterattack()
                    if ca != False:
                        #se pregunta si se quiere desafiar
                        ch = self.askchallenge(ca)
                        if ch != False:
                            #se desafia
                            challenge = self.Challenge_(ca, ch, 'Duke')
                            if challenge == True:
                                # se contraataca
                                self.currentPlayer.modifyCoins(0)
                            elif challenge == False:
                                # currentPlayer ejecuta accion
                                self.action.ForeignAid(self.currentPlayer)

                        else:
                            #se contraataca
                            self.currentPlayer.modifyCoins(0)
                    else:
                        #ejecuta accion
                        self.action.ForeignAid(self.currentPlayer)

                elif action == 3:
                    print('\n')
                    for k in self.players:
                        if k != self.currentPlayer:
                            print(self.players.index(k), '.', k.name)

                    target = int(input('Target: '))
                    self.lostInfluences.append(
                        self.action.Coup(self.currentPlayer, target))

            #Acciones de Personaje
            else:
                ch = self.askchallenge(self.currentPlayer)
                if ch != False:
                    #ejecutar desafio
                    if action == 4:
                        inf = 'Duke'
                    elif action == 5:
                        inf = 'Assasin'
                    elif action == 6:
                        inf = 'Ambassador'
                    elif action == 7:
                        inf = 'Captain'
                    challenge = self.Challenge_(self.currentPlayer, ch, inf)
                    if challenge == True:
                        #ejecutar accion
                        if action == 4:
                            self.action.Tax(self.currentPlayer)
                        elif action == 5:
                            print('\n')
                            for k in self.players:
                                if k != self.currentPlayer:
                                    print(self.players.index(k), '.', k.name)

                            target = int(input('Target: '))
                            self.action.Assassinate(self.currentPlayer, target)
                        elif action == 6:
                            self.action.Exchange(self.currentPlayer, self.deck)
                        elif action == 7:
                            print('\n')
                            for k in self.players:
                                if k != self.currentPlayer:
                                    print(self.players.index(k), '.', k.name)

                            target = int(input('Target: '))
                            self.action.Steal(self.currentPlayer, target)
                else:
                    if action == 5 or action == 7:
                        #se pregunta si se quiere contraatacar
                        ca = self.askcounterattack()
                        if ca != False:
                            #se pregunta si se quiere desafiar el contraataque
                            ch = self.askchallenge(ca)
                            if ch != False:
                                #se desafia
                                if action == 5:
                                    inf = 'Contessa'
                                elif action == 7:
                                    inf = 'Captain'
                                    challenge = self.Challenge_(ca, ch, inf)
                                    if challenge == False:
                                        inf = 'Ambassador'

                                challenge = self.Challenge_(ca, ch, inf)

                                if challenge == True:
                                    #se contraataca
                                    if action == 5:
                                        self.currentPlayer.modifyCoins(-3)
                                    elif action == 7:
                                        self.currentPlayer.modifyCoins(0)
                                elif challenge == False:
                                    #ejecutar accion
                                    if action == 5:
                                        print('\n')
                                        for k in self.players:
                                            if k != self.currentPlayer:
                                                print(self.players.index(k),
                                                      '.', k.name)

                                        target = int(input('Target: '))
                                        self.action.Assassinate(
                                            self.currentPlayer, target)
                                    elif action == 7:
                                        print('\n')
                                        for k in self.players:
                                            if k != self.currentPlayer:
                                                print(self.players.index(k),
                                                      '.', k.name)

                                        target = int(input('Target: '))
                                        self.action.Steal(
                                            self.currentPlayer, target)

                            else:
                                #no hay desafio y se contraataca
                                if action == 5:
                                    self.currentPlayer.modifyCoins(-3)
                                elif action == 7:
                                    self.currentPlayer.modifyCoins(0)

                        else:
                            #ejecuta accion
                            if action == 5:
                                print('\n')
                                for k in self.players:
                                    if k != self.currentPlayer:
                                        print(self.players.index(k), '.',
                                              k.name)

                                target = int(input('Target: '))
                                self.action.Assassinate(
                                    self.currentPlayer, target)
                            elif action == 7:
                                print('\n')
                                for k in self.players:
                                    if k != self.currentPlayer:
                                        print(self.players.index(k), '.',
                                              k.name)

                                target = int(input('Target: '))
                                self.action.Steal(self.currentPlayer, target)

                    else:
                        #ejecuta accion
                        if action == 4:
                            self.action.Tax(self.currentPlayer)
                        elif action == 6:
                            self.action.Exchange(self.currentPlayer, self.deck)
                            pass

            #verifica que los jugadores tengan cartas
            for i in self.players:
                if len(i.cards) == 0:
                    k = self.players.index(i)
                    self.players.pop(k)

            if self.turn < num_of_players:
                self.turn += 1
            else:
                self.turn = 0
Exemplo n.º 25
0
'''
getter: it is a method to get the value of the data attribute
getters can be created later, no need to make them initially
setter: sets the value of the data attribute

getters and setters are used with property that uses these getters and setters
_lives have been replaced by lives
'''

from players import Players  # this kind of importing must be avoided
from enemy import Enemy, Troll, Vampyre, VampyreKing

aditya = Players("Aditya")

# print(aditya.name)
# print(aditya.lives)
# print(aditya.__dict__)
''' aditya.lives -= 1
print(aditya)

aditya.lives -= 1
print(aditya)

aditya.lives -= 1
print(aditya)

aditya.lives -= 1
print(aditya) '''

# aditya.level = 5 # level - _level
# print(aditya)
Exemplo n.º 26
0
 def setUp(self):
     self.player = Players("Mike", "Dog")
Exemplo n.º 27
0
import time

print(' ### BLACKJACK GAME - (Soft 17) ### '.center(100,'*'))

current_players = []

game = Game(current_players)

while True:
    try:
        number_of_player = input("Number of players: ")
        
        for i in range(int(number_of_player)):
            print(f"{i+1}. player ", end='')
            player_name = input("name: ")
            current_players.append(Players(player_name.capitalize())) 
        break
        
    except ValueError:
        print("Opps! Enter player's number as a number")

game.cards_deal()
game.isBlackJack()
print("\n")
game.write_values(0)            

for player in current_players[1:]:
    while True:
        if player.black_jack == 1:
            print(f"\n{player.name}, Black Jack")
            break
Exemplo n.º 28
0
import random

print("""
Welcome to Definitely NOT Mario Kart

  ___
    _-_-  _/\______\\__
 _-_-__  / ,-. -|-  ,-.`-.
    _-_- `( o )----( o )-'
           `-'      `-'

A text-based racing game.

Choose your driver and get racing!""")

player1 = Players(1)

game_menu = """
    1: Pick a Driver
    2: Pick a Kart
    3: View your selections
    4: RACE!!!
    5: Exit
    """

# GAME MENU AND FUNCTIONS--------------------------------------------------------------------------

kart_menu = ("""
    1: Standard:      
            Speed: 6.5, Handling: 4
    2: Mushmellow:    
Exemplo n.º 29
0
from cards import Cards
from players import Players

print("\nToday we play Poker! \n")

cards = Cards()
deck1 = cards.make_deck()

luke = Players("Luke")
slim = Players("Slim")

luke.hand = Cards().deal_cards(deck1, 5)
slim.hand = Cards().deal_cards(deck1, 5)

luke_sum = Cards().total_of_hand(luke.hand)
slim_sum = Cards().total_of_hand(slim.hand)

total = luke_sum + slim_sum

print("Total of both hands are: " + str(total) + "\n")

luke.hand = Cards().throw_cards(luke.hand, 2)
slim.hand = Cards().throw_cards(slim.hand, 2)

Cards().draw_cards(deck1, luke.hand, 2)
Cards().draw_cards(deck1, slim.hand, 2)

print()

luke.game_end(deck1)
slim.game_end(deck1)
Exemplo n.º 30
0
from players import Players

test = Players()

print(test.get_strength())
print(test.get_movieball())

test.strength_up()
test.strength_up()
test.strength_up()
test.movieballs_up()
test.movieballs_up()
test.movieballs_up()
test.movieballs_down()

print(test.get_strength())
print(test.get_movieball())