home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Loadstar 44
/
044.d81
/
castrovia
(
.txt
)
< prev
next >
Wrap
Commodore BASIC
|
2022-08-26
|
7KB
|
247 lines
10 p=1:dl=1500:ss=54272:c$(0)="":c$(1)="[159]":c$(2)="[158]"
15 a$(0)="f":a$(1)="s":a$(2)="l":a$(3)="c"
17 a$(4)="x":poke53280,0:poke53281,0
20 gosub60100
25 gosub900:print""
26 print" [154]press space [154]to play; q [154]to quit "
27 a=peek(203):ifa<>60anda<>62then27
28 ifa=62thengosub60000:goto26
30 print"[145] [145]":poke198,.
35 print"[154]enter player one's name:";:gosub60500:n1$=b$:poke198,.
40 print"[145][154]enter player two's name: [157][157][157][157][157][157]";:gosub60500:n2$=b$
45 dim m (9,9),p(9,9),t(9,9),c(9,9),r(2)
50 print"[145] setting up map ":s=1
55 fory=1to9:forx=1to9
60 n=int(40*rnd(1)+1)
65 m(x,y)=0
70 ifn<8thenm(x,y)=1
75 ifn<4thenm(x,y)=2
80 p(x,y)=0
85 ifm(x,y)=0thenp(x,y)=int(9*rnd(1)+1)
90 t(x,y)=0:c(9,9)=0
95 nextx,y
100 m(5,5)=4
105 p(5,5)=int(5*rnd(1)+5)
110 print"[147]":gosub430
115 gosub490:print"[154]is this map allright with both":print"players (y[154]/n[154])?"
120 geta$:ifa$="y"thens=0:goto135
125 ifa$="n"thenprint"[145][145]";:fora=1to2:print" ":next:goto50
130 goto120
135 gosub490:print"placing castles":forx=1to500:nextx
140 x1=int(9*rnd(1)+1):y1=int(9*rnd(1)+1)
145 y1=int(9*rnd(1)+1)
150 ifm(x1,y1)<>0then140
155 m(x1,y1)=3:c(x1,y1)=1:t(x1,y1)=9
160 x2=int(9*rnd(1)+1):y2=int(9*rnd(1)+1)
165 ifm(x2,y2)<>0then160
170 m(x2,y2)=3:c(x2,y2)=2:t(x2,y2)=9
175 gosub490:print"[159]";n1$"'s castle is at "chr$(x1+64);y1
180 print"[158]";n2$"'s castle is at "chr$(x2+64);y2
185 x(1)=x1:x(2)=x2:y(1)=y1:y(2)=y2:n$(1)=n1$:n$(2)=n2$
190 gosub430:p=2:n$=n2$:c$="[158]"
195 x=int(4*rnd(1)+1):ifx=4then210
200 ifp=2thenp=1:n$=n1$:c$="[159]":goto210
205 ifp=1thenp=2:n$=n2$:c$="[158]"
210 gosub490:print"[154]it's "c$n$"'s [154]move: --> from ";
215 la=65:ha=73:gosub840
220 fx=asc(a$)-64
225 la=49:ha=75:gosub840
230 fy=val(a$)
235 print:print" [154]to ";
240 la=65:ha=73:gosub840
245 tx=asc(a$)-64
250 la=49:ha=57:gosub840
255 ty=val(a$)
260 ifc(fx,fy)=pthen275
265 gosub490:print"[150]you have no troops there! - try again":forx=1todl:nextx
270 goto210
275 ifabs(fx-tx)<=1andabs(fy-ty)<=1then290
280 gosub490:print"[150]you can only move into an adjacent quadrant";
285 print" -- try again":forx=1todl:nextx:goto210
290 ifm(tx,ty)<>2then305
295 gosub490:print"[150]you can't move into a lake -- try again"
300 forx=1todl:nextx:goto210
305 gosub490:print"[154]how many troops to move? --> ";
310 la=48:ha=57:gosub840
315 mn=val(a$)
320 ifmn=0thenprint" ok":goto415
325 ift(fx,fy)=>mnthen340
330 gosub490:print"not enough troops! -- try again":forx=1todl:nextx
335 goto290
340 if not(c(tx,ty)=pandt(tx,ty)+mn>9)then355
345 gosub490:print"this would result in more than nine troops in a";
350 print" quadrant - try again":forx=1todl:nextx:goto290
355 print" ok":t(fx,fy)=t(fx,fy)-mn
360 ift(fx,fy)=0thenc(fx,fy)=0
365 ifc(tx,ty)=0orc(tx,ty)=pthent(tx,ty)=t(tx,ty)+mn:c(tx,ty)=p:goto415
370 gosub490:print"a battle!!":gosub900
375 ds=t(tx,ty)+(.5*p(tx,ty))
380 ifm(tx,ty)=3orm(tx,ty)=4thends=ds*2
385 dv=int(ds*rnd(1))
390 av=int(mn*rnd(1))
395 ifav=dvthent(tx,ty)=0:c(tx,ty)=0:goto415
400 ifdv>avthent(tx,ty)=t(tx,ty)-av
405 ifav>dvthent(tx,ty)=mn-dv:c(tx,ty)=p
410 ift(tx,ty)<1thent(tx,ty)=1
415 gosub430:gosub490
420 tu=tu+1:iftu>(int(7*rnd(1)+3))thentu=0:gosub505
425 goto195
430 print" a b c d e f g h i"
435 print" [154][176][195][195][195][195][195][195][195][195][195][195][195][195][195][195][195][195][195][195][195][195][195][195][195][195][195][195][195][195][195][195][195][195][195][195][195][195][174]"
440 r(1)=0:r(2)=0:fory=1to9
445 ify<>1thenprint" [154][194] [194]"
450 print""chr$(y+48)"[154][194][155]";
455 forx=1to9
460 printc$(c(x,y));p(x,y);"[157]";a$(m(x,y));chr$(t(x,y)+48)"[155]";
465 r(c(x,y))=r(c(x,y))+t(x,y):nextx
470 print"[154][194]":nexty
475 print" [173][195][195][195][195][195][195][195][195][195][195][195][195][195][195][195][195][195][195][195][195][195][195][195][195][195][195][195][195][195][195][195][195][195][195][195][195][189]"
480 if(r(1)=0orr(2)=0)ands=0then855
485 return
490 print"";
495 forx=1864to2023:pokex,32:nextx
500 return
505 gosub490:print"year end tax reports":ta(1)=0:ta(2)=0
510 fory=1to9:forx=1to9
515 ifc(x,y)=1thenta(1)=ta(1)+100*p(x,y)
520 ifc(x,y)=2thenta(2)=ta(2)+100*p(x,y)
525 nextx,y
530 forpp=1to2:printc$(pp)
535 ifc(x(pp),y(pp))=ppthen560
540 gosub490:print"attention "n$(pp):forx=1todl:nextx
545 gosub490:print"you can't collect taxes or buy troops if ";
550 print"you're not in control of your castle":forx=1todl:nextx
555 goto770
560 gosub490:printn$(pp)" collected"ta(pp)"barbles"
562 print"in taxes this year"
565 forx=1todl:nextx:gosub490
570 i(pp)=int(.1*ba(pp))
575 print"and earned"i(pp)"barbles in interest"
580 forx=1todl:nextx
585 ba(pp)=ba(pp)+i(pp)+ta(pp)
590 gosub490:printn$(pp)"'s new balance is"ba(pp)"barbles"
592 forx=1todl:nextx
595 gosub490
600 print"how many castle troops do you"
603 print"want to buy (2000 barbles each)";
605 la=48:ha=57:gosub840
610 a=val(a$):ifa*2000<=ba(pp)then625
615 gosub490:print"you don't have enough money!":forx=1todl:nextx
620 goto595
625 ifa=0then660
630 ift(x(pp),y(pp))+a<10then650
635 gosub490:print"you can't have more than nine troops in a quadrant!";
640 print" - try again":forx=1todl:nextx
645 goto595
650 t(x(pp),y(pp))=t(x(pp),y(pp))+a:ba(pp)=ba(pp)-(2000*a)
655 gosub490:printc$(pp)"your new balance is"ba(pp)"barbles"
658 forx=1todl:nextx
660 gosub490
665 print"how many regular troops"
667 print"do you wish to buy (1000 barbles each)";
670 la=48:ha=57:gosub840
675 a=val(a$):ifa*1000<=ba(pp)then690
680 gosub490:print"you don't have enough money!":forx=1todl:nextx
685 goto660
690 ifa=0then770
695 gosub490:print"where do you want to put them ";
700 la=65:ha=73:gosub840
705 xx=asc(a$)-64
710 la=49:ha=57:gosub840
715 y=val(a$)
720 ifc(xx,y)=ppthen735
725 gosub490:print"you can not put troops where you do not have any!"
730 forx=1todl:nextx:goto695
735 ift(xx,y)+a<=9then755
740 gosub490
742 print"you can not have more than nine troops in any quadrant"
745 forx=1todl:nextx
750 goto660
754 ifxx=x(pp)andy=y(pp)thengosub490
755 ifxx=x(pp)andy=y(pp)thengosub490:gosub1000
760 ifxx=x(pp)andy=y(pp)thenprint"your castle":forx=1todl:nextx:goto660
765 t(xx,y)=t(xx,y)+a:ba(pp)=ba(pp)-1000*a:gosub490
770 nextpp
775 z=int(20*rnd(1)+1):print"[152]";
780 ifz=1thengosub490:print"all treasuries mysteriously double"
785 ifz=1thenba(1)=ba(1)*2:ba(2)=ba(2)*2
790 ifz=2thengosub490:print"all treasuries mysteriously disappear"
795 ifz=2thenba(1)=0:ba(2)=0
800 ifz=3thengosub490:print"revolution in capitol"
805 ifz=3thenprint"all troops killed":t(5,5)=0:c(5,5)=0
810 ifz<>4then830
814 gosub490
815 print"[154]castle troop's disease kills half of all castle troops"
820 t(x1,y1)=int(t(x1,y1)/2):ift(x1,y1)=0thenc(x1,y1)=0
825 t(x2,y2)=int(t(x2,y2)/2):ift(x2,y2)=0thenc(x2,y2)=0
830 ifz>4thengosub490:print"[154]no news is good news"
835 gosub430:return
840 geta$:ifa$=""then840
842 ifa$="q"thengosub60600:goto840
845 ifasc(a$)<laorasc(a$)>hathengoto840
850 printa$;:return
855 print"[147]":ifr(1)=0thenw=2:w$=n2$:l$=n1$:goto865
860 w=1:w$=n1$:l$=n2$
865 print""w$" [154]has beaten "l$
870 print"[154]final statistics"
875 print"[159][183][183][183][183][183][183][183][183][183][183][183][183][183][183][183][183]":print""
880 print" ",n1$,n2$
885 print"[154]troops",r(1),r(2)
890 print"[154]barbles",ba(1),ba(2)
895 print"[154] press space [154]to continue"
896 ifpeek(203)<>60then896
897 run
900 rem sound
905 forxx=1to5:poke ss+24,15
910 poke ss+5,9
915 poke ss+1,20
920 poke ss+4,128
925 for dd=1 to 10: next dd
930 poke ss+4,129
935 fordd=1to(50*int(10*rnd(1)+1)):nextdd,xx
940 forxx=sstoss+24:pokexx,o:nextxx
945 poke ss+24,7
950 poke ss+5,12*16+0
955 poke ss+6,15*16+10
960 for xx= 255 to 100step -1.4
965 poke ss+1,xx
970 poke ss+4,17
975 next xx
980 poke ss+24,15
985 poke ss+1,15
990 poke ss+4,128
995 forxx=1to900:nextxx:forxx=sstoss+24:pokexx,0:nextxx:return
1000 print"you can't put regular troops in ":return
60000 print"[145] [154]are you sure you