Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local Player = {
- Character = "unknown",
- Label = "unknown",
- Sprite = {
- Default = {
- delay = 1,
- list = {"Player/Sprite/character.png"}
- },
- OnAttack = {
- delay = 1,
- list = {}
- },
- OnSkill = {
- delay = 1,
- list = {}
- }
- },
- Effect = {
- Strength = 0,
- Healing = 0,
- Dex = 0,
- },
- Shield = 0,
- Deck = DefaultCardList,
- HandCard = {},
- DiscardsPile = {},
- DrawPile = DefaultCardList,
- DrawHandCard = true,
- RemoveCard = {},
- Relic = {},
- MaxCardOnHand = 10,
- Hp = 50,
- HpMax = 50,
- Gold = 0,
- Mana = 3,
- MaxMana =3,
- x = 25,
- y = 450
- }
- function Player:TakeDamage(count)
- if self.Shield > count then
- self.Shield = self.Shield - count
- else
- count = count - self.Shield
- self.Shield = 0
- self.Hp = self.Hp - count
- if self.Hp < 0 then
- self.Hp = 0
- end
- end
- end
- function Player:MixedDrawPile()
- local newDrawPile = {}
- local tempCurrentDraw = self.DrawPile
- for i = 1 , #self.DrawPile do
- local random = math.random(1,#tempCurrentDraw)
- table.insert(newDrawPile,tempCurrentDraw[random])
- table.remove(tempCurrentDraw,random)
- end
- self.DrawPile = newDrawPile
- end
- function Player:ApplyEffect(pStrength,pHealing,pDex,pShield)
- self.Effect.Strength = Effect.Strength + pStrength
- self.Effect.Healing = Effect.Healing + pHealing
- self.Effect.Dex = Effect.Dex + pDex
- self.Effect.Shield = Effect.Shield + pShield
- end
- function Player:MixedCard()
- local newPile = {}
- local discard = self.DiscardsPile
- local pile = self.DrawPile
- for i = 1 , #self.DiscardsPile do
- local random = math.random(1,#discard)
- table.insert(pile,discard[random])
- table.remove(discard,random)
- end
- self.DrawPile = pile
- end
- function Player:IsAlive()
- if self.Hp <= 0 then
- return false
- else
- return true
- end
- end
- function Player:Discard(index)
- if index ~= -1 then
- table.insert(self.DiscardsPile,self.HandCard[index])
- self.HandCard[index].OnDiscard()
- table.remove(self.HandCard,index)
- else
- for k,v in pairs(self.HandCard) do
- table.insert(self.DiscardsPile,v)
- end
- self.HandCard = {}
- end
- end
- function Player:Exhaust(index)
- if index ~= -1 then
- table.insert(self.RemoveCard,self.HandCard[index])
- table.remove(self.HandCard,index)
- else
- for k,v in pairs(self.HandCard) do
- table.insert(self.RemoveCard,v)
- end
- self.HandCard = {}
- end
- end
- function Player:DrawCard(count)
- for i = 1 ,tonumber(count) do
- if #self.DrawPile < 1 then
- self:MixedCard()
- end
- if #self.HandCard < self.MaxCardOnHand then
- table.insert(self.HandCard,self.DrawPile[#self.DrawPile])
- table.remove(self.DrawPile,#self.DrawPile)
- self.HandCard[#self.HandCard].OnDraw(Player)
- end
- end
- end
- function Player:Draw()
- if self.HandCard ~= nil then
- if self.DrawHandCard then
- for i = 1,#self.HandCard do
- self.HandCard[i].x = 250 + (220*i)
- if love.mouse.getX() > self.HandCard[i].x and love.mouse.getX() < self.HandCard[i].x +200 and love.mouse.getY() > self.HandCard[i].y and love.mouse.isDown(1) then
- self.HandCard[i].y = love.mouse.getY() -100
- if self.HandCard[i].y > 600 then
- self.HandCard[i].y = 600
- end
- end
- love.graphics.rectangle("fill", self.HandCard[i].x, self.HandCard[i].y, 200, 250)
- love.graphics.setColor(0,0,0,1)
- love.graphics.printf(self.HandCard[i].costMana,self.HandCard[i].x, self.HandCard[i].y, 200,"left",0,1.25,1.25,1)
- love.graphics.printf(self.HandCard[i].info,self.HandCard[i].x, self.HandCard[i].y+160, 200,"center")
- love.graphics.setColor(1,1,1,1)
- end
- end
- end
- love.graphics.printf("Mana : ".. self.Mana.." / "..self.MaxMana,25,640,100,"left")
- love.graphics.printf("Hp : "..self.Hp.." / "..self.HpMax,25,660,100,"left")
- love.graphics.printf("Shield : "..self.Shield,25,680,100,"left")
- love.graphics.printf("Strength : "..self.Effect.Strength,25,700,100,"left")
- love.graphics.printf("Dex : "..self.Effect.Dex,25,720,100,"left")
- love.graphics.draw(love.graphics.newImage(self.Sprite.Default.list[1]),self.x,self.y,0,1,1,0,0)
- end
- return Player
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement