RPG attributes generator: Difference between revisions

correction to Pascal version
(correction to Pascal version)
Line 495:
 
=={{header|Pascal|FreePascal}}==
 
{{incorrect|lang|Rolls are generated incorrectly. An attribute should be the total of the 3 highest rolls out of 4, each a value from 1 to 6.}}
<lang Pascal>
program attributes;
Line 509:
total:=0;
for score :=1 to 6 do begin
{roll:=random(18)+1; produce a number up to 18, pretty much the same results}
repeat
for diceroll:=1 to 4 rolldo dice[diceroll]:=random(186)+1; {roll produce4 asix number up tosided 18die}
until roll>4; {if all dice rolled 1 we allow re-roll else 3 here}
{find lowest rolled dice. If we roll two or more equal low rolls then we
atribs[score]:=roll;
eliminate the first of them, change '<' to '<=' to eliminate last low die}
total := total + roll;
if (roll>15) then countlowroll:=count+17;
endlowdie:=0;
for diceroll:=1 to 4 do if (dice[diceroll] < lowroll) then begin
until ((total>74) and (count>1));
lowroll := dice[diceroll];
lowdie := diceroll;
end;
{add up higest three dice}
roll:=0;
for diceroll:=1 to 4 do if (diceroll <> lowdie) then roll := roll + dice[diceroll];
atribs[score]:=roll;
total := total + roll;
if (roll>15) then count:=count+1;
repeatend;
until ((total>74) and (count>1)); {this evens out different rolling methods }
{ Prettily print the attributes out }
writeln('Attributes :');
Anonymous user