-
Notifications
You must be signed in to change notification settings - Fork 0
/
items.py
111 lines (93 loc) · 4.24 KB
/
items.py
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
import main
from playerchar import Player
def all_player_items(player_inventory): #wszystkie itemy gracza
for ele in player_inventory:
all_player_items_list.append(ele[0])
return all_player_items_list
def add_item_to_inv(list_of_items): #dodawanie itemu do inventory gracza
index_count = 0
if list_of_items[0] not in all_player_items_list:
player_inventory.append(list_of_items)
else:
for lists in player_inventory:
if lists[0] == list_of_items[0]:
player_inventory[index_count][2] += list_of_items[2]
else:
index_count +=1
def player_pos_to_index(x,y): #zamaina pozycji x,y na indeks
x = str(x)
y = str(y)
player_pos = x+y
return player_pos
def del_worse_item(player_inventory,item_type):
index = 0
for player_items in player_inventory:
if player_items[1] == item_type:
del player_inventory[index]
else:
index +=1
def add_attack_and_health(player_inventory,player):
for item in player_inventory:
if item[1] == 'weapon' :
player[3] += item[5]
item[5] = 0
elif item[1] == 'armour':
player[2] += item[5]
item[5] = 0
def is_item_on_ground(player_pos,player,actual_items): #sprawdzanie czy stoimy na itemie, dodawanie go
#player_pos = player_pos_to_index(x,y)
if player_pos == '510' and actual_items == 'itemy2':
item_type = items_level_2[0][1]
del_worse_item(player_inventory,item_type)
add_item_to_inv(items_level_2[0]) #dryer
elif player_pos == '99' and actual_items == 'itemy4':
item_type = items_level_4[0][1]
del_worse_item(player_inventory,item_type)
add_item_to_inv(items_level_4[0]) #trident
elif player_pos == '123' and actual_items == 'itemy3':
item_type = items_level_3[0][1]
del_worse_item(player_inventory,item_type)
add_item_to_inv(items_level_3[0]) #plastic straw
elif player_pos == '610' and actual_items == 'itemy2':
item_type = items_level_2[1][1]
del_worse_item(player_inventory,item_type)
add_item_to_inv(items_level_2[1]) #wet cardboard
elif player_pos == '77' and actual_items == 'itemy4':
item_type = items_level_4[2][1]
del_worse_item(player_inventory,item_type)
add_item_to_inv(items_level_4[2]) #full diamond set
elif player_pos == '41' and actual_items == 'itemy3':
item_type = items_level_3[2][1]
del_worse_item(player_inventory,item_type)
add_item_to_inv(items_level_3[1]) #lifeb
elif player_pos == '1010' and actual_items == 'itemy1':
item_type = items_level_1[0][1]
player[2] += items_level_1[0][5] #seedweed
elif player_pos == '910' and actual_items == 'itemy3':
item_type = items_level_3[2][1]
player[2] += items_level_3[2][5] #monster energy
elif player_pos == '42' and actual_items == 'itemy4':
item_type = items_level_4[1][1]
player[2] += items_level_4[1][5] #golden apple
else:
pass
def display_inventory(inventory): #printowanie inventory
print(f'INVENTORY__________________________')
for index in range(len(inventory)):
print(f'{inventory[index][0]} - {inventory[index][1]} ({inventory[index][6]})')
#lista itemow bez statystyk #
list_of_keys = [['red key','key',1,'k','xxxx']]
items_level_1 = [['seeweed', 'food',1,'h','1010', 10,]]
items_level_2 = [['dryer','weapon', 1, 'd','510',20,'Rare'],['wet cardboard','armour',1,'c','610',25,'Rare']]
items_level_3 = [['plastic straw', 'weapon',1,'l','123',30,'Exceptional'],['lifebuoy','armour',1,'m','41',15,'Exceptional'],['monster energy', 'food',1,'h','910',20]]
items_level_4 = [['trident', 'weapon', 1,'w','99',40,'Legendary'],['golden apple', 'food',1,'h','41',50],['diamond armour','armour',1,'s','77',50,'Legendary']]
#eggs, czepek koło ratunkowe, mokry karton
player_inventory = [['stick','weapon', 1, 'd','xxxx',1,'Common'],['swimming trunks','armour',1,'m','xxxx',5,'Common']]
all_player_items_list = []
all_player_items(player_inventory)
# display_inventory(player_inventory)
# x=10
# y=20
# player_pos = player_pos_to_index(x,y)
# is_item_on_ground(player_pos)
# display_inventory(player_inventory)