def sub_input(device: AbstractIO, model: GameModel): # 4020 POKE VAL "23659",VAL "2": # POKE VAL "23613",NOT PI: # INPUT LINE F$: # POKE VAL "23659",NOT PI: # IF F$="" THEN # LET F$="0": # GO TO VAL "4026" while True: f = device.input() if f == '': f = '0' # 4021 IF F$="k" OR f$="K" THEN # LET OI=SGN PI: # GO SUB OITOG: # GO TO VAL "50" # to main menu if f == 'k' or f == 'K': raise EndGameException(True) # 4022 IF F$="d" OR f$="D" THEN GO SUB VAL "4040": GO SUB VAL "120" if f == 'd' or f == 'D': save_load() # start_program() # 4024 FOR N=SGN PI TO LEN F$: # IF CODE F$(N)<VAL "48" OR CODE F$(N)>VAL "57" THEN GO TO VAL "4020" # 4025 NEXT N # 4026 RETURN if f.isdecimal(): return f
def intervention(device: AbstractIO, model: GameModel): """Intervention of enemies""" # 1860 REM \#017\#001WTORVENIE\#017\#000 # 1870 LET RASST=RASST-FN S(VAL "5")-VAL "10" model.distance_to_enemies -= randint(11, 15) # 1880 IF RASST<FN S(VAL "\{f0}5") THEN GO SUB ATAKA: GO TO VAL "1900" if model.distance_to_enemies < randint(1, 5): attack_by_enemies(device, model) # 1890 IF (RASST<VAL "15") AND (RND<0.1) THEN # PRINT AT VAL "11",SGN PI;"wRAGI SOWER[ILI STREMITELXNYJ";AT VAL "12",VAL "9";"MAR[ - BROSOK!": # GO SUB KEY: # GO SUB CLS: # GO SUB ATAKA elif model.distance_to_enemies < 15 and random() < 0.1: device.at(11, 1).print("Враги совершили стремительный") device.at(12, 9).print("марш - бросок!") device.wait_key() device.cls() attack_by_enemies(device, model)
def game_results(device: AbstractIO, model: GameModel, result): # 1980 REM \#017\#001OITOG\#017\#000 # 1985 GO SUB CLS device.cls() # 1987 RANDOMIZE USR VAL "64042" device.show_image("game_end") # 1990 IF OI=SGN PI THEN # PRINT AT VAL "8",INT PI;"\{i5}wA[E PRAWLENIE OKON^ENO!!!\{i7}"; # AT VAL "10",VAL "2";"wY UPRAWLQLI STRANOJ ";TIME;" LET": # PRINT " zA \\TO WREMQ UMERLO OT GOLODA"; # AT VAL "12",VAL "8";UMERWSEGO;" ^ELOWEK" if result: device.at(8, 3).ink(5).print("Ваше правление окончено!!!").ink(7) device.at(10, 2).print(f"Вы управляли страной {model.time} лет") device.print(" За это время умерло от голода ") device.at(12, 8).print(f"{model.dead_total} человек") # 2000 LET BOG=ZEML*CENA+ZERNO wealth = model.wealth() # 2010 IF (BOG>NBOG) AND (OI=1) THEN # PRINT AT VAL "14",BIN ;"wY UWELI^ILI BOGATSTWO W ";INT (BOG/NBOG);" RAZ!": # GO TO VAL "2030" if result: if wealth > model.initial_wealth: device.at(14, 0).print(f"Вы увеличили богатство в {wealth // model.initial_wealth} раз!") # 2020 IF OI=SGN PI THEN # PRINT AT VAL "14",VAL "5";"wY RAZORILI STRANU!!!" else: device.at(14, 5).print("Вы разорили страну!!!") # 2030 IF OI=SGN PI THEN # PRINT AT VAL "17",VAL "7";"\{i4}do swidaniq!!!": # GO TO VAL "2045" if result: device.at(17, 7).ink(4).print("До свидания!!!") # 2040 IF OI=BIN THEN # PRINT AT VAL "9",BIN ;"\{i2}tAKIH NADO GNATX IZ PRAWITELEJ!!"; # AT VAL "11",SGN PI;"wY EDWA PRODERVALISX U WLASTI"; # AT VAL "12",VAL "10";TIME;" LET": # PRINT AT VAL "14",BIN ;"\{i2}I UMORILI GOLODOM ";UMERWSEGO;" ^ELOWEK": # PRINT AT VAL "16",VAL "5";"\{i2}kUDA \\TO GODITSQ?!" else: device.at(9, 0).ink(2).print("Таких надо гнать из правителей!!") device.at(12, 1).print("Вы едва продержались у власти") device.at(12, 10).print(f"{model.time} лет") if model.dead_total > 0: device.at(14, 0).ink(2).print(f"и уморили голодом {model.dead_total} человек") device.at(16, 5).ink(2).print("Куда это годится?!") # 2045 GO SUB KEY device.wait_key()
def guard(device: AbstractIO, model: GameModel): # 610 REM \#017\#001OHRANA\#017\#000 while True: # 620 LET UBITO=NOT PI: LET Z=-1 ubito = 0 # FIXME: Add to model? # 630 GO SUB PUS: PRINT AT VAL "20",VAL "5";"u NAS ";NAS;" ^ELOWEK" empty_lines(device) device.at(20, 5).print(f"У нас {model.population} человек") # 640 PRINT AT VAL "21",INT PI;"sKOLXKO PO[LEM W WOJSKO?": # GO SUB INPUT: # LET Z=VAL F$: # GO SUB PUS device.at(21, 3).print("Сколько пошлём в войско?") try: model.defenders = int(sub_input(device, model)) except ValueError: model.defenders = -1 empty_lines(device) # 650 IF Z<NOT PI THEN GO TO VAL "620" if model.defenders < 0: continue # 660 IF Z>NAS THEN PRINT AT VAL "20",VAL "6";"u NAS MALO L\@DEJ!!!": # GO SUB KEY: # GO SUB PUS: # GO TO VAL "620" if model.defenders > model.population: device.at(20, 6).print("У нас мало людей!!!") device.wait_key() empty_lines(device) continue # 670 IF Z>INT (ZERNO/VAL "5") THEN # PRINT AT VAL "20",SGN PI;"zERNA HWATIT NA ";INT (ZERNO/5);" WOINOW": # GO SUB KEY: # GO SUB PUS: # GO TO VAL "620" if model.defenders > model.grain // 5: device.at(20, 1).print(f"Зерна хватит на {model.grain // 5} воинов") device.wait_key() empty_lines(device) continue # 680 IF Z>NOT PI THEN # LET OST=NAS-Z: # LET ZERNO=ZERNO-Z*5: # RETURN if model.defenders > 0: model.ost = model.population - model.defenders model.grain -= model.defenders * 5 else: # 690 LET OST=NAS: # RETURN model.ost = model.population return
def empty_lines(device: AbstractIO): # 4030 PRINT AT VAL "20",BIN ;S$: RETURN device.at(20, 0).print(" " * 64)
def defeat(device: AbstractIO, model: GameModel): # 1240 REM \#017\#001PORAVENIE\#017\#000 # 1245 GO SUB CLS: RANDOMIZE USR VAL "54778" device.cls() device.show_image("enemies") # 1250 PRINT AT VAL "11",VAL "5";"\{i3}poravenie w hAMONII!!!" device.at(11, 5).ink(3).print("ПОРАЖЕНИЕ В Хамонии!!!") # 1260 LET UBITO=INT (ZAHW*(0.8+RND/5)): # LET NAS=NAS+ZAHW-UBITO: # LET POGIB=POGIB+UBITO ubito = int(model.warriors * (0.8 + random() / 5)) model.population += model.warriors - ubito model.dead_in_battles += ubito # 1270 PRINT AT VAL "13",SGN PI;"pOGIBLO - ";UBITO;" WOINOW" device.at(13, 1).print(f"Погибло - {ubito} воинов") # 1280 LET ZAHW=BIN : # LET OST=NAS-Z-INT (ZAS/PROIZ) model.warriors = 0 model.ost = model.population - model.defenders - model.zas // model.sower_productivity # 1285 GO SUB KEY: GO SUB CLS device.wait_key() device.cls()
def war(device: AbstractIO, model: GameModel): # 960 REM \#017\#001hAMONIQ\#017\#000 # 970 IF (OST<=BIN ) OR (ZERNO<=5) THEN # LET POS=BIN : # GO TO VAL "1030" if model.ost <= 0 or model.grain < 5: pos = 0 else: # 980 PRINT AT VAL "19",SGN PI;"u NAS ";OST;" NEZANQTYH L\@DEJ": # PRINT AT VAL "20",BIN ;"zERNA HWATIT NA ";INT (ZERNO/5);" WOINOW" device.at(12, 1).print(f"У нас {model.ost} незанятых людей") device.at(20, 0).print(f"Зерна хватит на {model.grain // 5} воинов") while True: # 990 LET POS=-1: PRINT AT VAL "21",INT PI;"sKOLXKO PO[LEM W hAMONI\@?" device.at(21, 1).print("Сколько пошлём в Хамонию?") # 1000 GO SUB INPUT: # LET POS=VAL F$: # PRINT AT VAL "18",BIN ;S$: # GO SUB PUS: # IF POS<BIN THEN GO TO VAL "990" try: pos = int(sub_input(device, model)) except ValueError: pos = -1 device.at(18, 0).print(64 * " ") empty_lines(device) if pos < 0: continue # 1010 IF POS>OST THEN # PRINT AT VAL "20",VAL "5";"u NAS MALO L\@DEJ!!!": # GO SUB KEY: # GO SUB PUS: # GO TO VAL "990" if pos > model.ost: device.at(20, 5).print("У нас мало людей!!!") device.wait_key() empty_lines(device) continue # 1020 IF POS>INT (ZERNO/5) THEN # PRINT AT VAL "20",VAL "6";"u NAS MALO ZERNA!!!": # GO SUB KEY: # GO SUB PUS: # GO TO VAL "990" if pos * 5 > model.grain: device.at(20, 6).print("У нас мало зерна!!!") device.wait_key() empty_lines(device) continue break # 1030 IF POS<=NOT PI THEN GO TO VAL "1070" if pos > 0: # 1040 LET NAS=NAS-POS: LET OST=OST-POS: LET ZERNO=ZERNO-POS*5 model.population -= pos model.ost -= pos model.grain -= pos * 5 # 1050 IF ZAHW>BIN THEN LET ZAHW=ZAHW+POS: GO TO VAL "1070" if model.warriors > 0: model.warriors += pos else: # 1060 LET ZAHW=POS: LET SROK=TIME+FN S(4) model.warriors = pos model.srok = model.time + randint(1, 4) # 1070 IF ZAHW<=NOT PI THEN GO TO VAL "1140" # 1080 IF SROK<>TIME THEN GO TO VAL "1140" if model.warriors > 0 and model.srok == model.time: # 1090 IF ZAHW>NAS*VAL "2" THEN GO SUB POBEDA: GO TO VAL "1140" if model.warriors > model.population * 2: victory(device, model) # 1100 IF ZAHW<INT (NAS/VAL "2") THEN GO SUB PORAV: GO TO VAL "1140" elif model.warriors < model.population // 2: defeat(device, model) # 1110 IF RND>0.5 THEN GO SUB POBEDA: GO TO VAL "1140" elif random() > 0.5: victory(device, model) # 1120 GO SUB PORAV else: defeat(device, model)
def victory(device: AbstractIO, model: GameModel): # 1150 REM \#017\#001POBEDA\#017\#000 # 1155 GO SUB CLS: RANDOMIZE USR VAL "54778" device.cls() device.show_image("enemies") # 1160 PRINT AT VAL "11",VAL "2";"\{i6}w hAMONII ODERVANA pobeda!!!" device.at(11, 2).ink(6).print("В Хамонии одержана победа!!!") # 1170 LET T(INT PI)=INT (NAS*(RND/3+0.3)): # LET T(SGN PI)=INT (ZAHW*(FN S(VAL "10")+VAL "4")): # LET T(VAL "2")=INT (ZEML*(RND/VAL "2"+0.3)): # LET NAS=NAS+T(INT PI): # LET ZEML=ZEML+T(VAL "2"): # LET ZERNO=ZERNO+T(SGN PI) captured_people = int(model.population * (random() / 3 + 0.3)) taken_grain: int = model.warriors * randint(1, 10) + 4 annexed_territory = int(model.land * (random() / 2 + 0.3)) model.population += captured_people model.land += annexed_territory model.grain += taken_grain # 1180 LET UBITO=INT (ZAHW*(RND/5+0.3)): # LET POGIB=POGIB+UBITO: # LET NAS=NAS+ZAHW-UBITO ubito = int(model.warriors * (random() / 5 + 0.3)) model.dead_in_battles += ubito model.population += model.warriors - ubito # 1190 PRINT AT VAL "13",BIN ;"u WRAGA ZAHWA^ENO:" device.at(13, 0).print("У врага захвачено:") # 1200 PRINT AT VAL "14",SGN PI;"zERNA - ";T(1);" BU[ELEJ": # PRINT " zEMLI - ";T(2);" AKROW": PRINT " pLENNYH - ";T(3);" ^ELOWEK" device.at(14, 1).print(f"Зерна - {taken_grain} бушелей") device.print(f"Земли - {annexed_territory} акров") device.print(f"Пленных - {captured_people} человек") # 1210 PRINT AT VAL "18",VAL "6";"iZ ";ZAHW;" WOINOW ";UBITO;AT VAL "19",VAL "10";"PALO SMERTX\@ HRABRYH!" device.at( 18, 6).print(f"Из {model.warriors} воинов {ubito} пало сметрью храбрых!") # 1220 LET ZAHW=BIN : # LET OST=NAS-Z-INT (ZAS/PROIZ) model.warriors = 0 model.ost = model.population - model.defenders - int( model.zas / model.sower_productivity) # 1225 GO SUB KEY: # GO SUB CLS device.wait_key() device.cls()
def events(device: AbstractIO, model: GameModel): # 1550 REM \#017\#001NN\#017\#000 # 1555 GO SUB CLS device.cls() # 1560 LET BEV=INT (RND*INT (NAS/4)) model.refugees = int(random() * (model.population // 4)) # 1570 IF (RASST<20) AND (RND>.5) THEN # LET BEV=BEV+INT (RND*BEV): # PRINT AT VAL "11",INT PI;"pRITOK BEVENCEW SPASA\@]IHSQ";AT VAL "12",VAL "7";"OT ZAHWAT^IKOW!!!": # GO SUB KEY: # GO SUB CLS if model.distance_to_enemies < 20 and random() > 0.5: model.refugees += int(random() * model.refugees) device.at(11, 3).print("Приток беженцев, спасающихся").at(12, 7).print("от захватчиков!!!") device.wait_key() device.cls() # 1580 LET NAS=NAS+BEV model.population += model.refugees # 1590 IF (K<10) OR (UMERWSEGO>NAS*10) THEN # RANDOMIZE USR VAL "55936": PRINT AT VAL "11",SGN PI;"nAROD WOSSTAL PROTIW TIRANA!!!": # GO SUB KEY: # GO SUB CLS: # GO TO VAL "1610" if model.feeding_per_worker < 10 or model.dead_total > model.population * 10: device.show_image("riot") device.at(11, 1).print("Народ восстал против тирана!!!") device.wait_key() device.cls() # 1610 IF (Z>(NAS-Z)/3) AND (Z<UMERGOL) THEN # RANDOMIZE USR "54778": # PRINT AT VAL "11",SGN PI;"nO WOJSKA PODAWILI WOSSTANIE!": # LET WOSST=(NAS-Z)*INT (RND/5+0.1): # LET POGIB=POGIB+WOSST: # LET NAS=NAS-WOSST: # PRINT AT VAL "12",VAL "5";"w ULI^NYH BOQH POLEGLO";AT VAL "13",VAL "8";WOSST;" VITELEJ": # GO SUB KEY: # GO SUB CLS: # GO TO VAL "1630" if (model.population - model.defenders) / 3 < model.defenders < model.dead_starvation: device.show_image("enemies") device.at(11, 1).print("Но войска подавили восстание!") rebels = (model.population - model.defenders) * int(random() / 5 + 0.1) model.dead_in_battles += rebels model.population -= rebels device.at(12, 5).print(f"В уличных боях полегло {rebels} жителей") device.wait_key() device.cls() else: # 1620 PRINT AT VAL "11",VAL "4";"wOJSKA PERE[LI NA STORONU";AT VAL "12",VAL "6";"WOSSTAW[EGO NARODA": # PRINT AT VAL "14",VAL "5";"\{i4}monarhiq swergnuta!!!": # GO SUB KEY: # GO SUB CLS: # LET U=SGN PI: # LET OI=BIN : # GO SUB OITOG: # RETURN device.at(11, 4).print("Войска перешли на сторону").at(12, 6).print("восставшего народа") device.at(14, 5).ink(4).print("МОНАРХИЯ СВЕРГНУТА!!!") device.wait_key() device.cls() raise EndGameException(False) # 1600 GO TO VAL "1630" # 1630 LET UMER=UMER+INT (RND*2.5/100*NAS): # LET ROD=INT (RND*(4+K/20)/100*NAS) model.dead_natural_cases += int(random() * 2.5 / 100 * model.population) model.born = int(random() * (4 + model.feeding_per_worker / 20) / 100 * model.population) # 1640 IF FN S(VAL "12")=SGN PI THEN # LET CHUMA=INT (RND*50+VAL "5"): # RANDOMIZE USR VAL "53620": # PRINT AT VAL "11",INT PI;"~UMA UNESLA ";CHUMA;"% NASELENIQ!": # LET UMER=UMER+INT (NAS*CHUMA/100): # GO SUB KEY: # GO SUB CLS if randint(1, 12) == 1: plague = int(random() * 50 + 5) device.show_image("graveyard") device.at(11, 3).print(f"Чума унесла {plague}% населения!") model.dead_natural_cases += model.population * plague // 100 device.wait_key() device.cls() # 1650 IF FN S(VAL "100")<VAL "5" THEN # RANDOMIZE USR VAL "46225": # PRINT AT VAL "11",VAL "4";"dEMOGRAFI^ESKIJ WZRYW!!!": # LET DEM=INT ((RND/VAL "2"+0.5)*NAS): # LET ROD=ROD+DEM: # GO SUB KEY: # GO SUB CLS if randint(1, 100) < 5: device.show_image("baby_boom") device.at(11, 4).print("Демографический взрыв!!!") dem = int((random() / 2 + 0.5) * model.population) model.born += dem device.wait_key() device.cls() # 1660 IF (FN S(VAL "20"))=VAL "5" THEN # RANDOMIZE USR VAL "52462": # PRINT AT VAL "11",VAL "6";"\{i2}pova - a - a - ar!!!": # LET SGOR=INT (NAS*(RND/3+0.3)): # LET SGORZER=INT (ZERNO*(RND/4+0.1)): # GO SUB KEY: # GO SUB CLS: # GO TO VAL "1666" if randint(1, 20) == 5: device.show_image("fire") device.at(11, 6).ink(2).print("ПОЖА - А - А - АР!!!") dead_in_fire = int(model.population * (random() / 3 + 0.3)) burnt_down_grain = int(model.grain * (random() / 4 + 0.1)) device.wait_key() device.cls() # 1666 LET UMER=UMER+SGOR: # LET ZERNO=ZERNO-SGORZER: # RANDOMIZE USR VAL "53620": # PRINT AT VAL "11",BIN ;"w OGNE POGIBLO ";SGOR;" ^ELOWEK": # PRINT AT VAL "13",BIN ;"sGORELO NA SKLADAH ";SGORZER;AT VAL "14",VAL "11";"BU[.ZERNA": # GO SUB KEY: # GO SUB CLS model.dead_natural_cases += dead_in_fire model.grain -= burnt_down_grain device.show_image("graveyard") device.at(11, 0).print(f"В огне погибло {dead_in_fire} человек") device.at(13, 0).print(f"Сгорело на складах {burnt_down_grain}").at(14, 11).print("буш. зерна") device.wait_key() device.cls() # 1663 GO TO VAL "1670" # 1670 IF FN S(VAL "10")=VAL "2" THEN # LET AGENT=AGENT+SGN PI: # RANDOMIZE USR VAL "45067": # PRINT AT VAL "11",SGN PI;"w GOROD PROBRALSQ DIWERSANT": # GO SUB KEY: # GO SUB CLS: if randint(1, 10) == 2: model.agent += 1 device.show_image("saboteur") device.at(11, 1).print("В город пробрался диверсант") device.wait_key() device.cls() # 1680 IF (AGENT<=BIN ) OR (Z>=NAS/VAL "10") THEN GO TO VAL "1720" if model.agent > 0 and model.defenders < model.population / 10: # 1690 RANDOMIZE USR VAL "52462": # PRINT AT VAL "11",VAL "2";"dIWERSIQ!!!pODOVVENY HLEBNYE";AT VAL "12",VAL "13";"SKLADY.": # LET SGORZER=INT (ZERNO*(RND/3+0.3)): # LET ZERNO=ZERNO-SGORZER: # PRINT AT VAL "14",VAL "2";"sGORELO ";SGORZER;" BU[.ZERNA": # GO SUB KEY: # GO SUB CLS device.show_image("fire") device.at(11, 2).print("Диверсия!!! Подожжены хлебные").at(12, 13).print("склады.") burnt_down_grain = int(model.grain * (random() / 3 + 0.3)) model.grain -= burnt_down_grain device.at(14, 2).print(f"Сгорело {burnt_down_grain} буш. зерна") device.wait_key() device.cls() # 1700 IF Z>NAS/VAL "20" THEN # PRINT AT VAL "11",VAL "6";"dIWERSANT SHWA^EN!!!": # LET AGENT=AGENT-SGN PI: # GO SUB KEY: # GO SUB CLS: # GO TO VAL "1720" if model.defenders > model.population / 20: device.at(11, 6).print("Диверсант схвачен!!!") model.agent -= 1 device.wait_key() device.cls() else: # 1710 RANDOMIZE USR VAL "45067": # PRINT AT VAL "11",VAL "6";"dIWERSANT SKRYLSQ!!!": # GO SUB KEY: # GO SUB CLS device.show_image("saboteur") device.at(11, 6).print("Диверсант скрылся!!!") device.wait_key() device.cls() # 1720 IF (AGENT<=BIN ) OR (Z<=NAS/VAL "2") THEN GO TO VAL "1740" if model.agent > 0 and model.defenders > model.population / 2: # 1730 IF RND<0.5 THEN # PRINT AT VAL "11",VAL "4";"pOJMAN WRAVESKIJ AGENT!!!": # LET AGENT=AGENT-SGN PI: # GO SUB KEY: # GO SUB CLS if random() < 0.5: device.at(11, 4).print("Пойман вражеский агент!!!") model.agent -= 1 device.wait_key() device.cls() # 1740 IF (K>=VAL "60") AND (NAS-Z-INT (ZAS/PROIZ)>=NAS/VAL "5") THEN # RANDOMIZE USR VAL "47383": # PRINT AT VAL "11",BIN ;"tUNEQDSTWU\@]IE \\LEMENTY ZANQLISX SAMOGONOWARENIEM IZ HLEBNYH"; # AT VAL "13",VAL "12";"IZLI[KOW";AT VAL "14",SGN PI;"pONIVAETSQ PROIZWODITELXNOSTX!": # LET PROIZ=PROIZ-VAL "2": # GO SUB KEY: # GO SUB CLS if (model.feeding_per_worker >= 60 and model.population - model.defenders - model.zas // model.sower_productivity >= model.population / 5): device.show_image("parasites") device.at(11, 0).print("Тунеядствующие элементы занялись самогоноварением из хлебных") device.at(13, 12).print("излишков") device.at(14, 1).print("Понижается производительность!") model.sower_productivity -= 2 device.wait_key() device.cls() # 1750 IF FN S(VAL "15")=VAL "8" THEN # RANDOMIZE USR VAL "43909": # PRINT AT VAL "11",VAL "2";"wNEDRENIE NOWYH ORUDIJ TRUDA PODNQLO PROIZWODITELXNOSTX!": # LET PROIZ=PROIZ+VAL "2": # LET PREDEL=PREDEL+VAL "5": # GO SUB KEY: # GO SUB CLS if randint(1, 15) == 8: device.show_image("tools") device.at(11, 2).print("Внедрение новых орудий труда подняло производительность!") model.sower_productivity += 2 model.max_sower_productivity += 5 device.wait_key() device.cls() # 1760 IF FN S(VAL "50")<>VAL "50" THEN GO TO VAL "1800" if randint(1, 50) == 50: # 1770 PRINT AT VAL "11",VAL "5";"\{i6}dworcowyj pereworot!!!" device.at(11, 5).ink(6).print("ДВОРЦОВЫЙ ПЕРВОРОТ!!!") # 1780 IF (FN S(VAL "2")=SGN PI) OR (Z<NAS/VAL "10") THEN # PRINT AT VAL "13",VAL "2";"wY SWERGNUTY S PRESTOLA!!!": # LET U=SGN PI: # LET OI=SGN PI: # GO SUB KEY: # GO SUB CLS: # GO SUB OITOG: # RETURN if randint(1, 2) == 1 or model.defenders < model.population / 10: device.at(13, 2).print("Вы свергнуты с престола!!!") device.wait_key() device.cls() raise EndGameException(True) else: # 1790 PRINT AT VAL "13",VAL "2";"NO WERNYE wAM WOJSKA RAZBILI";AT VAL "14",VAL "11";"MQTEVNIKOW": # GO SUB KEY: # GO SUB CLS device.at(13, 2).print("но верные Вам войска разбили").at(14, 11).print("мятежников") device.wait_key() device.cls() # 1800 IF (TIME<=10) OR (ZAS<>ZEML) THEN GO TO VAL "1820" if model.time > 10 and model.zas == model.land: # 1810 IF IST<VAL "4" THEN # LET IST=IST+SGN PI: # RANDOMIZE USR VAL "62884": # PRINT AT VAL "11",VAL "4";"iSTO]ENIE ZEMELX SNIVAET";AT VAL "12",VAL "10";"UROVAJNOSTX": # GO SUB KEY: # GO SUB CLS: # GO TO VAL "1830" if model.ist < 4: model.ist += 1 device.show_image("bad_harvest") device.at(11, 4).print("Истощение земель снижает").at(12, 10).print("урожайность") device.wait_key() device.cls() else: # 1820 IF (ZAS<ZEML/VAL "2") AND (IST> -VAL "2") THEN # LET IST=IST-SGN PI: # RANDOMIZE USR VAL "58252": # PRINT AT VAL "11",INT PI;"oTWEDENIE BOLX[IH PLO]ADEJ";AT VAL "12",VAL "4";"POD PARY POWY[AET UROVAJ": # GO SUB KEY: # GO SUB CLS if model.zas < model.land / 2 and model.ist > -2: model.ist -= 1 device.show_image("excellent_harvest") device.at(11, 3).print("Отведение больших площадей").at(12, 4).print("под пары повышает урожай") device.wait_key() device.cls() # 1830 IF (FN S(VAL "15")=SGN PI) AND (AGENT>BIN ) THEN # LET PROPALO=INT ((RND/VAL "5"+0.1)*ZERNO): # RANDOMIZE USR VAL "47383": # PRINT AT VAL "11",INT PI;"gRUPPOJ RASHITITELEJ POD";AT VAL "12",VAL "2";"PREDWODITELXSTWOM DIWERSANTA"; # AT VAL "13",INT PI;"POHI]ENO ";PROPALO;" BU[.ZERNA": # LET ZERNO=ZERNO-PROPALO: # GO SUB KEY: # GO SUB CLS if randint(1, 15) == 1 and model.agent > 0: stolen = int((random() / 5 + 0.1) * model.grain) device.show_image("parasites") device.at(11, 3).print("Группой расхитителей под") device.at(12, 2).print(f"предводительством диверсанта похищено {stolen} буш. зерна") model.grain -= stolen device.wait_key() device.cls() # 1840 LET NAS=NAS-UMER+ROD model.population += model.born - model.dead_natural_cases
def info(device: AbstractIO, model: GameModel): # 300 REM \#017\#001INFO\#017\#000 # 310 GO SUB CLS device.cls() # 330 PRINT "\{i5}********************************" device.ink(5).print("*" * 32) # 335 PRINT device.print() # 340 INK VAL "6": # PRINT AT VAL "2",VAL "8";TIME;" gOD PRAWLENIQ:": # INK VAL "7" device.ink(6).at(2, 8).print(f"{model.time} Год правления:").ink(7) # 350 IF BEV>BIN THEN PRINT ;"\{b0i7}w GOROD PRI[LO ";BEV;" BEVENCEW" if model.refugees > 0: device.bright(0).ink(7).print( f'В город пришло {model.refugees} беженцев') # 360 PRINT "rODILOSX ";ROD;" ^ELOWEK" device.print(f'Родилось {model.born} человек') # 370 PRINT "\{b0}uMERLO ";UMER;" ^ELOWEK" device.bright(0).print(f'Умерло {model.dead_natural_cases} человек') # 380 IF UMERGOL>BIN THEN PRINT "OT gOLODA - ";UMERGOL;" ^ELOWEK" if model.dead_starvation > 0: device.print(f'От голода - {model.dead_starvation} человек') # 390 IF POGIB>BIN THEN PRINT "\{b0}w BOQH POLEGLO ";POGIB;" ^ELOWEK" if model.dead_in_battles > 0: device.bright(0).print( f'В боях полегло {model.dead_in_battles} человек') # 395 IF NAS<=BIN THEN LET NAS=SGN PI if model.population <= 0: model.population = 1 # 400 PRINT "nASELENIE - ";NAS;" ^ELOWEK" device.print(f"Население - {model.population} человек") # 410 PRINT "\{b0}zEMLI - ";ZEML;" AKROW" device.bright(0).print(f"Земли - {model.land} акров") # 420 PRINT "uROVAJ - ";UROV;" BU[/AKR" device.print(f"Урожай - {model.grain_yield} буш/акр") # 430 IF KRYS>BIN THEN PRINT "kRYSY SOVRALI ";KRYS;" BU[." if model.rats > 0: device.print(f"Крысы сожрали {model.rats} буш.") # 440 PRINT "\{b0}zAPASY ZERNA ";ZERNO;" BU[." device.bright(0).print(f"Запасы зерна {model.grain} буш.") # 450 PRINT "cENA ZEMLI ";CENA;" BU[/AKR" device.print(f"Цена земли {model.land_price} буш/акр") # 460 PRINT "\{b0}hLEBOROB ZASEWAET ";PROIZ;" AKROW" device.bright(0).print( f"Хлебороб засевает {model.sower_productivity} акров") # 470 LET I=25+FN S(10): # IF RASST<I THEN PRINT "nAPADA\@T ";WRAGI;" WOINOW": # PRINT "ONI W ";RASST;" MILQH OT NAS!" i = randint(25, 35) if model.distance_to_enemies < i: device.print(f"Нападают {model.enemies} воинов") device.print(f"Они в {model.distance_to_enemies} милях от нас!") # 475 PRINT # 480 PRINT "\{i5}********************************" device.print() device.ink(5).print("*" * 32)
def sowing(device: AbstractIO, model: GameModel): # 840 REM \#017\#001POSEW\#017\#000 # 850 LET ZAS=-1: # LET UROV=NOT PI: # LET SBOR=NOT PI model.grain_yield = 0 model.harvest = 0 # 860 IF (OST>NOT PI) AND (ZERNO>NOT PI) THEN # GO TO VAL "880" # 870 RETURN if not (model.ost > 0 and model.grain > 0): return # 880 PRINT AT VAL "18",SGN PI;"u NAS ";ZEML;" AKROW ZEMLI": # PRINT AT VAL "19",BIN ;"l\@DI MOGUT ZASEQTX ";PROIZ*OST;" AKROW": # PRINT AT VAL "20",VAL "2";"zERNA HWATIT NA ";ZERNO*2;" AKROW" device.at(18, 1).print(f"У нас {model.land} акров земли") device.at(19, 0).print( f"Люди могут засеять {model.sower_productivity * model.ost} акров") device.at(20, 2).print(f"Зерна хватит на {int(model.grain / 0.5)} акров") while True: # 890 PRINT AT VAL "21",VAL "7";"sKOLXKO ZASEEM?" device.at(21, 7).print("Сколько засеем?") # 900 GO SUB INPUT: LET ZAS=VAL F$: # PRINT AT VAL "18",BIN ;S$: # GO SUB PUS: # IF ZAS<BIN THEN # GO TO VAL "890" try: model.zas = int(sub_input(device, model)) except ValueError: model.zas = -1 device.at(18, 0).print(64 * " ") empty_lines(device) if model.zas < 0: continue # 910 IF ZAS>ZEML THEN # PRINT AT VAL "20",VAL "5";"u NAS MALO ZEMLI!!!": # GO SUB KEY: # GO SUB PUS: # LET ZAS=-1: # GO TO VAL "890" if model.zas > model.land: device.at(20, 5).print("У нас мало земли!!!") device.wait_key() empty_lines(device) continue # 920 IF ZAS/VAL "2">ZERNO THEN # PRINT AT VAL "20",VAL "4";"u NAS NE HWATIT ZERNA!!!": # GO SUB KEY: # GO SUB PUS: # LET ZAS=-1: # GO TO VAL "890" if model.zas * 0.5 > model.grain: device.at(20, 4).print("У нас не хватит зерна!!!") device.wait_key() empty_lines(device) continue # 930 IF INT (ZAS/PROIZ)>OST THEN # PRINT AT VAL "20",VAL "5";"u NAS MALO L\@DEJ!!!": # GO SUB KEY: # GO SUB PUS: # LET ZAS=-1: # GO TO VAL "890" if model.zas / model.sower_productivity > model.ost: device.at(20, 5).print("У нас мало людей!") device.wait_key() empty_lines(device) continue # 940 LET ZERNO=ZERNO-INT (ZAS/VAL "2"): # LET OST=OST-INT (ZAS/PROIZ) model.grain -= int(model.zas * 0.5) model.ost -= model.zas // model.sower_productivity # 950 RETURN return
def main_menu(device: AbstractIO): while True: # 50 GO SUB CLS: RANDOMIZE USR VAL "51304" device.cls() device.show_image("castle") # 53 PRINT AT VAL "9",VAL "7";"\{i6}korolewstwo zerna" # 55 PRINT AT VAL "12",VAL "9";"\{i5}1 sTART IGRY" # 56 PRINT AT VAL "14",VAL "9";"\{i5}2 iNSTRUKCII" # 57 PRINT AT VAL "16",VAL "9";"\{i5}3 aWTORY" # 59 PRINT AT VAL "21",VAL "9";"\{i4}1992 mOSKWA" device.at(9, 7).ink(6).print("КОРОЛЕВСТВО ЗЕРНА") device.at(12, 9).ink(5).print("1 Старт игры") device.at(14, 9).ink(5).print("2 Инструкции") device.at(16, 9).ink(5).print("3 Авторы") device.at(21, 9).ink(4).print("1992 Москва") # 60 GO SUB KEY: IF INKEY$="1" THEN GO TO VAL "80" # 62 IF INKEY$="2" THEN GO SUB INSTR: GO SUB KEY: GO TO VAL "50" # 64 IF INKEY$="3" THEN RANDOMIZE USR VAL "48541": GO SUB KEY: GO TO VAL "50" # 66 GO TO VAL "60" inkey = device.wait_key() if inkey == '1': break elif inkey == '2': instr(device) elif inkey == '3': device.show_image("credits")
def attack_by_enemies(device: AbstractIO, model: GameModel): # 1910 REM \#017\#001ATAKA\#017\#000 # 1920 RANDOMIZE USR VAL "54778": # PRINT AT VAL "11",VAL "7";"\{i3}gorod atakowan!!!": # GO SUB KEY: # LET I=INT (INT (10*RND)*0.1)+0.5: # LET J=I+INT (INT (10*RND)*0.15)+0.5 device.show_image("enemies") device.at(11, 7).ink(3).print("ГОРОД АТАКОВАН!!!") device.wait_key() i = int(int(10 * random()) * 0.1) + 0.5 j = i + int(int(10 * random()) * 0.15) + 0.5 # 1930 IF WRAGI>Z*J THEN # PRINT AT VAL "13",BIN ;"gOROD PAL,WEDX EGO ZA]I]ALO MALO": # PRINT AT VAL "14",VAL "13";"SOLDAT": # GO SUB KEY: # GO SUB CLS: # LET U=SGN PI: # LET OI=BIN : # GO SUB OITOG: # RETURN if model.enemies > model.defenders * j: device.at(13, 0).print("Город пал, ведь его защищало мало") device.at(14, 13).print("солдат") device.wait_key() device.cls() raise EndGameException(True) else: # 1940 IF Z*J>WRAGI THEN # PRINT AT VAL "13",INT PI;"NO ATAKA OTBITA! uRA-A-A!!!" device.at(13, 1).print("Но атака отбита! Ура-а-а!!!") # 1950 IF FN S(3)=SGN PI THEN # PRINT AT VAL "15",INT PI;"pROIZO[LA RE[A\@]AQ BITWA!!!" if randint(1, 3) == 1: device.at(15, 1).print("Произошла решающая битва!!!") # 1960 LET POGIBZ=INT (WRAGI/3)+INT (RND*Z/6): # LET POGIB=POGIB+POGIBZ: # LET NAS=NAS-POGIB: # LET RASST=25+FN S(20): # LET WRAGI=INT (NAS/4)+INT (RND*NAS/5) pogibz = model.enemies // 3 + int(random() * model.defenders / 6) model.dead_in_battles += pogibz model.population -= model.dead_in_battles model.distance_to_enemies = randint(26, 45) model.enemies = int(model.population / 4) + int( random() * model.population / 5) # 1965 GO TO KEY: # GO SUB CLS device.wait_key() device.cls()
def harvest(device: AbstractIO, model: GameModel): # 1300 REM \#017\#001UBORKA\#017\#000 # 1305 GO SUB CLS device.cls() # 1320 IF OST>INT (ZAS/PROIZ) THEN # RANDOMIZE USR VAL "47383": # PRINT AT VAL "11",VAL "5";"bOLX[OE ^ISLO TUNEQDCEW": # PRINT AT VAL "12",VAL "6";"RAZWRA]AET HLEBOROBOW": # LET PROIZ=PROIZ-SGN PI: # GO SUB KEY: # GO SUB CLS if model.ost > model.zas // model.sower_productivity: device.show_image("parasites") device.at(11, 5).print("Большое число тунеядцев") device.at(12, 6).print("развращает хлеборобов") model.sower_productivity -= 1 device.wait_key() device.cls() # 1330 IF (OST<NAS/VAL "15") AND (PROIZ<PREDEL) THEN # RANDOMIZE USR VAL "43909": # PRINT AT VAL "11",SGN PI;"pOSTOQNNYJ TRUD WYRABATYWAET";AT VAL "12",VAL "10";"SNOROWKU": # LET PROIZ=PROIZ+SGN PI: # GO SUB KEY: # GO SUB CLS if model.ost * 15 < model.population and model.sower_productivity < model.max_sower_productivity: device.show_image("tools") device.at(11, 1).print("Постоянный труд вырабатывает сноровку") model.sower_productivity += 1 device.wait_key() device.cls() # 1340 IF K<VAL "20" THEN # PRINT AT VAL "11",VAL "4";"pLOHOE PITANIE SNIVAET": # PRINT AT VAL "12",VAL "5";" PROIZWODITELXNOSTX!": # LET PROIZ=PROIZ-INT (30/K): # GO SUB KEY: # GO SUB CLS if model.feeding_per_worker < 20: device.at(11, 4).print("Плохое питание снижает") device.at(12, 5).print(" производительность!") model.sower_productivity -= 30 // model.feeding_per_worker device.wait_key() device.cls() # 1350 IF PROIZ<=BIN THEN LET PROIZ=INT PI if model.sower_productivity <= 0: model.sower_productivity = 1 # 1360 IF (K>VAL "30") AND (PROIZ<PREDEL) THEN # PRINT AT VAL "11",SGN PI;"nA HORO[IH HAR^AH I RABOTAETSQ"; # AT VAL "12",VAL "13";"LU^[E": # LET PROIZ=PROIZ+SGN PI: # GO SUB KEY: # GO SUB CLS if model.feeding_per_worker > 30 and model.sower_productivity < model.max_sower_productivity: device.at(11, 1).print("На хороших харчах и работается") device.at(12, 13).print("лучше") model.sower_productivity += 1 device.wait_key() device.cls() # 1370 LET UROV=SGN PI+FN S(VAL "6")-IST: # LET J=FN S(VAL "21") model.grain_yield = randint(2, 7) j = randint(1, 21) # 1380 IF J>=VAL "18" THEN LET UROV=VAL "10" if j >= 18: model.grain_yield = 10 # 1390 IF J<=INT PI THEN LET UROV=SGN PI if j <= 3: model.grain_yield = 1 # 1400 IF UROV<SGN PI THEN LET UROV=SGN PI if model.grain_yield < 1: model.grain_yield = 1 # 1410 IF UROV>VAL "5" THEN # RANDOMIZE USR VAL "58252": # PRINT AT VAL "11",VAL "7";"oTLI^NYJ UROVAJ!!!": # GO SUB KEY: # GO SUB CLS if model.grain_yield > 5: device.show_image("excellent_harvest") device.at(11, 7).print("Отличный урожай!!!") device.wait_key() device.cls() # 1420 LET I=BIN : # IF UROV<VAL "2" THEN # LET I=FN S(INT PI) i = 0 if model.grain_yield < 2: i = randint(1, 3) # 1430 IF I=SGN PI THEN # RANDOMIZE USR VAL "62884": # PRINT AT VAL "11",INT PI;"zASUHA POGUBILA UROVAJ!!!": # GO SUB KEY: # GO SUB CLS if i == 1: device.show_image("bad_harvest") device.at(11, 3).print("Засуха погубила урожай!!!") device.wait_key() device.cls() # 1440 IF I=VAL "2" THEN # RANDOMIZE USR VAL "60568": # PRINT AT VAL "11",BIN ;"pYLEWYE BURI POGUBILI UROVAJ!!!": # GO SUB KEY: # GO SUB CLS if i == 2: device.show_image("dust_storms") device.at(11, 0).print("Пылевые бури погубили урожай!!!") device.wait_key() device.cls() # 1450 IF I=INT PI THEN # RANDOMIZE USR VAL "59410": # PRINT AT VAL "11",BIN ;"lIWNEWYE DOVDI POGUBILI UROVAJ!!": # GO SUB KEY: # GO SUB CLS if i == 3: device.show_image("rains") device.at(11, 0).print("Ливневые дожди погубили урожай!!") device.wait_key() device.cls() # 1460 LET SBOR=ZAS*UROV model.harvest = model.zas * model.grain_yield # 1470 IF RND>0.7 THEN # LET SAR=4+FN S(8): # LET SBOR=SBOR-INT (SBOR/SAR): # RANDOMIZE USR VAL "61726": # PRINT AT VAL "11",SGN PI;"sARAN^A POGUBILA 1/";SAR;" UROVAQ!": # GO SUB KEY: # GO SUB CLS if random() > 0.7: sar = randint(5, 12) model.harvest -= model.harvest // sar device.show_image("locrust") device.at(11, 1).print(f"Саранча погубила 1/{sar} урожая!") device.wait_key() device.cls() # 1480 LET ZERNO=ZERNO+SBOR: # LET J=FN S(5) model.grain += model.harvest j = randint(1, 5) # 1490 IF J=SGN PI THEN # LET KRYS=INT (ZERNO/(FN S(10)+7)): # RANDOMIZE USR VAL "57094": # PRINT AT VAL "11",VAL "4";"nA GOROD NAPALI KRYSY!!!": # LET ZERNO=ZERNO-KRYS: # GO SUB KEY: # GO SUB CLS if j == 1: model.rats = model.grain // randint(7, 17) device.show_image("rats") device.at(11, 4).print("На город напали крысы!!!") model.grain -= model.rats device.wait_key() device.cls()
def feeding(device: AbstractIO, model: GameModel): # 700 REM \#017\#001KORMEVKA\#017\#000 # 710 LET K=-1: IF OST<=NOT PI THEN RETURN if model.ost <= 0: return while True: # 720 PRINT AT VAL "20",SGN PI;"mOVNO DATX ";INT (ZERNO/OST);" BU[ NA ^ELOWEKA": # PRINT AT VAL "21",VAL "6";"sKOLXKO DA[X?" device.at( 20, 1).print(f"Можно дать {model.grain // model.ost} буш на человека") device.at(21, 6).print("Сколько дать?") # 730 GO SUB INPUT: # LET K=VAL F$: # GO SUB PUS: # IF K<BIN THEN : # GO TO VAL "720" try: model.feeding_per_worker = int(sub_input(device, model)) except ValueError: continue # 740 IF K*OST>ZERNO THEN # PRINT AT VAL "20",INT PI;"u NAS NET STOLXKO ZERNA!!!": # GO SUB KEY: # GO SUB PUS: # GO TO VAL "720" if model.feeding_per_worker * model.ost > model.grain: device.print("У нас нет столько зерна!!!") device.wait_key() continue break # 750 LET ZERNO=ZERNO-K*OST model.grain -= model.feeding_per_worker * model.ost # 760 IF K<VAL "20" THEN # LET UMERGOL=OST*INT (SGN PI-K/VAL "20"): # LET UMERWSEGO=UMERWSEGO+UMERGOL: # LET NAS=NAS-UMERGOL if model.feeding_per_worker < 20: model.dead_starvation = model.ost * (1 - model.feeding_per_worker // 20) model.dead_total += model.dead_starvation model.population -= model.dead_starvation # 770 IF NAS<=NOT PI OR K=NOT PI THEN # GO SUB CLS: # RANDOMIZE USR VAL "53620": # PRINT AT VAL "11",INT PI;"\{i2}ty UMORIL WSEH GOLODOM!!!": # GO SUB KEY: # LET OI=BIN : # LET U=SGN PI: # GO SUB OITOG: # RETURN if model.population <= 0 or model.feeding_per_worker == 0: device.cls() device.show_image("graveyard") device.at(11, 3).ink(2).print("Ты уморил всех голодом!!!") device.wait_key() raise EndGameException(False) # 780 IF K<=VAL "10" THEN # PRINT AT VAL "20",VAL "10";"\{i3}du{egub!!!": # GO SUB KEY: # GO SUB PUS: # GO TO VAL "800" if model.feeding_per_worker <= 10: device.at(10, 20).ink(3).print("ДУШЕГУБ!!!") device.wait_key() empty_lines(device) # 790 IF K<=VAL "21" THEN # PRINT AT VAL "20",VAL "10";"\{i5}vadina!!!": # GO SUB KEY: # GO SUB PUS elif model.feeding_per_worker <= 21: device.at(20, 10).ink(5).print("ЖАДИНА!!!") device.wait_key() empty_lines(device) # 800 IF K>VAL "20" THEN # LET UMERGOL=BIN elif model.feeding_per_worker > 20: model.dead_starvation = 0 # 810 IF K>VAL "70" THEN # PRINT AT VAL "20",BIN ;"\{i6}w..WY...wypx..pxem!!!za tebq!!!": # GO SUB KEY: # GO SUB PUS: # GO TO VAL "830" elif model.feeding_per_worker > 70: device.at(20, 0).ink(6).print("В..вы...ВЫПЬ..ПЬЕМ!!!ЗА ТЕБЯ!!!") device.wait_key() empty_lines(device) # 820 IF K>VAL "50" THEN # PRINT AT VAL "20",VAL "5";"\{i4}bLAGODETELX ty NA[!!!": # GO SUB KEY: # GO SUB PUS elif model.feeding_per_worker > 50: device.at(20, 5).ink(4).print("Благодетель ты НАШ!!!") device.wait_key() empty_lines(device)