-
Notifications
You must be signed in to change notification settings - Fork 1
/
Player.lua
223 lines (174 loc) · 4.83 KB
/
Player.lua
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
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
--[[
Structure made for game player.
]]
local Player = {}
Player.__index = Player
function Player:new(Px, Py, currentSprite)
local player = {
props = {
Px = Px,
Py = Py,
Sprite = {
spriteUp = love.graphics.newImage("assets/player/player_up.png"),
spriteDown = love.graphics.newImage("assets/player/player_down.png") ,
spriteRight = love.graphics.newImage("assets/player/player_right.png"),
spriteLeft = love.graphics.newImage("assets/player/player_left.png")
},
currentSprite = currentSprite
},
status = {
damage = 1,
defese = 1,
dexterity = 1,
accuracy = 2,
maxLife = 100,
critical = 1,
life = 100,
exp = 0,
level = 0
},
invetory = {
potion = 3
},
equip = {
sword = nil,
armor = nil,
}
}
setmetatable(player, Player)
return player
end
function Player:setXP(value)
self.status["exp"] = self.status["exp"] + value
if self.status["exp"] >= 100 then
self.status["exp"] = 0
self.status["level"] = self.status["level"] + 1
self.status["damage"] = self.status["damage"] + 2
self.status["defese"] = self.status["defese"] + 2
self.status["dexterity"] = self.status["dexterity"] + 2
self.status["accuracy"] = self.status["accuracy"] + 2
self.status["maxLife"] = self.status["maxLife"] + 10
self.status["life"] = self.status["maxLife"]
return true
end
return false
end
function Player:getXP()
return self.status["exp"]
end
function Player:setEquipSword(item)
self.equip["sword"] = item
end
function Player:setEquipArmor(item)
self.equip["armor"] = item
end
function Player:getDefeseArmor()
if self.equip["armor"] == nil then return 0 end
return self.equip["armor"].defese
end
function Player:getDexterityArmor()
if self.equip["armor"] == nil then return 0 end
return self.equip["armor"].dexterity
end
function Player:getCriticalSword()
if self.equip["sword"] == nil then return 0 end
return self.equip["sword"].critical
end
function Player:getAccuracySword()
if self.equip["sword"] == nil then return 0 end
return self.equip["sword"].accuracy
end
function Player:getDamageSword()
if self.equip["sword"] == nil then return 0 end
return self.equip["sword"].damage
end
function Player:getEquipSwordName()
if self.equip["sword"] == nil then return "Not Equiped" end
return self.equip["sword"].name
end
function Player:getEquipArmorName()
if self.equip["armor"] == nil then return "Not Equiped" end
return self.equip["armor"].name
end
function Player:getEquipArmorSprite()
if self.equip["armor"] == nil then return nil end
return self.equip["armor"].sprite
end
function Player:getEquipSwordSprite()
if self.equip["sword"] == nil then return nil end
return self.equip["sword"].sprite
end
function Player:setInventoryPotion(potion)
if not(self.invetory["potion"] + potion > 6 or self.invetory["potion"] + potion < 0) then
self.invetory["potion"] = self.invetory["potion"] + potion
end
end
function Player:getInventoryPotion()
return self.invetory["potion"]
end
function Player:getPx()
return self.props["Px"]
end
function Player:getPy()
return self.props["Py"]
end
function Player:setPy(px)
self.props["Px"] = px;
end
function Player:setPx(py)
self.props["Py"] = py;
end
-- Get's and Set's Sprite
function Player:getSprite()
return self.props.Sprite[self.props.currentSprite]
end
function Player:setSprite(sprite)
self.props["currentSprite"] = sprite
end
--- Get's and Set's Status
function Player:getDamage()
return self.status["damage"]
end
function Player:setDamage(value)
self.status["damage"] = value
end
function Player:getDefese()
return self.status["defese"]
end
function Player:setDefese(value)
self.status["defese"] = value
end
function Player:getDexterity()
return self.status["dexterity"]
end
function Player:setDexterity(value)
self.status["dexterity"] = value
end
function Player:getAccuracy()
return self.status["accuracy"]
end
function Player:setAccuracy(value)
self.status["accuracy"] = value
end
function Player:getCritical()
return self.status["critical"]
end
function Player:setCritical(value)
self.status["critical"] = value
end
function Player:getLife()
return self.status["life"]
end
function Player:setLife(value)
self.status["life"] = value
end
function Player:getMaxLife()
return self.status["maxLife"]
end
function Player:getLevel()
return self.status["level"]
end
function Player:setLevel(value)
self.status["level"] = value
end
return Player