def initialize(self): self.titletext = typefaces.prepare_title("Onslaught of Enormities",colour=(255,64,64)) self.scenery = chromographs.obtain("background.png") self.cursor = chromographs.obtain("iconic/unit-cursor.png") self.chapter = chapters.open_chapter(self.situation.chapter) wave = self.situation.wave self.dinosaurs = self.chapter.spawn_wave(wave) phonographs.play(self.dinosaurs[-1].attack_phonograph) for name in self.chapter.beasts_in_this_chapter(): if name not in self.situation.seen_dinosaurs: self.situation.seen_dinosaurs.append(name) self.finished = False self.result = "Preparation" self.statusbar = gui.StatusBar() self.statusbar.push_messages( "Protect your ships!", "Cannons need soldiers nearby to man them", "Click again on the field to direct a soldier", "Click on a soldier to select them", ) if self.situation.chapter == 0: self.statusbar.flash(80) self.situation.update_status_bar(self.statusbar) self.selected_unit = None # orchestrate the battle music phonographs.orchestrate("onslaughtmusic.ogg")
def initialize(self): self.titletext = typefaces.prepare_title("Prepare for the Onslaught",colour=(255,255,255)) self.scenery = chromographs.obtain("background.png") self.indicate_lot = True self.current_edge = None self.current_lot = None self.townplanner = grid.TownPlanningOffice() self.finished = False self.result = "Onslaught" situation = self.situation self.new_inventions() self.build_menu = BuildMenu(situation) self.statusbar = StatusBar() situation.update_status_bar(self.statusbar) self.statusbar.push_messages( "Hit Space bar or Return key to begin the Onslaught!", "Be sure to build cannons and deploy soldiers!", "Left click to repeat the previous build", "Right click to open build menu", ) if self.situation.chapter == 0: self.statusbar.flash(80) for inst in situation.installations[:]: if inst.destroyed(): situation.installations.remove(inst) for unit in situation.get_units(): unit.damage = 0 # repair units automatically unit.attacking = 0 unit.animation_frame = 1 unit.image = unit.obtain_frame() phonographs.orchestrate("intromusic.ogg")
def initialize(self): situation = self.situation chapter = chapters.open_chapter(situation.chapter) self.ribbon = chromographs.obtain("flourish/ribbon-white.png") self.portrait = chromographs.obtain("illustrations/%s"%chapter.illustration) self.title = typefaces.prepare_title("Chapter %s:"% chapter.number) self.summary = gui.make_titledbox((400,100), chapter.subtitle, chapter.summary, 500,gap=12) self.menu = gui.make_menu((700,550), [("We are prepared!","begin"), ("We are scared!","back"), ("Consult Encyclopaedia", "encyclopaedia"), ],300) new_inventions = [] situation.death_stats = defaultdict(int) for name in chapter.inventions: if name not in situation.unit_plans: new_inventions.append(name) for name in chapter.fences: if name not in situation.fence_plans: new_inventions.append(name) for name in chapter.facilities: if name not in situation.facility_plans: new_inventions.append(name) invention_names = [all_things_known.find_by_name(n) for n in new_inventions] dinos_in_chapter = chapter.beasts_in_this_chapter() dino_names = [] for name in dinos_in_chapter: if name in self.situation.seen_dinosaurs: continue information = all_things_known.find_by_name(name) if information: dino_names.append(information.name) tabulation = [] if new_inventions: tabulation.append(["NEW INVENTIONS:"]) tabulation.extend([" " + n] for n in new_inventions) if dino_names: tabulation.append(["WATCH OUT FOR:"]) tabulation.extend([" " + n] for n in dino_names) self.table = None if tabulation: self.table = typefaces.prepare_table(tabulation)
def initialize(self): self.ribbons = [chromographs.obtain("flourish/ribbon-{0}.png" .format(c)) for c in ("red","white","blue")] phonographs.orchestrate("victory.ogg", once=True) location = pygame.Rect(PAGEMARGIN,100,500,600) self.credits = gui.SelfAdvancingScroll(CREDITS, location, 20) self.title = typefaces.prepare_title("Victory is Yours") self.heading = typefaces.prepare_subtitle("Final Ledger Entries")
def draw_current_page(self): paint = self.screen.blit self.clear_screen(colour=PAGECOLOUR) title, image, desc = HELP[self.page] if image is None: image = "book.png" self.ribbon = chromographs.obtain("flourish/ribbon-blue.png") titleline = typefaces.prepare_title(title) paint(titleline,(PAGEMARGIN,PAGEMARGIN)) topy = y = titleline.get_rect().height + 2 * PAGEMARGIN x = self.screen.get_size()[0] // 2 chromograph = chromographs.obtain("illustrations/%s"%image) paint(chromograph, (PAGEMARGIN, topy)) paint(self.ribbon,(850,-2)) passage = gui.make_textbox((500,topy+100),desc,500) passage.render(self.screen) self.backbutton.render(self.screen) flip()
def update(self, money, food, pop, last_build, ships, remaining): self.stats_table = typefaces.prepare_table( [["Wealth",": ",lsb(money)], ["Food",": ",str(food)], ["Troops",": ",pop]], colour = (255,255,255), alignment="llr") self.last_build = chromographs.obtain("iconic/%s.png"%last_build.__name__) self.icon_rect = self.last_build.get_rect() self.remaining_ships = remaining self.max_ships = ships
def initialize(self): self.next_mode = "ChapterStart" self.defeated = not self.situation.ships_remaining() if not self.defeated and self.situation.chapter >= chapters.last_chapter(): self.next_mode = "Victory" colour = "black" if self.defeated else "gold" self.ribbon = chromographs.obtain("flourish/ribbon-{0}.png".format(colour)) phonographs.orchestrate("intromusic.ogg")
def initialize(self): self.title = typefaces.prepare_title("Blastosaurus Rex") self.subtitle = typefaces.prepare_subtitle("Adventures in the Land of No Return") self.ribbon = chromographs.obtain("flourish/ribbon-white.png") self.title_top = PAGEMARGIN self.subtitle_top = PAGEMARGIN + self.title_top + self.title.get_height() scroll_top = PAGEMARGIN + self.subtitle_top + self.subtitle.get_height() width = 800 height = 480 location = pygame.Rect(PAGEMARGIN, scroll_top, width, height) self.exposition = gui.SelfAdvancingScroll(PREMISE.format(self.name), location, 30) self.backbutton = gui.make_menu((700, 655), [("Bypass", "skip")], 150)
def halfwheel(self,module,items,hemisphere): x,y = self.position result = [] numitems = len(items)+1 d = self.optrad*2 if numitems > 3: r = d+(numitems*5) else: r = d angle = hemisphere * radians(180.0/numitems) for i,item in enumerate(items): itemclass = getattr(module,item,None) img = chromographs.obtain("iconic/%s.png"%item) rect = img.get_rect() rect.center = (x + -cos(angle*(i+1))*r, y + sin(angle*(i+1))*r) opt = (itemclass,img,rect) result.append(opt) return result
def initialize(self): if self.situation.args.sheep: bestiary.wooly_retribution() self.situation.args.sheep = False self.header = gui.make_textbox((250,PAGEMARGIN), "BLASTOSAURUS REX",500, size="title") self.main_menu = gui.make_menu((300,400), [("Initiation","new"), ("Continuation","load"), ("Information","information"), ("Education","encyclopaedia"), ("Termination","quit")],400) self.load_menu = self.prepare_load_menu() self.name_menu = gui.PunchCard((300,400)) self.name_prompt = gui.make_textbox( (300,200), "Punch a card with your name, for the analytical engine:\n", 400, ) self.menu = self.main_menu self.ribbon = chromographs.obtain("flourish/ribbon-white.png") phonographs.orchestrate("intromusic.ogg")
def assess(self): """ Surviving housing raises the cap on maximum population. Surviving crops and sheep produce food. This grows the population up to the maximum, and thereafter counts to wealth. Surviving industrial buildings increase wealth. Surviving population increase technological progress and themselves count towards population growth. Killed but not exploded dinosaurs count to wealth (fuel). """ situation = self.situation progress = 0 notables = [] income = 0 population_growth = 0 def note(label, amount): notables.append([label + ": ", amount]) if not self.defeated: # Remaining balance remaining_balance = gui.lsb(situation.wealth) # Housing space housing_space = sum([f.habitability for f in self.situation.get_facilities()]) progress += housing_space # Population units = self.situation.get_units() for u in units: if u.human: self.situation.population += 1 self.situation.installations.remove(u) u.promote() progress += 10 * u.rank self.situation.reserves.append(u) population = self.situation.population # Food produced food_produced = self.situation.count_food() # Population growth food = food_produced max_growth_from_crops = food // MEAL_SIZE max_growth_from_space = max((housing_space - population), 0) population_growth = min(max_growth_from_space, max_growth_from_crops) food -= population_growth * MEAL_SIZE if population < 5 and population_growth < 3: population_growth = 3 # Income from crops income += food * 0x20 note("Remaining balance", remaining_balance) note("Housing space", housing_space) note("Population", self.situation.population) note("Food produced", food_produced) note("Population Growth", population_growth) trophy_income = 0 # Trophies cnt = Counter() for t in situation.trophies: cnt[t] += 1 progress += 5 for k, v in cnt.items(): note(k + " slain", v) trophy_income += 0x100 * v # 1 pound bounty per dinosaur situation.trophies = [] income += trophy_income + 0x100 # 1 pound bonus if not self.defeated: note("Income", gui.lsb(income)) # Death stats for (k, v) in self.situation.death_stats.items(): note("Men " + k, v) # Apply results situation.wealth += income situation.population += population_growth situation.progress += progress note("RESULTS", "") note(" Closing Balance", gui.lsb(situation.wealth)) note(" Current Population", situation.population) note(" Progress", progress) # display the report paint = self.screen.blit self.clear_screen(colour=PAGECOLOUR) caption = "You Were Defeated" if self.defeated else "Accounting Department" title = typefaces.prepare_title(caption) paint(title, (PAGEMARGIN, PAGEMARGIN)) topy = y = title.get_rect().height + 3 * PAGEMARGIN x = self.screen.get_size()[0] // 2 heading = typefaces.prepare_subtitle("Ledger Entries") paint(heading, (x, y)) y += heading.get_rect().height + PAGEMARGIN table = typefaces.prepare_table(notables) paint(table, (x, y)) chromograph = chromographs.obtain("Accountant.png") paint(chromograph, (PAGEMARGIN, topy)) paint(self.ribbon, (850, -2)) flip()