-
Notifications
You must be signed in to change notification settings - Fork 1
/
player.pl
61 lines (52 loc) · 1.43 KB
/
player.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
:- dynamic(player_status/1).
:- dynamic(player_position/2).
% :- dynamic(player_inv1/3).
% :- dynamic(player_inv2/3).
% :- dynamic(player_inv3/3).
% :- dynamic(player_inv4/3).
% :- dynamic(player_inv5/3).
% :- dynamic(player_inv6/3).
:- dynamic(inventory/7). /* inventory(nama,max health, nattack,sattack,namasatack,type,id) */
:- dynamic(maxInventory/1). /* maxInventory(Maks) */
:- include('tokemon.pl').
:- include('utility.pl').
init_player :-
asserta(gameMain(1)),
% lebarPeta(L),
% tinggiPeta(T),
% random(1,L,X),
% random(1,T,Y),
% asserta(player(X,Y)),
% asserta(healthpoint(100)),
% asserta(armor(0)),
% asserta(senjata(sniper_rifle,40,3)),
asserta(maxInventory(6)),
generateTokemon
%
.
cekPanjangInv(Panjang) :-
findall(B,inventory(B,_,_,_,_,_,_),ListBanyak),
length(ListBanyak,Panjang).
addToInventory(_) :-
cekPanjangInv(Panjang),
maxInventory(Maks),
(Panjang+1) > Maks,
write("Inventory full!"),
nl,
!,
fail.
addToInventory(Tokemon) :-
/*Inventory muat*/
tokemon(Tokemon,H,N,S,NS,T,I),
asserta(inventory(Tokemon,H,N,S,NS,T,I)),!.
delFromInventory(Tokemon) :-
\+inventory(Tokemon,_,_,_,_,_,_),!,fail.
delFromInventory(Tokemon) :-
inventory(Tokemon,_,_,_,_,_,_),
retract(inventory(Tokemon,_,_,_,_,_,_)),
!.
generateTokemon:-
random(1,12,X),
tokemon(Tokemon,_,_,_,_,_,X),
addToInventory(Tokemon),
!.