works still, bout to fuck it up

This commit is contained in:
Paul Liverman
2015-12-05 23:20:29 -08:00
parent 1dc98d80d3
commit 1446b2bf95
3 changed files with 51 additions and 40 deletions

View File

@@ -35,23 +35,9 @@ function Card:draw(face, x, y, r)
if self.rank == "Joker" then if self.rank == "Joker" then
lg.print("Joker", cornerOffset - Card.static.width/2, cornerOffset - Card.static.height/2) lg.print("Joker", cornerOffset - Card.static.width/2, cornerOffset - Card.static.height/2)
-- I wanted this to be a symbol for a suit, but the Joker doesn't have one! -- I wanted this to be a symbol for a suit, but the Joker doesn't have one!
lg.print("#") --used to be "J" lg.print("#")
else else
lg.print(self.rank .. " of " .. self.suit, cornerOffset - Card.static.width/2, cornerOffset - height/2) lg.print(self.rank .. " of " .. self.suit, cornerOffset - Card.static.width/2, cornerOffset - Card.static.height/2)
-- I wanted these to be symbols for suits, but for some reason I made them ranks
--[[
if self.rank == "Ace" then
lg.print("A")
elseif self.rank == "Jack" then
lg.print("J")
elseif self.rank == "Queen" then
lg.print("Q")
elseif self.rank == "King" then
lg.print("K")
else
lg.print(self.rank)
end
--]]
if self.suit == "Clubs" then if self.suit == "Clubs" then
lg.print("") lg.print("")
elseif self.suit == "Diamonds" then elseif self.suit == "Diamonds" then

View File

@@ -64,8 +64,11 @@ function Deck:shuffleCards()
end end
function Deck:shuffleIn(card) --TODO make capable of handling multiple cards function Deck:shuffleIn(card) --TODO make capable of handling multiple cards
-- --insert(self.cards, random(1, #self.cards)) --no, we shuffle everything!
insert(self.cards, card)
self:shuffleCards()
end end
--TODO ? placeIn() to randomly place within without shuffling whole deck?
function Deck:drawCards(count) function Deck:drawCards(count)
if count and (count > 1) then if count and (count > 1) then
@@ -103,4 +106,8 @@ function Deck:placeCardsUnder(cards)
end end
end end
function Deck:getCards()
return self.cards
end
return Deck return Deck

View File

@@ -99,7 +99,7 @@ function love.draw()
else else
if hovering == "Card" then if hovering == "Card" then
--deck over card --deck over card
lg.print("Left click to place deck (will not shuffle card underneath into the deck). Right click to flip cards in the deck.", 2, lg.getHeight() - 14) lg.print("Left click to place deck (will place card underneath on the bottom of the deck). Right click to flip cards in the deck.", 2, lg.getHeight() - 14)
elseif hovering == "Deck" then elseif hovering == "Deck" then
--deck over deck --deck over deck
lg.print("Left click to place deck (will not interact with deck underneath). Scroll up to add this deck on top, scroll down to add this deck on bottom. Right click to flip cards in this deck.", 2, lg.getHeight() - 14) lg.print("Left click to place deck (will not interact with deck underneath). Scroll up to add this deck on top, scroll down to add this deck on bottom. Right click to flip cards in this deck.", 2, lg.getHeight() - 14)
@@ -112,15 +112,6 @@ function love.draw()
end end
function love.mousepressed(x, y, button) function love.mousepressed(x, y, button)
--[[ ORIGINAL TEXT, NOT ACCURATE
Left click will grab a card or deck.
While holding a card: Left click will place it (as long as the mouse is not over a deck).
While holding a card over a deck: Scroll up to place it on top of the deck, scroll down to place it on the bottom of the deck. Right click to shuffle it into the deck.
While holding a deck: Left click will place it (as long as the mouse is not over a deck).
While holding a deck over a deck: Scroll up to place it on top of the deck, scroll down to place it on the bottom of the deck. Right click to shuffle the decks together.
While NOT holding anything: Right click a card to flip it, or right click a deck to flip the cards in it (does not flip order of cards). Scroll over a deck to shuffle it.
All cards in a deck are facing the same way automatically.
--]]
if button == "l" then if button == "l" then
if not holding then if not holding then
for i=#items,1,-1 do for i=#items,1,-1 do
@@ -152,18 +143,11 @@ function love.mousepressed(x, y, button)
insert(items, deck) insert(items, deck)
holding = false holding = false
elseif items[item]:isInstanceOf(Deck) then elseif items[item]:isInstanceOf(Deck) then
--TODO shuffle it into the deck items[item]:shuffleIn(holding)
holding = false
end end
end end
--[[
--card on deck
"Scroll up to place card on top of deck, scroll down to place card on bottom of deck."
--deck over deck
"Scroll up to add this deck on top, scroll down to add this deck on bottom."
--deck over nothing
"Scroll to shuffle the deck."
]]
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 ?
@@ -173,9 +157,24 @@ function love.mousepressed(x, y, button)
end end
end end
elseif holding:isInstanceOf(Card) then elseif holding:isInstanceOf(Card) then
--TODO easy for i=#items,1,-1 do
if isOnItem(x, y, items[i]) and items[i]:isInstanceOf(Deck) then
items[i]:placeCardsOn(holding)
holding = false
break
end
end
elseif holding:isInstanceOf(Deck) then elseif holding:isInstanceOf(Deck) then
--TODO maybe harder for i=#items,1,-1 do
if isOnItem(x, y, items[i]) and items[i]:isInstanceOf(Deck) then
items[i]:placeCardsOn(holding:getCards())
holding = false
break
end
end
if holding then --if we didn't just get rid of it...
holding:shuffleCards()
end
end end
elseif button == "wd" then elseif button == "wd" then
if not holding then if not holding then
@@ -186,9 +185,24 @@ function love.mousepressed(x, y, button)
end end
end end
elseif holding:isInstanceOf(Card) then elseif holding:isInstanceOf(Card) then
--TODO easy for i=#items,1,-1 do
if isOnItem(x, y, items[i]) and items[i]:isInstanceOf(Deck) then
items[i]:placeCardsUnder(holding)
holding = false
break
end
end
elseif holding:isInstanceOf(Deck) then elseif holding:isInstanceOf(Deck) then
--TODO maybe harder for i=#items,1,-1 do
if isOnItem(x, y, items[i]) and items[i]:isInstanceOf(Deck) then
items[i]:placeCardsUnder(holding:getCards())
holding = false
break
end
end
if holding then --if we didn't just get rid of it...
holding:shuffleCards()
end
end end
elseif button == "r" then elseif button == "r" then
if holding then if holding then
@@ -208,6 +222,10 @@ function love.keypressed(key)
if key == "escape" then if key == "escape" then
love.event.quit() love.event.quit()
end end
if key == "m" then
insert(items, makeDeck(true))
end
end end
-- ♣ ♦ ♥ ♠ A 2 3 4 5 6 7 8 9 10 J Q K Joker -- ♣ ♦ ♥ ♠ A 2 3 4 5 6 7 8 9 10 J Q K Joker