Skip to content

Commit

Permalink
hehehe
Browse files Browse the repository at this point in the history
  • Loading branch information
inkariyadi committed Nov 18, 2019
1 parent 62a6408 commit ae17a6a
Show file tree
Hide file tree
Showing 4 changed files with 111 additions and 35 deletions.
46 changes: 36 additions & 10 deletions battle.pl
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
:- dynamic(finish_battle/1).
:- dynamic(tangkaptime/1).
:- dynamic(pick_time/1).
:- dynamic(specials/1).

:- include('player.pl').

Expand Down Expand Up @@ -58,6 +59,7 @@


pick(X) :-
asserta(specials(1)),
battle_status(1),
pick_time(1),
inventory(X,B,C,_,_,_,G,LV),
Expand Down Expand Up @@ -120,11 +122,12 @@
!.

attackenemy :-
current_tokemon1(A,B,C,D),current_tokemon2(E,_,_,H),
current_tokemon1(A,B,C,D),current_tokemon2(E,_,LV,H),
tokemon(AA,_,_,_,_,_,E),tokemon(BB,_,_,_,_,_,A),
B2 is B - H,
H2 is H+((LV/8)*H),
B2 is B - H2,
write(AA),write(' used normal attack!'),nl,
write(BB),write(' took '),write(H),write(' damage'), nl,nl,
write(BB),write(' took '),write(H2),write(' damage'), nl,nl,
(B2 =< 0 -> lose;(
retract(current_tokemon1(A,B,C,D)),asserta(current_tokemon1(A,B2,C,D)),!)),!.

Expand All @@ -135,39 +138,53 @@
battle_status(0),
write('Tidak sedang bertempur mas, mbak'),nl,!.

special :-
battle_status(1),
specials(0),
write('Tokemon anda terlalu lelah untuk menggunakan special attack lagi'),nl,
!.

special :-
specials(1),
battle_status(1),
current_tokemon1(A,B,C,_), current_tokemon2(E,F,G,H),
((tokemon(N,_,_,S,P,grass,A),tokemon(NAMAM,_,_,_,_,water,E));(tokemon(N,_,_,S,P,water,A),tokemon(_,_,_,_,_,fire,E));(tokemon(N,_,_,S,P,fire,A),tokemon(_,_,_,_,_,grass,E))),
write(N),write(' used '),write(P),write('!'), nl,
S2 is S*(1+(C/5)),
B2 is B - H, F2 is (F-(S2*1.5)),
write('ITS SUPER EFFECTIVE'),nl,nl,
write(NAMAM),write(' took '),write(S2*1.5),write(' damage'),nl,
S3 is S2*1.5,
write(NAMAM),write(' took '),write(S3),write(' damage'),nl,
((B2 >0, F2 > 0) ->
(retract(current_tokemon2(E,F,G,H)),asserta(current_tokemon2(E,F2,G,H)),attackenemy,tulis_battle) ;(
((B2 > 0 , F2 =< 0) -> win;(
(B2 =< 0, F2 > 0) -> (lose,nl) ;seri)
)))
))),
retract(specials(_)),asserta(specials(0))
,!.

special :-
specials(1),

battle_status(1),
current_tokemon1(A,B,C,_), current_tokemon2(E,F,G,H),
((tokemon(N,_,_,S,P,water,A),tokemon(NAMAM,_,_,_,_,grass,E));(tokemon(N,_,_,S,P,grass,A),tokemon(_,_,_,_,_,fire,E));(tokemon(N,_,_,S,P,fire,A),tokemon(_,_,_,_,_,water,E))),
write(N),write(' used '),write(P),write('!'), nl,
S2 is S*(1+(C/5)),
B2 is B - H, F2 is (F-(S2*0.5)),
S3 is S2*0.5,
write('ITS NOT VERY EFFECTIVE.....'),nl,nl,
write(NAMAM),write(' took '),write(S2*0.5),write(' damage'),nl,
write(NAMAM),write(' took '),write(S3),write(' damage'),nl,
((B2 >0, F2 > 0) ->
(retract(current_tokemon2(E,F,G,H)),asserta(current_tokemon2(E,F2,G,H)),attackenemy,tulis_battle) ;(
((B2 > 0 , F2 =< 0) -> win;(
(B2 =< 0, F2 > 0) -> (lose,nl) ;seri)
)))
))),
retract(specials(_)),asserta(specials(0))
,!.

special :-
special :-
specials(1),
battle_status(1),
current_tokemon1(A,B,C,_), current_tokemon2(E,F,G,H),
tokemon(N,_,_,S,P,_,A),tokemon(NAMAM,_,_,_,_,_,E),
Expand All @@ -181,23 +198,30 @@
asserta(current_tokemon2(E,F2,G,H)),attackenemy,tulis_battle) ;(
((F2 =< 0) -> win;(
(B2 =< 0, F2 > 0) -> (lose,nl) ;seri)
)))
))),
retract(specials(_)),asserta(specials(0))
,!.



