diff --git a/battle.pl b/battle.pl index 3788818..5548dbb 100644 --- a/battle.pl +++ b/battle.pl @@ -8,6 +8,7 @@ :- dynamic(finish_battle/1). :- dynamic(tangkaptime/1). :- dynamic(pick_time/1). +:- dynamic(specials/1). :- include('player.pl'). @@ -58,6 +59,7 @@ pick(X) :- + asserta(specials(1)), battle_status(1), pick_time(1), inventory(X,B,C,_,_,_,G,LV), @@ -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)),!)),!. @@ -135,7 +138,14 @@ 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))), @@ -143,31 +153,38 @@ 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), @@ -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), @@ -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)), diff --git a/main.pl b/main.pl index 494573b..fd85baa 100644 --- a/main.pl +++ b/main.pl @@ -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! .'),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, @@ -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, !. diff --git a/map.pl b/map.pl index 3228fb2..91da822 100644 --- a/map.pl +++ b/map.pl @@ -21,8 +21,8 @@ asserta(lebarPeta(X)), asserta(tinggiPeta(Y)), asserta(player_position(1,1)), - generateRintangan, generateGym, + generateRintangan, !. isTopBorder(_,Y) :- @@ -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*/ @@ -170,16 +170,19 @@ 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, @@ -187,6 +190,7 @@ 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), @@ -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, @@ -211,6 +217,7 @@ !. s :- + gameMain(1), player_position(X,Y), Y2 is Y+1, X2 is X, @@ -218,6 +225,7 @@ 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), @@ -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, @@ -244,6 +254,7 @@ !. e :- + gameMain(1), player_position(X,Y), Y2 is Y, X2 is X+1, @@ -251,6 +262,7 @@ 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), @@ -265,16 +277,19 @@ 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, @@ -282,6 +297,7 @@ 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), @@ -309,4 +325,14 @@ random(1,100,C), encounterroll(C),!. encounterroll(X) :- - X > 20 -> write('You have moved');battle. \ No newline at end of file + 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,!. \ No newline at end of file diff --git a/player.pl b/player.pl index 6a7f969..6db8fb4 100644 --- a/player.pl +++ b/player.pl @@ -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) */ @@ -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),