fixed lack of ability to draw a card, added Decks collapsing into cards
This commit is contained in:
14
src/Deck.lua
14
src/Deck.lua
@@ -78,9 +78,15 @@ function Deck:drawCards(count)
|
|||||||
insert(new, remove(self.cards))
|
insert(new, remove(self.cards))
|
||||||
end
|
end
|
||||||
|
|
||||||
|
self:update()
|
||||||
|
|
||||||
return Deck(new)
|
return Deck(new)
|
||||||
else
|
else
|
||||||
return remove(self.cards)
|
local card = remove(self.cards)
|
||||||
|
|
||||||
|
self:update()
|
||||||
|
|
||||||
|
return card
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -110,4 +116,10 @@ function Deck:getCards()
|
|||||||
return self.cards
|
return self.cards
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function Deck:update()
|
||||||
|
if #self.cards < 2 then
|
||||||
|
self = self.cards[1] --turn into a Card (no idea if this will break anything Oo)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
return Deck
|
return Deck
|
||||||
|
@@ -69,7 +69,7 @@ function love.draw()
|
|||||||
--All cards in a deck are facing the same way automatically.
|
--All cards in a deck are facing the same way automatically.
|
||||||
if not holding then
|
if not holding then
|
||||||
--not holading anything
|
--not holading anything
|
||||||
lg.print("Left click to grab a card or deck. Scroll over a deck to shuffle it. Right click to flip a card or the cards in a deck.", 2, lg.getHeight() - 14)
|
lg.print("Left click to grab a card or draw a card. Scroll down over a deck to shuffle it, scroll up to pick up a deck. Right click to flip a card or the cards in a deck.", 2, lg.getHeight() - 14)
|
||||||
else
|
else
|
||||||
local hovering = false
|
local hovering = false
|
||||||
|
|
||||||
@@ -116,7 +116,10 @@ function love.mousepressed(x, y, button)
|
|||||||
if not holding then
|
if not holding then
|
||||||
for i=#items,1,-1 do
|
for i=#items,1,-1 do
|
||||||
if isOnItem(x, y, items[i]) then
|
if isOnItem(x, y, items[i]) then
|
||||||
|
if items[i]:isInstanceOf(Card) then
|
||||||
holding = table.remove(items, i)
|
holding = table.remove(items, i)
|
||||||
|
else
|
||||||
|
holding = items[i]:drawCards(1)
|
||||||
break
|
break
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -158,12 +161,12 @@ function love.mousepressed(x, y, button)
|
|||||||
holding = false
|
holding = false
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
elseif button == "wu" then --WU AND WD ARE ALMOST IDENTICAL, COLLAPSE THEM INTO ONE WHERE POSSIBLE
|
elseif button == "wu" then --WU AND WD ARE ALMOST IDENTICAL, COLLAPSE THEM INTO ONE WHERE POSSIBLE
|
||||||
if not holding then
|
if not holding then
|
||||||
for i=#items,1,-1 do --ABSTRACT THIS FOR, I DO IT TOO MUCH ?
|
for i=#items,1,-1 do --ABSTRACT THIS FOR, I DO IT TOO MUCH ?
|
||||||
if isOnItem(x, y, items[i]) and items[i]:isInstanceOf(Deck) then
|
if isOnItem(x, y, items[i]) and items[i]:isInstanceOf(Deck) then
|
||||||
items[i]:shuffleCards()
|
--items[i]:shuffleCards() -- now we pick it up instead!
|
||||||
|
holding = table.remove(items, i)
|
||||||
break
|
break
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
Reference in New Issue
Block a user