lose :- jumlapokemon(1),
lose :- maxInventory(1),
write('you lose'),
retract(gameMain(1)),
asserta(gameMain(0)),
retract(battle_status(1)),
asserta(battle_status(0)),
current_tokemon1(A,B,C,D),
retract(current_tokemon1(A,B,C,D)),
retract(inventory(_,_,_,_,_,_,A,_)),
nl, !.


lose :-
maxInventory(X),
X =\= 1,
X2 is X-1,
specials(X),
retract(specials(X)),
retract(maxInventory(X)),
assert(maxInventory(X2)),
current_tokemon1(A,B,_,O),
Expand All @@ -217,6 +241,8 @@
current_tokemon2(AA,_,_,_),
tokemon(NA,_,_,_,_,_,AA),
tokemon(_,HEA,_,_,_,_,A),
specials(X),
retract(specials(X)),
write(NA),write(' has died'), nl,
LV is L + 1,
retract(current_tokemon1(A,B,L,P)),
Expand Down
57 changes: 40 additions & 17 deletions main.pl
Original file line number Diff line number Diff line change
Expand Up @@ -14,30 +14,53 @@

start :-
nl,
write(' ╔════╗╔═══╗╔╗╔═╗╔═══╗╔═╗╔═╗╔═══╗╔═╗─╔╗'),nl,
write(' ║╔╗╔╗║║╔═╗║║║║╔╝║╔══╝║║╚╝║║║╔═╗║║║╚╗║║'),nl,
write(' ╚╝║║╚╝║║─║║║╚╝╝─║╚══╗║╔╗╔╗║║║─║║║╔╗╚╝║'),nl,
write(' ──║║──║║─║║║╔╗║─║╔══╝║║║║║║║║─║║║║╚╗║║'),nl,
write(' ──║║──║╚═╝║║║║╚╗║╚══╗║║║║║║║╚═╝║║║─║║║'),nl,
write(' ──╚╝──╚═══╝╚╝╚═╝╚═══╝╚╝╚╝╚╝╚═══╝╚╝─╚═╝ '),nl,
help,nl,nl,
legend,nl,nl,
write('Halo! <story>.'),nl,
write('88888 .d88b. 8 dP 8888 8b d8 .d88b. 8b 8 '),nl,
write(' 8 8P Y8 8wdP 8www 8YbmdP8 8P Y8 8Ybm8 '),nl,
write(' 8 8b d8 88Yb 8 8 " 8 8b d8 8 "8 '),nl,
write(' 8 Y88P 8 Yb 8888 8 8 Y88P 8 8 '),nl,nl,nl,
write('Kamu adalah mahasiswa biasa, normal, dan punya sedikit teman, dan berharap memiliki masa depan yang cerah.'),nl,
write('Hari-hari berjalan dengan cukup normal, dan dibumbui dengan sedikit perasaan depresi khas mahasiswa.'),nl,
write('Hingga suatu hari, saat kamu sedang merenung di plaza widya, kamu melihat meteor dengan kecepatan tinggi '),nl,
write('dan menghantam bumi. Tanah bergetar hebat, dan seketika pandanganmu membuyar.'),nl,nl,
write('Saat tersadar, kamu didunia yang tidak sama lagi. Dunia dipenuhi makhluk-makhluk aneh. Berkat bantuan'),nl,
write('Prof. Rila M. yang telah menyelamatkanmu, kamu mengetahui meteor tersebut membawa wabah virus dan mengubah orang-orang'),nl,
write('menjadi makhluk unik bernama Tokemon. Kini Prof. Rila tengah mengembangkan serum untuk mengatasi wabah dan mengembalikan orang-orang.'),nl,
write('Kini tugasmu adalah membantu Prof Rila mengalahkan tokemon spesial yang luar biasa kuat dan mengambil sampel darahnya guna '),nl,
write('pembuatan serum. Kamu dibantu dengan alat hasil penelitian Prof. Rila bisa menjinakkan tokemon-tokemon tersebut'),nl,
write('sekarang bantu Prof. Rila untuk segera mengalahkan tokemon spesial sebelum korban-korban sulit ditolong kembali!'),nl,nl,nl,
help,nl,nl,nl,
legend,nl,nl,nl,
retract(game_status(0)),asserta(game_status(1)),
write('Selamat bermain! Good luck!'),nl,nl,
init_map,
init_player,
asserta(game_status(1)),
init_player, init_map,
!.

