Example #1
0
def next_turn(pid: int):
    ps: PlayerState = db_connector.get_player_state_pid(pid)
    ps.pay_taxes()
    game: Game = db_connector.get_game_pid(pid)
    if game.update_progress():
        define_bankrupts(db_connector.get_game_pid(pid))
        socket.emit('new_market_lvl', game.get_new_market_lvl(), room=game.id)
Example #2
0
def credit_payoff(pid: int):
    print(str(pid))
    player: Player = db_connector.get_player_pid(pid)
    emit('paid_credit_sum', player.check_credit_payoff())
    game: Game = db_connector.get_game_pid(pid)
    if game.update_progress():
        emit('wait_take_credit', room=db_connector.get_game_id(pid))
Example #3
0
def produce(pid: int, quantity: int, fabrics_1: int, fabrics_2: int):
    player_state = db_connector.get_player_state_pid(pid)
    result = player_state.get_egp(quantity, fabrics_1, fabrics_2)
    if isinstance(result, int) and result == 0:
        emit('production_error')
        return
    emit('produced', (result[0], result[1]))
    game: Game = db_connector.get_game_pid(pid)
    if game.update_progress():
        emit('wait_egp_request', room=game.id)
Example #4
0
def egp_request(pid: int, price: int, qty: int):
    game: Game = db_connector.get_game_pid(pid)
    is_senior: bool = db_connector.get_player_state_pid(
        pid).rang == game.turn_num % game.max_players
    egp_orders.append(Order(game.id, pid, price, qty, is_senior))
    if game.update_progress():
        game_orders: list = []
        i: int = 0
        while i < len(egp_orders):
            order: Order = egp_orders[i]
            if order.game_id == game.id:
                print('game_id ' + str(order.game_id) + ' ' + str(game.id))
                game_orders.append(order)
                egp_orders.remove(order)
            else:
                i += 1
        send_egp_approved(game.start_egp_auction(game_orders), game.id)
        pay_bank_percent(game, game.id)