示例#1
0
文件: UI.py 项目: JValtteri/gtycoon
def statusBar(player):
    print("""

        company:  %s    \t\t   year:     %i
        credits:  %s   \t\t   products: %i
        science:  %i   \t\t\t   income:   %s
        general:  %i    \t\t\t   node:     %s
                        \t\t   defect
                        \t\t   dencity:  %s

    ===============================================================
    """ % (player.name, player.year, calc.scale(player.credits),
           len(player.products), player.science, calc.scale(
               player.income), player.generalization, calc.NODE[player.node],
           str(round(player.refinememt, 3))))
示例#2
0
文件: UI.py 项目: JValtteri/gtycoon
def showLine(product, game, index=None):
    categories = [
        '\t ', product.name, '\t ',
        calc.scale(product.perf), '\t ',
        str(round(product.chipCost())), '\t ',
        str(product.price), ' c\t',
        calc.scale(product.sales(game)), '\t ',
        str(product.size), ' mm2 \t',
        str(calc.NODE[product.node]), '\t',
        str(round(product.ptp / game.best_ptp, 2)), '\t',
        calc.scale(product.income), '\t'
        #calc.scale( product.market() * 10**7 * product.perf/game.max_perf)
    ]

    line = ''.join(categories)
    if index != None:
        line = ''.join(('\t ', str(index), line))
    print(line)
示例#3
0
文件: UI.py 项目: JValtteri/gtycoon
def design(player, game):
    "Design a chip"

    ### PLEASE ####
    #
    # Find a sane way to split this in to sections.
    # This is horrible to read.

    statusBar(player)
    showMarket(player, game)
    print("\n\n\n")

    # Asks if there is a new chip designed, that is not in production
    try:
        no_saved = player.products[-1].inproduction
    except:
        # If there are no chips at all, there are no saved chips either
        no_saved = True

    # START FRESH
    # THE BASICS
    if no_saved:
        name = ask("Chip name: ", 0)
        time.sleep(SHORT_SLEEP)
        size = int(ask("Chip size [mm2]: ", 1))
        time.sleep(SHORT_SLEEP)
        price = 1
        overdrive = 0

        new_product = engine.Product(name, size, overdrive, price, player.node,
                                     player.science, player.refinememt)

        # The chip is added to products (saved), it will be refrenced to as
        # player.products[-1] ig. Players newest product.
        player.products.append(new_product)

    # RECALL AN UNFINISHED CHIP
    #
    else:
        # If a saved chip is found, the preliminary specs are displayed
        print("Chip name: ", player.products[-1].name)
        print("Chip size: ", player.products[-1].size)
        print("Overdrive: ", player.products[-1].overdrive)
        print("Chip price:", player.products[-1].price)
        print("\n")

    # MANUFACTURING
    #
    # Yeald and cost to make are tuned
    chipcost = player.products[-1].chipCost()

    print("")
    print("Manufacturing cost per chip: \t", round(chipcost, 2), "c")
    print("Manufacturing yeald:         \t",
          round(player.products[-1].yealdPr() * 100), "%")

    # FINE TUNING THE PRODUCT
    #
    player.products[-1] = set_overdrive(player.products[-1])

    # PRICE SELECTION
    #
    player.products[-1] = set_price(player.products[-1])

    # ENFORCE MAXIMUM NUMBER OF CHIPS
    #
    if len(player.products) > engine.MAX_CHIPS:
        print("""
        Maximum number of chips reached.
        Pick on chip to be removed:
        """)
        time.sleep(MEDIUM_SLEEP)

        number = chooseProduct(player, game, 'replace')
        if number == None:  # If none selected, the oldest (0) will be removed
            number = 0
        old_chip = player.products[number]
        game.remove_from_market(old_chip)
        del [player.products[number]]

    # PRODUCTION AND TRANSACTION
    #
    statusBar(player)
    print("""
    It costs %s to start production.
    Do you whant to procede with producing this chip? 
    (Y/n)""" % calc.scale(engine.PRODUCTION_COST))
    try:
        ch = getch()
    except:
        ch = input("")

    if ch.upper() in [b'Y', b' ', b'\r', 'Y', ' ', '']:
        done = player.purchase(engine.PRODUCTION_COST)

        if done == True:
            player.products[-1].inproduction = True
            game.newProduct(
                player.products[-1]
            )  # Relevant data is updated to game (and market status)   #market_segment, price, player.products[-1].performance())
            print("Transaction complete\nChip Released\n")
            productReleace(player, player.products[-1],
                           game)  # Announcement and review
            showMarket(player, game)
        else:
            print("Not enough credits!")
        #try: getch()
        #except: input()
        time.sleep(MEDIUM_SLEEP)

    elif ch.upper() in ['N', b'N']:
        print("""
        Do you whant to save the chip for later?
        (Y/n)""")
        try:
            getch()
        except:
            ch = input("")
        if ch.upper() in ['N', b'N']:
            del player.products[-1]
            print("Deleted")
        else:
            pass
