Code:
% Author: Jeremy Gibers
% Date: 4/29/2004
return(exit).
player_stat(name, 'stranger').
player_stat(race, human).
player_stat(class, fighter).
player_stat(health, 100).
player_stat(mana, 66).
player_stat(direction, north).
mob_stat(name, pion).
mob_stat(race, orc).
mob_stat(class, fighter).
mob_stat(health, 100).
mob_stat(mana, 50).
dropitem_stat(type, food). %food, water, elixer, weapon, or armor
dropitem_stat(name, meat). %will be randomly generated
dropitem_stat(bleh).
bonus(health, human, fighter, 1.3).
bonus(health, human, mage, 0.89).
bonus(mana, human, fighter, 0.6).
bonus(mana, human, mage, 1.4).
bonus(health, orc, fighter, 2.2).
bonus(health, orc, mage, 1.9).
bonus(mana, orc, fighter, 0.4).
bonus(mana, orc, mage, 1.0).
bonus(health, elf, fighter, 1.0).
bonus(health, elf, mage, 1.0).
bonus(mana, elf, fighter, 1.2).
bonus(mana, elf, mage, 2.0).
race(human).
race(orc).
race(elf).
class(fighter).
class(mage).
direction(north).
direction(east).
direction(south).
direction(west).
description(north) :-
write('A great distance ahead of you lie enormous mountains casting'),nl,
write('luminous shadows upon the landscape that lay before it.'), nl.
description(east) :-
write('Medows of long grass lay waving in ominous rythems. They'), nl,
write('seem an endless ocean that melts into the horizon.'), nl.
description(south) :-
write('A putrid smell is radiating from a gruesome swamp that'), nl,
write('while is miles away seems ever present in your proximity.'), nl.
description(west) :-
write('In the great distance they stands erect a ledge of wood'),nl,
write('drenched in clounds of foilage. The forrest seems alive with life.'), nl.
nameparts(weapon, 0, sword).
nameparts(weapon, 0, knife).
nameparts(weapon, 0, polearm).
nameparts(weapon, 0, blade).
nameparts(weapon, 0, knuckles).
nameparts(weapon, 0, staff).
nameparts(weapon, 0, bow).
nameparts(name, 1, ana).
nameparts(name, 2, ord).
nameparts(name, 3, wyn).
nameparts(name, 4, tor).
nameparts(name, 5, dur).
nameparts(name, 6, oth).
nameparts(name, 7, ulth).
nameparts(name, 8, iel).
nameparts(name, 9, va).
%1 to 2 offer best results.
genname(Number, Name) :- Number >= 0, Rand is random(8) + 1, nameparts(name, Rand, Part),
string_concat(Name, Part, Whole), N is Number - 1,
genname(N, Whole);
write(Name), nl.
genname(0, Name) :- nl, write(Name), nl.
rollcharacter :- write('In the world of Aden, identy is everything. Your name may echo'), nl,
write('honorably in the halls of mighty castles. Or perhaps be whispered'), nl,
write('in discust through the streets of the commoners. Your destiny'), nl,
write('is yours to make.'), nl,
write('What name will your reputation be established with?'), nl,
write('(enter your name, no spaces, lowercase): '), nl, getname, nl,
write('Now you must select what race you take form of in this new'), nl,
write('mysterious world of Aden. Each race has pros and cons that'), nl,
write('you must consider with great earnest. They will ultimately'), nl,
write('dertermine your success in this life. Make your choice now.'),nl,
write('What race will you be? (human, orc, elf)'), nl,
getrace, nl,
write('Ah, a good choice. Now you will choose your craft. How will'), nl,
write('you wrack the land in havoc and chaos, or justly protect the'),nl,
write('the inocent. Perhaps you baffle the commons with mysticism, and'),nl,
write('supernatural phenomena. Or they will envy you for your great'), nl,
write('strength and skill, cleaving away at enemys with your great broadsword.'),nl,
write('What will it be young one? The life of a Mage, or the life of a Fighter?'),nl,
write('What class will you be? (mage, fighter)'), nl,
getclass, nl,
write('Congratulations! You have begun your journey. With good judgement, and'),nl,
write('perhaps a bit of luck, you can make it a long and prosperous one.'),nl,nl,
write('Suddenly everything is black, and void. You feel as if you are floating'),nl,
write('in the true definition of nothingness. Just before the moment of despair'),nl,
write('a single point of light appears in the distance just out of reach.'),nl,
write('Quickly the light begins to envelope you, and the blinding whiteness'),nl,
write('of it fades into shades of green, and blue, and soft browns. The image'),nl,
write('becomes more clear, and you realize you are lying in a soft patch of grass'),nl,
write('in a vast meadow. As you gain your senses you slowly realize you are in'),nl,
write('Aden. After several moments gazing at your suroundings in amazement you'),nl,
write('begin to take a personal inventory. You are unarmed, have minimal food'),nl,
write('supplies, and are covered in feable leather clothing. Already you begin'),nl,
write('to question the decisions youve made. But no matter, you must continue.'),nl,nl.
getname :- read(Name),
retract(player_stat(name, _)),
assert(player_stat(name, Name)).
getrace :- read(Race), race(Race), retract(player_stat(race, _)), assert(player_stat(race, Race));
write('Sorry, that isnt available. Try again:'), nl, getrace.
getclass :- read(Class), class(Class), retract(player_stat(class, _)), assert(player_stat(class, Class));
write('Sorry, that isnt available. try again:'), nl, getclass.
mainloop :- player_stat(direction, Dir), description(Dir), getcommand, mainloop;
write('Thanks for playing').
go :- rollcharacter, mainloop.
getcommand :- write('You can go: north, south, east, west'), nl,nl, write('Action?'),nl, read(Command), docommand(Command).
docommand(Dir) :- direction(Dir), retract(player_stat(direction, _)), assert(player_stat(direction, Dir));
not(return(Dir)), write('Invalid command, if you need help type h'), nl, getcommand;
1 < 0. %return false
And heres a once through using all the features that are implimented.