Skip to content

Commit

Permalink
Playtest bug fix + cardsDB overhaul
Browse files Browse the repository at this point in the history
Fixed multiple bugs that were discovered after the first playtest and
overhauled the way the cards database is update with a complete
integration of the GitHub API.
  • Loading branch information
_FR_Starfox64 committed Sep 18, 2015
1 parent e5e41d2 commit 89b699c
Show file tree
Hide file tree
Showing 7 changed files with 325 additions and 84 deletions.
File renamed without changes.
3 changes: 3 additions & 0 deletions lua/autorun/sh_cah_init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,12 @@ if (SERVER) then
AddCSLuaFile("external/von.lua")
AddCSLuaFile("external/netstream.lua")
AddCSLuaFile("external/htmlentities.lua")
AddCSLuaFile("external/base64.lua")

include("external/von.lua")
include("external/netstream.lua")
include("external/htmlentities.lua")
include("external/base64.lua")

include("cah/sv_hooks.lua")
include("cah/sh_cah.lua")
Expand All @@ -25,6 +27,7 @@ else
include("external/von.lua")
include("external/netstream.lua")
include("external/htmlentities.lua")
include("external/base64.lua")

include("cah/sh_cah.lua")
include("cah/cl_cah.lua")
Expand Down
36 changes: 34 additions & 2 deletions lua/cah/cl_cah.lua
Original file line number Diff line number Diff line change
Expand Up @@ -140,8 +140,14 @@ hook.Add("PostDrawOpaqueRenderables", "CAH_PostDrawOpaqueRenderables", function(

-- Black Card --
if (cahGame:GetBlackCard() and cursor.r == 180) then
local flipped = cahGame:GetStatus() < CAH_DISCOVER
local mainX, mainY = TABLE_WIDTH - 1164 - CARD_WIDTH, TABLE_HEIGHT - 350 - CARD_HEIGHT
local flipped = cahGame:GetStatus() == CAH_DISCOVER
CAH:DrawCard(cahGame:GetBlackCard(), 1164, 350, flipped)
CAH:AddClickPos(mainX, mainY, CARD_WIDTH, CARD_HEIGHT, IN_ATTACK2, "preview", {cardID = cahGame:GetBlackCard(), flipped = flipped})

if (ply == cahGame:GetCzar() and cahGame:GetStatus() == CAH_DISCOVER) then
CAH:AddClickPos(mainX, mainY, CARD_WIDTH, CARD_HEIGHT, IN_ATTACK, "discover")
end
end
cam.End3D2D()

Expand Down Expand Up @@ -185,9 +191,13 @@ hook.Add("PostDrawOpaqueRenderables", "CAH_PostDrawOpaqueRenderables", function(

-- Black Card --
if (cahGame:GetBlackCard() and cursor.r == 0) then
local flipped = cahGame:GetStatus() < CAH_DISCOVER
local flipped = cahGame:GetStatus() == CAH_DISCOVER
CAH:DrawCard(cahGame:GetBlackCard(), 1164, 350, flipped)
CAH:AddClickPos(1164, 350, CARD_WIDTH, CARD_HEIGHT, IN_ATTACK2, "preview", {cardID = cahGame:GetBlackCard(), flipped = flipped})

if (ply == cahGame:GetCzar() and cahGame:GetStatus() == CAH_DISCOVER) then
CAH:AddClickPos(1164, 350, CARD_WIDTH, CARD_HEIGHT, IN_ATTACK, "discover")
end
end

-- Cursor --
Expand Down Expand Up @@ -346,6 +356,8 @@ function CAH:CheckClickPos( cursor )
if (cursor.x >= clickPos.x and cursor.y >= clickPos.y and cursor.x <= clickPos.x + clickPos.w and cursor.y <= clickPos.y + clickPos.h) then
if (clickPos.action == "draw") then
netstream.Start("CAH_DrawCard", clickPos.arg)
elseif (clickPos.action == "discover") then
netstream.Start("CAH_DiscoverCard")
elseif (clickPos.action == "choose") then
netstream.Start("CAH_ChooseCard", clickPos.arg)
elseif (clickPos.action == "quit") then
Expand Down Expand Up @@ -458,4 +470,24 @@ end)

netstream.Hook("CAH_Notification", function( data )
CAH:Notify(data.m, data.i, data.ns)
end)

netstream.Hook("CAH_LoadCards", function( sha )
if (file.Exists("cah/"..(sha == "default" and CAH.CurrentRelease or sha)..".txt", "DATA")) then
if (sha == "default") then
CAH:LoadCards(true)
else
CAH:LoadCards(false, sha)
end
else
sha = sha == "default" and CAH.CurrentRelease or sha

CAH:DownloadCards(sha, function( sha, success )
if (sha == CAH.CurrentRelease) then
CAH:LoadCards(true)
else
CAH:LoadCards(false, sha)
end
end)
end
end)
Loading

0 comments on commit 89b699c

Please sign in to comment.