Skip to content

Commit

Permalink
Player now lose life on each failed draw card. Fixes #13
Browse files Browse the repository at this point in the history
  • Loading branch information
Zomis committed Sep 10, 2014
1 parent 4bae902 commit 1a13186
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions cardshifter-core/src/main/resources/com/cardshifter/core/start.lua
Expand Up @@ -114,9 +114,6 @@ end

function onTurnStart(player, event)
print("(This is Lua) Turn Start! " .. player:toString())
if player.data.deck:isEmpty() then
print("(This is Lua) Deck is empty!")
end

local field = player.data.battlefield
local iterator = field:getCards():iterator()
Expand All @@ -129,12 +126,22 @@ function onTurnStart(player, event)
card.data.attacksAvailable = 1
end

drawCard(player)
if not drawCard(player) then
player.data.life = player.data.life - 1
if player.data.life <= 0 then
player:getGame():gameOver()
end
print("(This is Lua) Deck is empty! One damage taken.")
end
player.data.manaMax = player.data.manaMax + 1
player.data.mana = player.data.manaMax
end

function drawCard(player)
if player.data.deck:isEmpty() then
return false
end
local card = player.data.deck:getTopCard()
card:moveToBottomOf(player.data.hand)
return true
end

0 comments on commit 1a13186

Please sign in to comment.