Created
November 27, 2015 23:12
-
-
Save drage0/1c3cd984b4eeba0009ff to your computer and use it in GitHub Desktop.
ZZZZZZZZZZZZZZ
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
program game0; | |
{ VARIABLE,s } | |
const | |
buffer_size = 8; | |
type | |
c_string = Array [1..buffer_size] of char; | |
var | |
p0_name :c_string; | |
p0_type :char; {'w' warrior, 'r' ranger, 'm' mage} | |
p0_hp :byte; { Nece biti vise od ((2^8)-1), zar ne? } | |
p0_atr_str :byte; | |
p0_atr_agl :byte; | |
p0_atr_int :byte; | |
temp_confirm :char; | |
{ Pocetne vrednosti, za svaki slucaj! } | |
procedure reset; | |
begin | |
p0_name := 'Tuskarr'; | |
p0_name := ' '; | |
p0_type := 'w'; | |
p0_hp := 255; | |
p0_atr_str := 0; | |
p0_atr_agl := 0; | |
p0_atr_int := 0; | |
temp_confirm := 'n'; | |
end; | |
{ Da li je znak jednak nekim drugim znakom, sluzi zbog velikog/malog slova } | |
function chrcmp(c0,c1:char): boolean; | |
begin | |
if( (c0 = c1) or (ord(c0) = ord(c1)-32) ) then exit(true); | |
exit(false); | |
end; | |
{ Pise string(niz znakova), preskace razmak. } | |
procedure write_trimstring(name: c_string ) ; | |
var | |
index: byte; | |
begin | |
index := 0; | |
while (index < buffer_size) do begin | |
if ( not(name[index] = ' ') ) then begin | |
write(name[index]); | |
end; | |
index := index + 1; | |
end; | |
end; | |
{ Pise ime klase u zavisnosti sta je igrac odabrao } | |
procedure write_classname(ttype: char); | |
begin | |
if (ttype = 'w') then write('warrior') | |
else if (ttype = 'r') then write('ranger') | |
else write('mage'); | |
end; | |
{ Prolog } | |
procedure intro; | |
var | |
bonus_atr: byte; | |
bonus_chr: char; | |
begin | |
writeln('Welcome to this amazing game.'); | |
writeln(); | |
temp_confirm := ' '; | |
while ( not (temp_confirm = 'y') ) do begin | |
writeln('Who are you, and what''s your name?'); | |
write('>>> My name is '); | |
readln(p0_name); | |
write('>>> And I am a ([W]arrior, [R]anger, [M]age): '); | |
readln(p0_type); | |
write('So, you are'); | |
write_trimstring(p0_name); | |
write(', a '); | |
write_classname(p0_type); | |
write('. Correct? [Y/N]: '); | |
readln(temp_confirm); | |
end; | |
{ POCETNI ATRIBUTI } | |
bonus_atr := 4; | |
bonus_chr := 's'; | |
if(p0_type = 'w') then begin | |
p0_atr_str := 5; | |
p0_atr_agl := 2; | |
p0_atr_int := 2; | |
end | |
else if(p0_type = 'r') then begin | |
p0_atr_str := 3; | |
p0_atr_agl := 4; | |
p0_atr_int := 3; | |
end | |
else begin | |
p0_atr_str := 2; | |
p0_atr_agl := 3; | |
p0_atr_int := 6; | |
end; | |
readln(); | |
writeln('STARTING ATTRIBUTES: '); | |
writeln('STR: ', p0_atr_str); | |
writeln('AGL: ', p0_atr_agl); | |
writeln('INT: ', p0_atr_int); | |
writeln('Bonus points: ', bonus_atr); | |
readln(); | |
while (bonus_atr > 0) do begin | |
write('Add a point to an atribute [S]trength, [A]gility, [I]nteligence, ', bonus_atr, 'remain: '); | |
readln(bonus_chr); | |
if(chrcmp(bonus_chr, 's')) then begin p0_atr_str := p0_atr_str + 1; bonus_atr := bonus_atr - 1; end | |
else if(chrcmp(bonus_chr, 'a')) then begin p0_atr_agl := p0_atr_agl + 1; bonus_atr := bonus_atr - 1; end | |
else if(chrcmp(bonus_chr, 'i')) then begin p0_atr_int := p0_atr_int + 1; bonus_atr := bonus_atr - 1; end; | |
end; | |
writeln('RESULTING ATTRIBUTES: '); | |
writeln('STR: ', p0_atr_str); | |
writeln('AGL: ', p0_atr_agl); | |
writeln('INT: ', p0_atr_int); | |
writeln('Bonus points: ', bonus_atr); | |
writeln(); | |
end; | |
{ MAIN HERE } | |
begin | |
randomize; | |
reset(); | |
intro(); | |
readLn(); | |
end. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment