-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.pl
84 lines (74 loc) · 2.5 KB
/
main.pl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
/* File : start.pl */
/* File for starting and initializing the game. */
:- dynamic(game_start/1).
game_start(false).
start :-
["./utils/list.pl"],
["./math/power.pl"],
["./math/calculation.pl"],
["./entity/message.pl"],
["./entity/enemy.pl"],
["./entity/character.pl"],
["./entity/item.pl"],
["./entity/inventory.pl"],
["./entity/art.pl"],
["./entity/story.pl"],
["./interaction/battle/battle.pl"],
["./interaction/battle/cmd.pl"],
["./interaction/map.pl"],
["./interaction/move.pl"],
["./interaction/interaction.pl"],
["./interaction/store.pl"],
["./interaction/quest.pl"],
/*mana_sempat(A,B,C,D),
keburu_telat(E,F,G),
writeln(A),writeln(B),writeln(C),writeln(D),writeln(),writeln(E),writeln(F),writeln(G),writeln(),*/
retract(game_start(false)), !,
asserta(game_start(true)),
asserta(in_battle(false)),
story_intro,
show_help,
pick_job, asserta(inventory([], 0)), asserta(gold(0)), asserta(is_in_quest(false)),
generate_structure, map_player(P), asserta(current_quest("dummy", [])),
asserta(map_object(20,1, P)).
start :-
write('Use \'help.\' to look at available commands!').
help :-
write('You have been helped.'), nl,
show_help.
/* Cek message.pl */
game_over :-
write('Game over!'), nl,
retract(game_start(true)),
asserta(game_start(false)),
retractall(map_object(_,_,_)),
retractall(inventory(_,_)),
retractall(gold(_)),
retractall(char_level(_)), retractall(char_exp(_)), retractall(char_job(_)),
retractall(char_maxhp(_)), retractall(char_hp(_)), retractall(char_maxexp(_)),
retractall(char_attack(_)), retractall(char_defense(_)),
retractall(char_weapon(_)), retractall(char_armor(_)), retractall(char_accessories(_)),
retractall(is_in_quest(_)), retractall(current_quest(_,_)),
retractall(in_battle(_)),
ask_play_again.
ask_play_again :-
write('Do you want to play again ?'), nl,
write('1. Yes'), nl,
write('2. No'), nl,
read(X), ((X =:= 2) -> write('See ya later!'),nl ; ((X=:=1) -> start ; write('Invalid input!') , nl, ask_play_again)), !.
quit :-
game_start(true),
write('Progress will not be saved after you quit.'),nl,
write('Are you sure? (y/n): '),
read(Param),
(Param = y -> halt;
(Param = n -> fail)).
save :-
write("Saving game data to data.dat...\n"),
nl,
open("data.dat",write,S),
set_output(S),
listing,
close(S),
write("Game Data have been successfully saved."),
nl.