Skip to content

Commit

Permalink
fixed #13 also on server
Browse files Browse the repository at this point in the history
  • Loading branch information
Zomis committed Sep 10, 2014
1 parent dc5a518 commit 2aa85f7
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 5 deletions.
Expand Up @@ -32,6 +32,12 @@ function enchant.isTargetAllowed(card, target, action)
if target.data.creatureType ~= 'Bio' then
return false
end
if target:getOwner() ~= card:getOwner() then
return false
end
if target:getZone() ~= card:getOwner().data.battlefield then
return false
end
return true
end

Expand Down
Expand Up @@ -29,10 +29,15 @@ function enchantspecial.isTargetAllowed(card, target, action)
if target.data.cardType ~= 'Creature' then
return false
end
-- if table.getn(target.data.enchantments) == 0 then
if target.data.enchantments <= 0 then
return false
end
if target:getOwner() ~= card:getOwner() then
return false
end
if target:getZone() ~= card:getOwner().data.battlefield then
return false
end
return true
end

Expand Down
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 2aa85f7

Please sign in to comment.