-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfishing.pl
150 lines (128 loc) · 3.67 KB
/
fishing.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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
:- dynamic(fishListGenerator/1).
fishListGenerator([]).
rarity(arwana, 10). % semakin besar semakin tidak langka
rarity(gurame, 15).
rarity(lele, 30).
rarity(nila, 25).
rarity(mujair, 20).
increaseFishingExp(Item, Exp):-
inventory(fishing_rod, _, FishingRodLevel),
playerRole(fish),
fishListGenerator(L),
length(L, Len),
rarity(Item, X),
Rarity is floor((Len-X)*100/Len),
random(30, 41, Mult),
Percentage is (100 + Rarity),
Exp is (Percentage*Mult*FishingRodLevel) div 100, !.
increaseFishingExp(Item, Exp):-
inventory(fishing_rod, _, FishingRodLevel),
fishListGenerator(L),
length(L, Len),
rarity(Item, X),
Rarity is floor((Len-X)*100/Len),
random(20, 31, Mult),
Percentage is (100 + Rarity),
Exp is (Percentage*Mult*FishingRodLevel) div 100, !.
isAroundWater:-
playerLoc(XP, YP),
X1 is XP-1,
tile(X1, YP, water),
!.
isAroundWater:-
playerLoc(XP, YP),
X2 is XP+1,
tile(X2, YP, water),
!.
isAroundWater:-
playerLoc(XP, YP),
Y1 is YP-1,
tile(XP, Y1, water),
!.
isAroundWater:-
playerLoc(XP, YP),
Y2 is YP+1,
tile(XP, Y2, water),
!.
countEmpty(X):-
playerRole(fisherman),
fishListGenerator(L),
length(L, Len),
X is 50*Len div 100, !.
countEmpty(X):-
fishListGenerator(L),
length(L, Len),
X is 80*Len div 100, !.
fishGenerator:-
forall((inventory(Fish, fish, _), rarity(Fish, Rarity), between(1, Rarity, _)), (
fishListGenerator(L),
append(L, [Fish], L_New),
asserta(fishListGenerator(L_New)),
retract(fishListGenerator(L))
)),
countEmpty(X),
forall(between(1, X, _), (
fishListGenerator(L),
append(L, [empty], L_New),
asserta(fishListGenerator(L_New)),
retract(fishListGenerator(L))
)),
!.
fish:-
inventory(fishing_rod, _, 0),
write('\nYou have to buy a fishing rod before you fish, you can buy it at the marketplace\n'), !.
fish:-
playerEnergy(Energy),
Energy < 10,
write('You run out of energy!, go to home to get some sleep immediately!\n'), !.
fish :-
capacity(Capacity),
Capacity >= 100,
write('You don\'t have enough space in your inventory, if you got a fish it will be a waste, throw or sell some of it!\n'), !.
fish :-
isAroundWater,
fishListGenerator(L),
length(L, Len),
random(0,Len,Idx),
nth0(Idx, L, FishFished),
lossEnergy(fish),
gotFishInterface(FishFished), !.
fish :-
write('\nAre you going to catch a worm or something? you can only FISH near the pond\n'), !.
gotFishInterface(empty):-
write('oh no, unfortunately you didn\'t get anything, try again will you?'), !.
gotFishInterface(FishFished):-
addProgress(FishFished, 1),
retract(inventory(FishFished, fish, Previous)),
New is Previous + 1,
asserta(inventory(FishFished, fish, New)),
write('Amazing! you got a(n) '),
write(FishFished),
write('!'), nl,
increaseFishingExp(FishFished, Exp),
gainExp(fish, Exp),
TotalExp is (Exp*120) div 100,
gainExp(total, TotalExp),
write('You gained '),
write(TotalExp),
write(' Exp and '),
write(Exp),
write(' Fishing Exp. \n Amazing!\n'),
!.
gotFishInterface(FishFished):-
retract(inventory(FishFished, fish, Previous)),
New is Previous + 1,
asserta(inventory(FishFished, fish, New)),
write('Amazing! you got a(n) '),
write(FishFished),
write('!'), nl,
increaseFishingExp(FishFished, Exp),
gainExp(fish, Exp),
TotalExp is (Exp*120) div 100,
gainExp(total, TotalExp),
write('You gained '),
write(TotalExp),
write(' Exp and '),
write(Exp),
write(' Fishing Exp. \n Amazing!\n'),
!.