quit :-
game_status(0),
write('Belum juga mulai gamenya -_-'),nl,!.

quit :-
game_status(1),retract(game_status(1)),assert(game_status(0)),
(udahheal(_)->retractall(udahheal(_))),assert(udahheal(0)),retract(tangkaptime(_)),assert(tangkaptime(0)),
retract(pick_time(_)),assert(pick_time(0)),
(lebarPeta(_)->retract(lebarPeta(_))),(tinggiPeta(_)->retract(tinggiPeta(_))),(posisiGym(_,_)->retractall(posisiGym(_,_))),(rintangan(_,_)->retractall(rintangan(_,_))),(ctrheal(_)->retractall(ctrheal(_))),
/*(posisiLegendary(_,_,_)->retractall(posisiLegendary(_,_,_))),*/
/*(udah_lari(_) -> retract(udah_lari(_))), (lagi_ketemu(_) -> retract(lagi_ketemu(_))),(battle_status(_) -> retract(battle_status(_))),
(digym(_)->retract(digym(_))),(maucapture(_)->retractall(maucapture(_))),(lagi_pick(_)->retractall(lagi_pick(_))),(finish_battle(_)->retractall(finish_battle(_))),
(current_tokemon1(_,_,_,_)-> retract(current_tokemon1(_,_,_,_))),(current_tokemon2(_,_,_,_) -> retract(current_tokemon2(_,_,_,_))),
(player_status(_)->retract(player_status(_))),*/ (player_position(_,_)->retract(player_position(_,_))),(inventory(_,_,_,_,_,_,_,_)->retractall(inventory(_,_,_,_,_,_,_,_))),(maxInventory(_)->retract(maxInventory(_))),(gameMain(_)->retractall(gameMain(_))),
write('Terima Kasih telah bermain!'),nl,
write('Sampai jumpa lagi!'),nl,!.

help :-
write('Daftar Command : '),nl,
write('1. start : Untuk memulai permainan.'),nl,
write('2. map : Menampilkan peta beserta posisi pemain dan gym saat ini.'),nl,
write('3. heal : Mengobati tokemon yang dimiliki player saat ini(Hanya bisa di Gym Center "G").'),nl,
write('4. w : Bergerak kearah Utara(atas).'),nl,
write('5. s : Bergerak kearah Timur(kanan).'),nl,
write('6. a : Bergerak kearah Barat(kiri).'),nl,
write('7. d : Bergerak kearah Selatan(bawah).'),nl,
write('4. n : Bergerak kearah Utara(atas).'),nl,
write('5. e : Bergerak kearah Timur(kanan).'),nl,
write('6. w : Bergerak kearah Barat(kiri).'),nl,
write('7. s : Bergerak kearah Selatan(bawah).'),nl,
write('8. quit : Keluar dari permainan.'),nl,
write('9. pick(tokemon) : Memilih tokemon yang akan digunakan untuk bertarung(hanya dalam battle).'),nl,
write('10. attack : Melakukan serangan normal ke tokemon musuh(hanya dalam battle).'),nl,
Expand Down Expand Up @@ -139,7 +162,7 @@
write(' Posisi: '),write(XX),write(','),write(YY),nl,
!.


/*loads(_) :-
game_status(mulai),
write('Kamu tidak bisa memulai game lainnya ketika ada game yang sudah dimulai.'), nl, !.
Expand Down
38 changes: 32 additions & 6 deletions map.pl
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@
asserta(lebarPeta(X)),
asserta(tinggiPeta(Y)),
asserta(player_position(1,1)),
generateRintangan,
generateGym,
generateRintangan,
!.

isTopBorder(_,Y) :-
Expand Down Expand Up @@ -65,15 +65,15 @@

setHealthTo0 :-
/* BUAT DEBUGGGGGG DOANGGGGG */
forall(retract(inventory(Tokemon,_,N,S,NS,T,I)),asserta(inventory(Tokemon,0,N,S,NS,T,I))).
forall(retract(inventory(Tokemon,_,N,S,NS,T,I,J)),asserta(inventory(Tokemon,0,N,S,NS,T,I,J))).

setHealthToFull :-
/* Prosedur untuk mengheal semua tokemon */
forall(inventory(Tokemon,Health,N,S,NS,T,I),
forall(inventory(Tokemon,Health,N,S,NS,T,I,J),
forall(tokemon(Tokemon,Health1,_,_,_,_,_),
forall(Y is Health1,
forall(retract(inventory(Tokemon,Health,N,S,NS,T,I)),
asserta(inventory(Tokemon,Y,N,S,NS,T,I)))))).
forall(retract(inventory(Tokemon,Health,N,S,NS,T,I,J)),
asserta(inventory(Tokemon,Y,N,S,NS,T,I,J)))))).

