RPG attributes generator: Difference between revisions

Content added Content deleted
m (→‎{{header|R}}: Syntax highlighting.)
(→‎{{header|Commodore BASIC}}: Standardize line numbering; switch to 0-basis for arrays to avoid wasting entries; use chr$ for cursor movement; change DS to DT so it works on C-128 where DS is a reserved word..)
Line 1,212: Line 1,212:
Except for screen control codes, this is generic enough it could be used for many other 8-bit interpreted BASICs as well. (Applesoft, ZX Spectrum, etc.). Should work on all Commodore models. (Adjustment for screen width may be necessary on VIC-20.)
Except for screen control codes, this is generic enough it could be used for many other 8-bit interpreted BASICs as well. (Applesoft, ZX Spectrum, etc.). Should work on all Commodore models. (Adjustment for screen width may be necessary on VIC-20.)


<lang gwbasic>
<lang gwbasic>100 rem rpg character roller
110 rem rosetta code - commodore basic
10 rem rpg character roller
120 dim di(3):rem dice
20 rem rosetta code - commodore basic
100 dim di(4):rem dice
130 dim at(5),at$(5):rem attributes as follows:
140 at$(0)="Strength"
105 dim at(6),at$(6):rem attributes as follows:
110 at$(1)="Strength"
150 at$(1)="Dexterity"
115 at$(2)="Dexterity"
160 at$(2)="Constitution"
120 at$(3)="Constitution"
170 at$(3)="Intelligence"
125 at$(4)="Intelligence"
180 at$(4)="Wisdom"
130 at$(5)="Wisdom"
190 at$(5)="Charisma"
200 pt=0:sa=0:rem points total and number of strong attributes (15+)
135 at$(6)="Charisma"
210 print chr$(147);chr$(14);chr$(29);chr$(17);"Rolling..."
140 pt=0:sa=0:rem points total and number of strong attributes (15+)
220 for ai=0 to 5:rem attribute index
145 print chr$(147);chr$(14);"{right}{down}Rolling..."
150 for ai=1 to 6:rem attribute index
230 for i=0 to 3:di(i)=int(rnd(.)*6)+1:next i
240 gosub 450
155 for i=1 to 4:di(i)=int(rnd(1)*6)+1:next i
250 dt=0:rem dice total
160 gosub 2000
260 for i=0 to 2:dt=dt+di(i):next i:rem take top 3
165 ds=0:rem dice sum
270 at(ai)=dt:pt=pt+dt
170 for i=1 to 3:ds=ds+di(i):next i:rem take top 3
280 if dt>=15 then sa=sa+1
175 at(ai)=ds:pt=pt+ds
290 next ai
180 if ds>=15 then sa=sa+1
300 if pt<75 or sa<2 then goto 200
185 next ai
310 print chr$(147);"Character Attributes:"
190 if pt<75 or sa<2 then goto 140
320 print
195 print chr$(147);"Character Attributes:"
330 for ai=0 to 5
200 print
340 print spc(13-len(at$(ai)));at$(ai);":";tab(14);at(ai)
205 for ai=1 to 6
350 next ai
210 print spc(13-len(at$(ai)));at$(ai);":";tab(14);at(ai)
360 print
215 next ai
370 print " Total:";tab(14);pt
220 print
380 print
225 print " Total:";tab(14);pt
230 print
390 print "Do you accept? ";
400 get k$:if k$<>"y" and k$<>"n" then 400
235 print "Do you accept? ";
410 print k$
240 get k$:if k$<>"y" and k$<>"n" then 240
420 if k$="n" then goto 200
245 print k$
430 print:print "Excellent. Good luck on your adventure!"
250 if k$="n" then goto 140
440 end
255 print:print "Excellent. Good luck on your adventure!"
450 rem sort dice
260 end
460 for x=0 to 2:for y=x+1 to 3

470 if di(x)<di(y) then di(0)=di(x):di(x)=di(y):di(y)=di(0)
2000 rem sort dice
480 next y,x
2005 for x=1 to 3:for y=x+1 to 4
490 return</lang>
2010 if di(x)<di(y) then di(0)=di(x):di(x)=di(y):di(y)=di(0)
2015 next y,x
2020 return
</lang>


{{out}}
{{out}}