示例#4
0
文件: UI.py 项目: JValtteri/gtycoon
def research(player):
    while True:

        statusBar(player)

        print("""
        CHOOSE RESEARCH SUBJECT:

                                        Cost
        S = Specific Architecture       %s
        G = General Compute             %s\t(Not implemented)
        X = Experimental                    \t(Not implemented)

        N = Smaller process node        %s

        [space] = Exit

        """ % (calc.scale(
            player.research_cost()), calc.scale(
                player.research_cost()), calc.scale(player.node_cost())))
        # This could work so, that the specific version gives double sciense, but is reset every node.
        # Experimental could be "i feel lucky" boost ranging from 0 to 10 science points randomly
        # Experimental things cost twice the normal research, but may sometimes yeald great leaps in performance

        try:
            ch = getch()
        except:
            ch = input("> ")

        if ch.upper() in ["S", b"S"]:
            researched = player.research(0)

        elif ch.upper() in ["G", b"G"]:
            researched = player.research(1)

        elif ch.upper() in ["N", b"N"]:
            researched = player.research_node()

        elif ch.upper() in [b" ", b'\r', "", " "]:
            break

        else:
            print("woops")
            time.sleep(MEDIUM_SLEEP)

        try:
            if researched == True:
                print("Researched!")
            elif researched == False:
                print("Not enough credits")
            elif researched == 404:
                print(
                    "Researchers tried to split an atom, but fission occoured.\n"
                    "Fission produces lots of power but also distroys electronics\n"
                    "so no good.\n"
                    "We'll have to try something else.")
            else:
                print(
                    "woops\nScience department made a blunder.\nAlso the game has a bug.\nPlease report this."
                )

            time.sleep(MEDIUM_SLEEP)
            #try:
            #    getch()
            #except:
            #    input ()
        except:
            pass
示例#5
0
文件: UI.py 项目: JValtteri/gtycoon
def gameScreen(player, game):
    while True:

        statusBar(player)

        print("""
        C = Chip Design \t %s
        R = Research    \t %s+

        B = Rebrand     \t %s
        S = Price Cut   \t free

        M = Show the market

        [space] = Next Turn

        \t\t\t\t  Q = Quit game instantly


        """ % (calc.scale(
            engine.PRODUCTION_COST), calc.scale(
                player.research_cost()), calc.scale(engine.REBRAND_COST)))

        try:
            ch = getch()
        except:
            ch = input("> ")

        if ch.upper() in ["R", b"R"]:
            research(player)

        elif ch.upper() in ["B", b"B"]:
            rebrand(player, game)

        elif ch.upper() in ["C", b"C"]:
            design(player, game)

        elif ch.upper() in ["S", b"S"]:
            priceDrop(player, game)

        elif ch.upper() in ["M", b"M"]:
            showMarket(player, game)
            time.sleep(SHORT_SLEEP)
            #try:
            #    getch()
            #except:
            #    input ()

        elif ch.upper() in [b" ", b'\r', "", " "]:
            if game.num_products < 1:
                print("What sort of a company doesn't have any products!?")
                time.sleep(LONG_SLEEP)

            else:
                break

        elif ch.upper() in ["Q", b"Q"]:
            sys.exit("quit")

        else:
            print("woops")