Compare commits
3 Commits
af73c6b75f
...
2166ea47cf
Author | SHA1 | Date |
---|---|---|
LeRoyce Pearson | 2166ea47cf | |
LeRoyce Pearson | 3ab5052d0c | |
LeRoyce Pearson | bffbd29614 |
44
rummy.lua
44
rummy.lua
|
@ -40,6 +40,10 @@ function TIC()
|
||||||
|
|
||||||
local points_of_interest = player_state.get_points_of_interest()
|
local points_of_interest = player_state.get_points_of_interest()
|
||||||
|
|
||||||
|
local discard_x=((240 - 24) / 2)
|
||||||
|
local draw_pile_x=discard_x - 24 - 4
|
||||||
|
local end_turn_x=discard_x + 24 + 4
|
||||||
|
|
||||||
if not hovered and #points_of_interest>0 then
|
if not hovered and #points_of_interest>0 then
|
||||||
hovered=points_of_interest[1]
|
hovered=points_of_interest[1]
|
||||||
end
|
end
|
||||||
|
@ -117,28 +121,19 @@ function TIC()
|
||||||
print("New\nMeld", meld_x, 17, 13)
|
print("New\nMeld", meld_x, 17, 13)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- render draw pile
|
-- render discard pile
|
||||||
for i,card in ipairs(draw_pile) do
|
|
||||||
local sel_state = nil
|
|
||||||
if hovered and hovered.interest == card then
|
|
||||||
sel_state = 1
|
|
||||||
end
|
|
||||||
|
|
||||||
card:render(3, 80 + (i - 1) * -0.25, true, sel_state)
|
|
||||||
end
|
|
||||||
|
|
||||||
for i,card in ipairs(discard_pile) do
|
for i,card in ipairs(discard_pile) do
|
||||||
local sel_state = nil
|
local sel_state = nil
|
||||||
if hovered and hovered.interest == card then
|
if hovered and hovered.interest == card then
|
||||||
sel_state = 1
|
sel_state = 1
|
||||||
end
|
end
|
||||||
|
|
||||||
card:render(39, 80 + (i - 1) * -0.25, false, sel_state)
|
card:render(discard_x, 80 + (i - 1) * -0.25, false, sel_state)
|
||||||
end
|
end
|
||||||
if is_an_interest(points_of_interest, "Discard") then
|
if is_an_interest(points_of_interest, "Discard") then
|
||||||
if hovered and hovered.interest=="Discard" then
|
if hovered and hovered.interest=="Discard" then
|
||||||
spr(Card.spr_hilight.sid,
|
spr(Card.spr_hilight.sid,
|
||||||
39,
|
discard_x,
|
||||||
80 + (#discard_pile - 1) * -0.25,
|
80 + (#discard_pile - 1) * -0.25,
|
||||||
Card.spr_hilight.colorkey,
|
Card.spr_hilight.colorkey,
|
||||||
1, 0, 0,
|
1, 0, 0,
|
||||||
|
@ -147,28 +142,31 @@ function TIC()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
if player_state == player_state_draw_card then
|
-- render draw pile
|
||||||
print("Your turn! Draw a card.", 60, 60, 15, false, 1, false)
|
for i,card in ipairs(draw_pile) do
|
||||||
elseif player_state == player_state_action then
|
local sel_state = nil
|
||||||
print("Your turn! Meld, Lay-off, or End Turn", 60, 60, 15, false, 1, false)
|
if hovered and hovered.interest == card then
|
||||||
|
sel_state = 1
|
||||||
|
end
|
||||||
|
|
||||||
|
card:render(draw_pile_x, 80 + (i - 1) * -0.25, true, sel_state)
|
||||||
end
|
end
|
||||||
|
|
||||||
if is_an_interest(points_of_interest, "End\nTurn") then
|
if is_an_interest(points_of_interest, "End\nTurn") then
|
||||||
print("End\nTurn", 110, 87, 0)
|
print("End\nTurn", end_turn_x, 80+7, 0)
|
||||||
if hovered and hovered.interest=="End\nTurn" then
|
if hovered and hovered.interest=="End\nTurn" then
|
||||||
spr(Card.spr_hilight.sid,
|
spr(Card.spr_hilight.sid,
|
||||||
110,
|
end_turn_x, 80,
|
||||||
80,
|
|
||||||
Card.spr_hilight.colorkey,
|
Card.spr_hilight.colorkey,
|
||||||
1, 0, 0,
|
1, 0, 0,
|
||||||
Card.spr_hilight.tw,
|
Card.spr_hilight.tw,
|
||||||
Card.spr_hilight.th)
|
Card.spr_hilight.th)
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
print("End\nTurn", 110, 87, 13)
|
print("End\nTurn", end_turn_x, 80+7, 13)
|
||||||
end
|
end
|
||||||
|
|
||||||
local hand_start_x=((240 - #cards_in_hand * 12) / 2)
|
local hand_start_x=((240 - #cards_in_hand * 12 - 24) / 2)
|
||||||
for i,card in ipairs(cards_in_hand) do
|
for i,card in ipairs(cards_in_hand) do
|
||||||
local ty=0
|
local ty=0
|
||||||
local sel_state = nil
|
local sel_state = nil
|
||||||
|
@ -289,7 +287,7 @@ player_state_action = {
|
||||||
player_state_secondary_action = {
|
player_state_secondary_action = {
|
||||||
update=function(point_of_interest)
|
update=function(point_of_interest)
|
||||||
if cards_in_hand:contains(point_of_interest.interest) then
|
if cards_in_hand:contains(point_of_interest.interest) then
|
||||||
cards_in_meld_draft=CardStack:new(point_of_interest.interest)
|
cards_in_meld_draft=CardStack:new({ point_of_interest.interest })
|
||||||
elseif point_of_interest.interest=="Discard" then
|
elseif point_of_interest.interest=="Discard" then
|
||||||
if #cards_in_meld_draft==1 then
|
if #cards_in_meld_draft==1 then
|
||||||
table.remove(cards_in_hand, cards_in_hand:index_of(cards_in_meld_draft[1]))
|
table.remove(cards_in_hand, cards_in_hand:index_of(cards_in_meld_draft[1]))
|
||||||
|
@ -401,7 +399,7 @@ function rummy_is_valid_meld(stack)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local expected_suit=stack[1].rank
|
local expected_suit=stack[1].suit
|
||||||
local is_valid_run=true
|
local is_valid_run=true
|
||||||
for i=2,#stack do
|
for i=2,#stack do
|
||||||
local card=stack[i]
|
local card=stack[i]
|
||||||
|
|
Loading…
Reference in New Issue