heal :-
/* Pemain belum pernah melakukan heal dan berada di posisi Gym*/
Expand Down Expand Up @@ -170,23 +170,27 @@
write(Y), ! .

n:-
gameMain(1),
(lagi_ketemu(1);battle_status(1)),
write('lagi ada pokemon jgn caw dong'),nl, !.

n :-
gameMain(1),
player_position(_,Y),
Y < 2,
write('nabrak bray'),nl,
!.

n:-
gameMain(1),
player_position(X,Y),
Y2 is Y-1,
X2 is X,
isRintangan(X2,Y2),
write('gabisa cuy ada rintangan'),!.

n :-
gameMain(1),
tangkaptime(J),
retract(tangkaptime(J)),asserta(tangkaptime(0)),
(J =:= 1 -> (write('u have left the pokemon'),nl) ; nl),
Expand All @@ -199,10 +203,12 @@


s :-
gameMain(1),
(lagi_ketemu(1);battle_status(1)),
write('lagi ada pokemon jgn caw dong'),nl, !.

s :-
gameMain(1),
player_position(_,Y),
tinggiPeta(YY),
YYY is YY-1,
Expand All @@ -211,13 +217,15 @@
!.

s :-
gameMain(1),
player_position(X,Y),
Y2 is Y+1,
X2 is X,
isRintangan(X2,Y2),
write('gabisa cuy ada rintangan'),!.

s :-
gameMain(1),
tangkaptime(J),
retract(tangkaptime(J)),asserta(tangkaptime(0)),
(J =:= 1 -> (write('u have left the pokemon'),(current_tokemon2(L,K,O,P),retract(current_tokemon2(L,K,O,P))),nl) ; nl),
Expand All @@ -232,10 +240,12 @@
roll, !.

e:-
gameMain(1),
(lagi_ketemu(1);battle_status(1)),
write('lagi ada pokemon jgn caw dong'),nl, !.

e :-
gameMain(1),
player_position(X,_),
lebarPeta(XX),
XXX is XX-1,
Expand All @@ -244,13 +254,15 @@
!.

e :-
gameMain(1),
player_position(X,Y),
Y2 is Y,
X2 is X+1,
isRintangan(X2,Y2),
write('gabisa cuy ada rintangan'),!.

e :-
gameMain(1),
tangkaptime(J),
retract(tangkaptime(J)),asserta(tangkaptime(0)),
(J =:= 1 -> (write('u have left the pokemon'),(current_tokemon2(L,K,O,P),retract(current_tokemon2(L,K,O,P))),nl) ; nl),
Expand All @@ -265,23 +277,27 @@
roll, !.

w :-
gameMain(1),
(lagi_ketemu(1);battle_status(1)),
write('lagi ada pokemon jgn caw dong'),nl, !.

w :-
gameMain(1),
player_position(X,_),
X < 2,
write('nabrak bray'),nl,
!.

w :-
gameMain(1),
player_position(X,Y),
Y2 is Y,
X2 is X-1,
isRintangan(X2,Y2),
write('gabisa cuy ada rintangan'),!.

w :-
gameMain(1),
tangkaptime(J),
retract(tangkaptime(J)),asserta(tangkaptime(0)),
(J =:= 1 -> (write('u have left the pokemon'),nl) ; nl),
Expand Down Expand Up @@ -309,4 +325,14 @@
random(1,100,C), encounterroll(C),!.

encounterroll(X) :-
X > 20 -> write('You have moved');battle.
X > 15 -> write('moved');
(X < 12) -> battletest(X).


battletest(X) :-
retract(lagi_ketemu(0)),
asserta(lagi_ketemu(1)),
tokemon(A,B,C,D,E,F,X),
write('anda bertemu '), write(A), write(' liar!'),
asserta(current_tokemon2(X,B,1,C)),
write('fight or run?'),nl,!.
5 changes: 3 additions & 2 deletions player.pl
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
:- dynamic(player_status/1).
:- dynamic(player_position/2).
:- dynamic(inventory/8).
:- dynamic(maxInventory/1).
:- dynamic(maxInventory/1).
:- discontiguous(maxInventory/1).
:- dynamic(gameMain/1).

/* inventory(nama, current health, nattack, sattack, namasatack, type, id, lvl) */
Expand Down Expand Up @@ -34,7 +35,7 @@
asserta(lagi_ketemu(0)),
asserta(battle_status(0)),
write('Prof. Rila memberikanmu tokemon! Silahkan cek inventory-mu!'),nl,
generateTokemon,generateTokemon,!.
generateTokemon,!.

addToInventory(Tokemon) :-
maxInventory(X),
Expand Down

0 comments on commit ae17a6a

Please sign in to comment.