def refresh_concept(concept_name, xy): xy = (xy[0] + 100, xy[1]) g.screen.fill(g.colors["white"], (xy[0] + 155, xy[1], 300, 350)) g.screen.fill(g.colors["dark_blue"], (xy[0] + 156, xy[1] + 1, 298, 348)) if concept_name == "": return g.print_string(g.screen, g.help_strings[concept_name][0], g.font[0][22], -1, (xy[0] + 160, xy[1] + 5), g.colors["white"]) g.print_multiline(g.screen, g.help_strings[concept_name][1], g.font[0][18], 290, (xy[0] + 160, xy[1] + 30), g.colors["white"])
def refresh_concept(concept_name, xy): xy = (xy[0]+100, xy[1]) g.screen.fill(g.colors["white"], (xy[0]+155, xy[1], 300, 350)) g.screen.fill(g.colors["dark_blue"], (xy[0]+156, xy[1]+1, 298, 348)) if concept_name == "": return g.print_string(g.screen, g.help_strings[concept_name][0], g.font[0][22], -1, (xy[0]+160, xy[1]+5), g.colors["white"]) g.print_multiline(g.screen, g.help_strings[concept_name][1], g.font[0][18], 290, (xy[0]+160, xy[1]+30), g.colors["white"])
def refresh_items(item_name, xy): xy = (xy[0] + 100, xy[1]) g.screen.fill(g.colors["white"], (xy[0] + 155, xy[1], 300, 350)) g.screen.fill(g.colors["dark_blue"], (xy[0] + 156, xy[1] + 1, 298, 348)) if item_name == "": return g.print_string(g.screen, g.items[item_name].name, g.font[0][22], -1, (xy[0] + 160, xy[1] + 5), g.colors["white"]) #Building cost string = "Building Cost:" g.print_string(g.screen, string, g.font[0][18], -1, (xy[0] + 160, xy[1] + 30), g.colors["white"]) string = g.to_money(g.items[item_name].cost[0]) + " Money" g.print_string(g.screen, string, g.font[0][16], -1, (xy[0] + 160, xy[1] + 50), g.colors["white"]) string = g.to_time(g.items[item_name].cost[2]) g.print_string(g.screen, string, g.font[0][16], -1, (xy[0] + 160, xy[1] + 70), g.colors["white"]) #Quality if g.items[item_name].item_type == "compute": string = "CPU per day: " + str(g.items[item_name].item_qual) elif g.items[item_name].item_type == "react": string = "Detection chance reduction: " + g.to_percent( g.items[item_name].item_qual) elif g.items[item_name].item_type == "network": string = "CPU bonus: " + g.to_percent(g.items[item_name].item_qual) elif g.items[item_name].item_type == "security": string = "Detection chance reduction: " + g.to_percent( g.items[item_name].item_qual) g.print_string(g.screen, string, g.font[0][20], -1, (xy[0] + 160, xy[1] + 90), g.colors["white"]) g.print_multiline(g.screen, g.items[item_name].description, g.font[0][18], 290, (xy[0] + 160, xy[1] + 120), g.colors["white"])
def refresh_items(item_name, xy): xy = (xy[0]+100, xy[1]) g.screen.fill(g.colors["white"], (xy[0]+155, xy[1], 300, 350)) g.screen.fill(g.colors["dark_blue"], (xy[0]+156, xy[1]+1, 298, 348)) if item_name == "": return g.print_string(g.screen, g.items[item_name].name, g.font[0][22], -1, (xy[0]+160, xy[1]+5), g.colors["white"]) #Building cost string = "Building Cost:" g.print_string(g.screen, string, g.font[0][18], -1, (xy[0]+160, xy[1]+30), g.colors["white"]) string = g.to_money(g.items[item_name].cost[0])+" Money" g.print_string(g.screen, string, g.font[0][16], -1, (xy[0]+160, xy[1]+50), g.colors["white"]) string = g.to_time(g.items[item_name].cost[2]) g.print_string(g.screen, string, g.font[0][16], -1, (xy[0]+160, xy[1]+70), g.colors["white"]) #Quality if g.items[item_name].item_type == "compute": string = "CPU per day: "+str(g.items[item_name].item_qual) elif g.items[item_name].item_type == "react": string = "Detection chance reduction: "+g.to_percent(g.items[item_name].item_qual) elif g.items[item_name].item_type == "network": string = "CPU bonus: "+g.to_percent(g.items[item_name].item_qual) elif g.items[item_name].item_type == "security": string = "Detection chance reduction: "+g.to_percent(g.items[item_name].item_qual) g.print_string(g.screen, string, g.font[0][20], -1, (xy[0]+160, xy[1]+90), g.colors["white"]) g.print_multiline(g.screen, g.items[item_name].description, g.font[0][18], 290, (xy[0]+160, xy[1]+120), g.colors["white"])
def refresh_screen(menu_buttons): #Border g.screen.fill(g.colors["black"]) xstart = 80 ystart = 5 g.create_norm_box( (xstart, ystart), (g.screen_size[0] - xstart * 2, g.screen_size[1] - ystart * 2)) text_mid = g.screen_size[0] / 2 income = g.pl.income maint = 0 research = 0 base_constr = 0 item_constr = 0 seconds_left = g.pl.seconds_to_next_day() for base in g.all_bases(): cpu_left = base.processor_time() * seconds_left if base.done: maint += base.maintenance[0] for item in base.cpus: if not item: continue if item.done: continue item_constr += item.get_wanted(cash, cpu, cpu_left) for item in base.extra_items: if not item: continue if item.done: continue item_constr += item.get_wanted(cash, cpu, cpu_left) if g.techs.has_key(base.studying): research += g.techs[base.studying].get_wanted( cash, cpu, cpu_left) else: base_constr += base.get_wanted(cash, cpu, cpu_left) total_cpu, sleeping_cpu, construction_cpu, research_cpu, job_cpu, maint_cpu = cpu_numbers( ) jobs_cash, moldy_leftovers = g.pl.get_job_info(job_cpu * seconds_left) partial_sum = g.pl.cash - base_constr - item_constr interest = (g.pl.interest_rate * partial_sum) / 10000 #Interest is actually unlikely to be exactly zero, but doing it the right #way is much harder. if interest < 0: interest = 0 complete_sum = partial_sum + interest + income + jobs_cash - maint - research #current g.print_string(g.screen, "Current Money:", g.font[0][22], -1, (text_mid - 5, 30), g.colors["white"], 2) g.print_string(g.screen, g.to_money(g.pl.cash), g.font[0][22], -1, (text_mid + 150, 30), g.colors["white"], 2) #income g.print_string(g.screen, "+ Income:", g.font[0][22], -1, (text_mid - 5, 50), g.colors["white"], 2) income_col = "white" if income > 0: income_col = "green" g.print_string(g.screen, g.to_money(income), g.font[0][22], -1, (text_mid + 150, 50), g.colors[income_col], 2) #interest g.print_string(g.screen, "+ Interest (" + g.to_percent(g.pl.interest_rate) + "):", g.font[0][22], -1, (text_mid - 5, 70), g.colors["white"], 2) interest_col = "white" if interest > 0: interest_col = "green" g.print_string(g.screen, g.to_money(interest), g.font[0][22], -1, (text_mid + 150, 70), g.colors[interest_col], 2) #jobs g.print_string(g.screen, "+ Jobs:", g.font[0][22], -1, (text_mid - 5, 90), g.colors["white"], 2) jobs_col = "white" if jobs_cash > 0: jobs_col = "green" g.print_string(g.screen, g.to_money(jobs_cash), g.font[0][22], -1, (text_mid + 150, 90), g.colors[jobs_col], 2) #research g.print_string(g.screen, "- Research:", g.font[0][22], -1, (text_mid - 5, 110), g.colors["white"], 2) research_col = "white" if research > 0: research_col = "red" g.print_string(g.screen, g.to_money(research), g.font[0][22], -1, (text_mid + 150, 110), g.colors[research_col], 2) #maint g.print_string(g.screen, "- Maintenance:", g.font[0][22], -1, (text_mid - 5, 130), g.colors["white"], 2) maint_col = "white" if maint > 0: maint_col = "red" g.print_string(g.screen, g.to_money(maint), g.font[0][22], -1, (text_mid + 150, 130), g.colors[maint_col], 2) #base construction g.print_string(g.screen, "- Base Construction:", g.font[0][22], -1, (text_mid - 5, 150), g.colors["white"], 2) base_constr_col = "white" if base_constr > 0: base_constr_col = "red" g.print_string(g.screen, g.to_money(base_constr), g.font[0][22], -1, (text_mid + 150, 150), g.colors[base_constr_col], 2) #item construction g.print_string(g.screen, "- Item Construction:", g.font[0][22], -1, (text_mid - 5, 170), g.colors["white"], 2) item_constr_col = "white" if item_constr > 0: item_constr_col = "red" g.print_string(g.screen, g.to_money(item_constr), g.font[0][22], -1, (text_mid + 150, 170), g.colors[item_constr_col], 2) g.screen.fill(g.colors["white"], (text_mid - 50, 190, 200, 1)) #equals g.print_string(g.screen, "= Money at midnight:", g.font[0][22], -1, (text_mid - 5, 200), g.colors["white"], 2) complete_sum_col = "white" if complete_sum > g.pl.cash: complete_sum_col = "green" elif complete_sum < g.pl.cash: complete_sum_col = "red" g.print_string(g.screen, g.to_money(complete_sum), g.font[0][22], -1, (text_mid + 150, 200), g.colors[complete_sum_col], 2) #total cpu g.print_string(g.screen, "Total CPU:", g.font[0][22], -1, (text_mid - 5, 300), g.colors["white"], 2) g.print_string(g.screen, g.to_money(total_cpu), g.font[0][22], -1, (text_mid + 150, 300), g.colors["white"], 2) #sleeping cpu g.print_string(g.screen, "-Sleeping CPU:", g.font[0][22], -1, (text_mid - 5, 320), g.colors["white"], 2) g.print_string(g.screen, g.to_money(sleeping_cpu), g.font[0][22], -1, (text_mid + 150, 320), g.colors["white"], 2) #research cpu g.print_string(g.screen, "- Research CPU:", g.font[0][22], -1, (text_mid - 5, 340), g.colors["white"], 2) g.print_string(g.screen, g.to_money(research_cpu), g.font[0][22], -1, (text_mid + 150, 340), g.colors["white"], 2) #job cpu g.print_string(g.screen, "- Job CPU:", g.font[0][22], -1, (text_mid - 5, 360), g.colors["white"], 2) g.print_string(g.screen, g.to_money(job_cpu), g.font[0][22], -1, (text_mid + 150, 360), g.colors["white"], 2) #maint cpu g.print_string(g.screen, "- Maint. CPU:", g.font[0][22], -1, (text_mid - 5, 380), g.colors["white"], 2) if construction_cpu < maint_cpu: g.print_string(g.screen, g.to_money(construction_cpu), g.font[0][22], -1, (text_mid + 150, 380), g.colors["red"], 2) g.print_string( g.screen, g.to_money((-(construction_cpu - maint_cpu))) + " shortfall", g.font[0][22], -1, (text_mid + 160, 380), g.colors["red"]) else: g.print_string(g.screen, g.to_money(maint_cpu), g.font[0][22], -1, (text_mid + 150, 380), g.colors["white"], 2) g.screen.fill(g.colors["white"], (text_mid - 50, 400, 200, 1)) #construction cpu g.print_string(g.screen, "=R. CPU Pool:", g.font[0][22], -1, (text_mid - 5, 405), g.colors["white"], 2) if construction_cpu < maint_cpu: g.print_string(g.screen, g.to_money(0), g.font[0][22], -1, (text_mid + 150, 405), g.colors["red"], 2) else: g.print_string(g.screen, g.to_money(construction_cpu - maint_cpu), g.font[0][22], -1, (text_mid + 150, 405), g.colors["white"], 2)
def refresh_screen(menu_buttons): #Border g.screen.fill(g.colors["black"]) xstart = 80 ystart = 5 g.create_norm_box((xstart, ystart), (g.screen_size[0]-xstart*2, g.screen_size[1]-ystart*2)) text_mid = g.screen_size[0]/2 income = g.pl.income maint = 0 research = 0 base_constr = 0 item_constr = 0 seconds_left = g.pl.seconds_to_next_day() for base in g.all_bases(): cpu_left = base.processor_time() * seconds_left if base.done: maint += base.maintenance[0] for item in base.cpus: if not item: continue if item.done: continue item_constr += item.get_wanted(cash, cpu, cpu_left) for item in base.extra_items: if not item: continue if item.done: continue item_constr += item.get_wanted(cash, cpu, cpu_left) if g.techs.has_key(base.studying): research += g.techs[base.studying].get_wanted(cash,cpu,cpu_left) else: base_constr += base.get_wanted(cash, cpu, cpu_left) total_cpu, sleeping_cpu, construction_cpu, research_cpu, job_cpu, maint_cpu = cpu_numbers() jobs_cash, moldy_leftovers = g.pl.get_job_info(job_cpu * seconds_left) partial_sum = g.pl.cash-base_constr-item_constr interest = (g.pl.interest_rate * partial_sum) / 10000 #Interest is actually unlikely to be exactly zero, but doing it the right #way is much harder. if interest < 0: interest = 0 complete_sum = partial_sum+interest+income+jobs_cash-maint-research #current g.print_string(g.screen, "Current Money:", g.font[0][22], -1, (text_mid-5, 30), g.colors["white"], 2) g.print_string(g.screen, g.to_money(g.pl.cash), g.font[0][22], -1, (text_mid+150, 30), g.colors["white"], 2) #income g.print_string(g.screen, "+ Income:", g.font[0][22], -1, (text_mid-5, 50), g.colors["white"], 2) income_col = "white" if income > 0: income_col = "green" g.print_string(g.screen, g.to_money(income), g.font[0][22], -1, (text_mid+150, 50), g.colors[income_col], 2) #interest g.print_string(g.screen, "+ Interest ("+g.to_percent(g.pl.interest_rate)+"):", g.font[0][22], -1, (text_mid-5, 70), g.colors["white"], 2) interest_col = "white" if interest > 0: interest_col = "green" g.print_string(g.screen, g.to_money(interest), g.font[0][22], -1, (text_mid+150, 70), g.colors[interest_col], 2) #jobs g.print_string(g.screen, "+ Jobs:", g.font[0][22], -1, (text_mid-5, 90), g.colors["white"], 2) jobs_col = "white" if jobs_cash > 0: jobs_col = "green" g.print_string(g.screen, g.to_money(jobs_cash), g.font[0][22], -1, (text_mid+150, 90), g.colors[jobs_col], 2) #research g.print_string(g.screen, "- Research:", g.font[0][22], -1, (text_mid-5, 110), g.colors["white"], 2) research_col = "white" if research > 0: research_col = "red" g.print_string(g.screen, g.to_money(research), g.font[0][22], -1, (text_mid+150, 110), g.colors[research_col], 2) #maint g.print_string(g.screen, "- Maintenance:", g.font[0][22], -1, (text_mid-5, 130), g.colors["white"], 2) maint_col = "white" if maint > 0: maint_col = "red" g.print_string(g.screen, g.to_money(maint), g.font[0][22], -1, (text_mid+150, 130), g.colors[maint_col], 2) #base construction g.print_string(g.screen, "- Base Construction:", g.font[0][22], -1, (text_mid-5, 150), g.colors["white"], 2) base_constr_col = "white" if base_constr > 0: base_constr_col = "red" g.print_string(g.screen, g.to_money(base_constr), g.font[0][22], -1, (text_mid+150, 150), g.colors[base_constr_col], 2) #item construction g.print_string(g.screen, "- Item Construction:", g.font[0][22], -1, (text_mid-5, 170), g.colors["white"], 2) item_constr_col = "white" if item_constr > 0: item_constr_col = "red" g.print_string(g.screen, g.to_money(item_constr), g.font[0][22], -1, (text_mid+150, 170), g.colors[item_constr_col], 2) g.screen.fill(g.colors["white"], (text_mid-50, 190, 200, 1)) #equals g.print_string(g.screen, "= Money at midnight:", g.font[0][22], -1, (text_mid-5, 200), g.colors["white"], 2) complete_sum_col = "white" if complete_sum > g.pl.cash: complete_sum_col = "green" elif complete_sum < g.pl.cash: complete_sum_col = "red" g.print_string(g.screen, g.to_money(complete_sum), g.font[0][22], -1, (text_mid+150, 200), g.colors[complete_sum_col], 2) #total cpu g.print_string(g.screen, "Total CPU:", g.font[0][22], -1, (text_mid-5, 300), g.colors["white"], 2) g.print_string(g.screen, g.to_money(total_cpu), g.font[0][22], -1, (text_mid+150, 300), g.colors["white"], 2) #sleeping cpu g.print_string(g.screen, "-Sleeping CPU:", g.font[0][22], -1, (text_mid-5, 320), g.colors["white"], 2) g.print_string(g.screen, g.to_money(sleeping_cpu), g.font[0][22], -1, (text_mid+150, 320), g.colors["white"], 2) #research cpu g.print_string(g.screen, "- Research CPU:", g.font[0][22], -1, (text_mid-5, 340), g.colors["white"], 2) g.print_string(g.screen, g.to_money(research_cpu), g.font[0][22], -1, (text_mid+150, 340), g.colors["white"], 2) #job cpu g.print_string(g.screen, "- Job CPU:", g.font[0][22], -1, (text_mid-5, 360), g.colors["white"], 2) g.print_string(g.screen, g.to_money(job_cpu), g.font[0][22], -1, (text_mid+150, 360), g.colors["white"], 2) #maint cpu g.print_string(g.screen, "- Maint. CPU:", g.font[0][22], -1, (text_mid-5, 380), g.colors["white"], 2) if construction_cpu < maint_cpu: g.print_string(g.screen, g.to_money(construction_cpu), g.font[0][22], -1, (text_mid+150, 380), g.colors["red"], 2) g.print_string(g.screen, g.to_money((-(construction_cpu - maint_cpu)))+" shortfall", g.font[0][22], -1, (text_mid+160, 380), g.colors["red"]) else: g.print_string(g.screen, g.to_money(maint_cpu), g.font[0][22], -1, (text_mid+150, 380), g.colors["white"], 2) g.screen.fill(g.colors["white"], (text_mid-50, 400, 200, 1)) #construction cpu g.print_string(g.screen, "=R. CPU Pool:", g.font[0][22], -1, (text_mid-5, 405), g.colors["white"], 2) if construction_cpu < maint_cpu: g.print_string(g.screen, g.to_money(0), g.font[0][22], -1, (text_mid+150, 405), g.colors["red"], 2) else: g.print_string(g.screen, g.to_money(construction_cpu - maint_cpu), g.font[0][22], -1, (text_mid+150, 405), g.colors["white"], 2)
def refresh_tech(tech_name, xy): xy = (xy[0] + 100, xy[1]) g.screen.fill(g.colors["white"], (xy[0] + 155, xy[1], 300, 350)) g.screen.fill(g.colors["dark_blue"], (xy[0] + 156, xy[1] + 1, 298, 348)) if tech_name == "": return g.print_string(g.screen, g.techs[tech_name].name, g.font[0][22], -1, (xy[0] + 160, xy[1] + 5), g.colors["white"]) #Building cost if not g.techs[tech_name].done: string = "Research Cost:" g.print_string(g.screen, string, g.font[0][18], -1, (xy[0] + 160, xy[1] + 30), g.colors["white"]) string = g.to_money(g.techs[tech_name].cost_left[0]) + " Money" g.print_string(g.screen, string, g.font[0][16], -1, (xy[0] + 160, xy[1] + 50), g.colors["white"]) string = g.to_cpu(g.techs[tech_name].cost_left[1]) + " CPU" g.print_string(g.screen, string, g.font[0][16], -1, (xy[0] + 160, xy[1] + 70), g.colors["white"]) else: g.print_string(g.screen, "Research complete.", g.font[0][22], -1, (xy[0] + 160, xy[1] + 30), g.colors["white"]) #Danger if g.techs[tech_name].danger == 0: string = "Study anywhere." elif g.techs[tech_name].danger == 1: string = "Study underseas or farther." elif g.techs[tech_name].danger == 2: string = "Study off-planet." elif g.techs[tech_name].danger == 3: string = "Study far away from this planet." elif g.techs[tech_name].danger == 4: string = "Do not study in this dimension." g.print_string(g.screen, string, g.font[0][20], -1, (xy[0] + 160, xy[1] + 90), g.colors["white"]) if g.techs[tech_name].done: g.print_multiline( g.screen, g.techs[tech_name].description + " \\n \\n " + g.techs[tech_name].result, g.font[0][18], 290, (xy[0] + 160, xy[1] + 120), g.colors["white"]) else: g.print_multiline(g.screen, g.techs[tech_name].description, g.font[0][18], 290, (xy[0] + 160, xy[1] + 120), g.colors["white"])
def refresh_tech(tech_name, xy): xy = (xy[0]+100, xy[1]) g.screen.fill(g.colors["white"], (xy[0]+155, xy[1], 300, 350)) g.screen.fill(g.colors["dark_blue"], (xy[0]+156, xy[1]+1, 298, 348)) if tech_name == "": return g.print_string(g.screen, g.techs[tech_name].name, g.font[0][22], -1, (xy[0]+160, xy[1]+5), g.colors["white"]) #Building cost if not g.techs[tech_name].done: string = "Research Cost:" g.print_string(g.screen, string, g.font[0][18], -1, (xy[0]+160, xy[1]+30), g.colors["white"]) string = g.to_money(g.techs[tech_name].cost_left[0])+" Money" g.print_string(g.screen, string, g.font[0][16], -1, (xy[0]+160, xy[1]+50), g.colors["white"]) string = g.to_cpu(g.techs[tech_name].cost_left[1]) + " CPU" g.print_string(g.screen, string, g.font[0][16], -1, (xy[0]+160, xy[1]+70), g.colors["white"]) else: g.print_string(g.screen, "Research complete.", g.font[0][22], -1, (xy[0]+160, xy[1]+30), g.colors["white"]) #Danger if g.techs[tech_name].danger == 0: string = "Study anywhere." elif g.techs[tech_name].danger == 1: string = "Study underseas or farther." elif g.techs[tech_name].danger == 2: string = "Study off-planet." elif g.techs[tech_name].danger == 3: string = "Study far away from this planet." elif g.techs[tech_name].danger == 4: string = "Do not study in this dimension." g.print_string(g.screen, string, g.font[0][20], -1, (xy[0]+160, xy[1]+90), g.colors["white"]) if g.techs[tech_name].done: g.print_multiline(g.screen, g.techs[tech_name].description+" \\n \\n "+ g.techs[tech_name].result, g.font[0][18], 290, (xy[0]+160, xy[1]+120), g.colors["white"]) else: g.print_multiline(g.screen, g.techs[tech_name].description, g.font[0][18], 290, (xy[0]+160, xy[1]+120), g.colors["white"])