浏览代码

You wanna duel;

bjorn 8 年之前
父节点
当前提交
ad6469eccd
共有 2 个文件被更改,包括 5 次插入6 次删除
  1. 3 4
      client.lua
  2. 2 2
      server.lua

+ 3 - 4
client.lua

@@ -329,8 +329,7 @@ function client:draw()
 						end
 						lovr.graphics.push()
 						lovr.graphics.translate(x, y, z)
-						lovr.graphics.rotate(-math.pi / 2, 1, 0, 0)
-						lovr.graphics.rotate(angle, 0, 1, 0)
+						lovr.graphics.rotate(-math.pi / 4, 1, 0, 0)
 						self:drawCard(player, i, 0, 0, 0, .5)
 						lovr.graphics.pop()
 					elseif (player.id == self.id and self.cardGrab.active and self.cardGrab.card == i) or (player.grabbedCard == i) then
@@ -440,7 +439,7 @@ function client:drawCard(player, cardIndex, ...)
 	local card = player.cards[cardIndex]
 	if card.position <= 0 then return end
 
-	if player.id == self.id or cardIndex == player.grabbedCard or (self.dueling == player.id and self.duelChoice > 0 and player.duelChoice > 0) then
+	if player.id == self.id or (cardIndex == player.grabbedCard and self.dueling ~= player.id) or (self.dueling == player.id and self.duelChoice > 0 and player.duelChoice > 0) then
 		lovr.graphics.setColor(255, 255, 255)
 	else
 		lovr.graphics.setColor(0, 0, 0)
@@ -759,7 +758,7 @@ function client.messages.server.outcome(self, data)
 		p2.cards = data.secondCards
 	end
 
-	if p1.id == self.id or p2.id == self.id then
+	if (p1 and p1.id == self.id) or (p2 and p2.id == self.id) then
 		self.dueling = 0
 		self.duelChoice = 0
 		self.duelTimer = 0

+ 2 - 2
server.lua

@@ -97,7 +97,7 @@ function server:update(dt)
 						end
 
 						-- Tell everyone about the changes
-						self:broadcast('outcome', { first = i, second = p1.dueling, firstCards = p1.cards, secondCards = p2.cards, firstStars = p1.stars, secondStars = p2.stars })
+						self:broadcast('outcome', { first = i, second = p2.id, firstCards = p1.cards, secondCards = p2.cards, firstStars = p1.stars, secondStars = p2.stars })
 					end
 				end
 
@@ -117,7 +117,7 @@ function server:update(dt)
 							p1.stars = p1.stars - 1
 						end
 
-						self:broadcast('outcome', { first = i, second = p1.dueling, firstCards = p1.cards, secondCards = p2.cards, firstStars = p1.stars, secondStars = p2.stars })
+						self:broadcast('outcome', { first = i, second = p2.id, firstCards = p1.cards, secondCards = p2.cards, firstStars = p1.stars, secondStars = p2.stars })
 					end
 				end
 			end