Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
shdwp committed Jun 22, 2020
1 parent aba434b commit 8956df4
Show file tree
Hide file tree
Showing 7 changed files with 40 additions and 11 deletions.
5 changes: 4 additions & 1 deletion app/scripts/Side.lua
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,10 @@ end
--- @return boolean
function Side:spendCredits(amount)
if self.credits >= amount then
self:alterCredits(-amount)
if amount > 0 then
self:alterCredits(-amount)
end

return true
else
return false
Expand Down
19 changes: 14 additions & 5 deletions app/scripts/cardspec/packs/core.lua
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,13 @@ Db.cards[1005] = {
--- @param ctx Ctx
onNewTurn = function (ctx)
game.runner.recurring.credits_for_virus_or_icebreakers = game.runner.recurring.credits_for_virus_or_icebreakers + 1
end,

--- @param ctx Ctx
onInstall = function (ctx)
game.runner.recurring.credits_for_virus_or_icebreakers = game.runner.recurring.credits_for_virus_or_icebreakers + 1
end

}
Db.card_titles["Cyberfeeder"] = 1005

Expand Down Expand Up @@ -118,8 +124,9 @@ Db.cards[1026] = {

--- @param ctx Ctx
onPlay = function (ctx)
make_interaction:promptSlotSelect(SIDE_RUNNER, isSlotIce, 1, function (card, slot)
make_interaction:promptSlotSelect(SIDE_RUNNER, isSlotIce, 1, function (decision, card, slot)
ctx.meta.selected_ice = card.uid
return true
end)
end,

Expand Down Expand Up @@ -217,8 +224,9 @@ Db.cards[1035] = {

--- @param ctx Ctx
onPlay = function(ctx)
make_interaction:promptSlotSelect(SIDE_RUNNER, SLOT_RUNNER_HAND, 1, function (card, slot)
make_interaction:promptSlotSelect(SIDE_RUNNER, SLOT_RUNNER_HAND, 1, function (decision, card, slot)
make_interaction:promptDiscountedInstall(SIDE_RUNNER, SLOT_RUNNER_HARDWARE, card, -3)
return true
end)
end
}
Expand Down Expand Up @@ -269,8 +277,9 @@ Db.cards[1037] = {

--- @param ctx Ctx
onPlay = function (ctx)
make_interaction:promptSlotSelect(SIDE_RUNNER, isSlotIce, 1, function (card, slot)
make_interaction:promptSlotSelect(SIDE_RUNNER, isSlotIce, 1, function (decision, card, slot)
card.meta.until_turn_end.additional_keywords = "Sentry Code Gate Barrier"
return true
end)
end
}
Expand Down Expand Up @@ -355,7 +364,7 @@ Db.cards[1040] = {

--- @param ctx Ctx
onInstall = function (ctx)
make_interaction:promptSlotSelect(SIDE_RUNNER, SLOT_RUNNER_PROGRAMS, 1, function (card, slot)
make_interaction:promptSlotSelect(SIDE_RUNNER, SLOT_RUNNER_PROGRAMS, 1, function (decision, card, slot)
if card.meta:isCardIcebreaker() then
card.meta.until_forever.additional_strength = card.meta.until_forever.additional_strength + 1
return true
Expand Down Expand Up @@ -841,7 +850,7 @@ _archer_trash_program_subroutine = function ()
SIDE_RUNNER,
function (slot) return slot == SLOT_RUNNER_PROGRAMS or slot == SLOT_RUNNER_RESOURCES end,
1,
function (card, slot)
function (decision, card, slot)
if card.meta:canBeSacrificed(nil, SLOT_RUNNER_PROGRAMS) then
board:cardPop(slot, card)
return true
Expand Down
3 changes: 2 additions & 1 deletion app/scripts/controller/human/HumanController.lua
Original file line number Diff line number Diff line change
Expand Up @@ -100,11 +100,12 @@ function HumanController:onTick(dt)
))
else
status_label:setText(string.format(
"%s, cl%d, cr%d, rcr%d, sc%d, tag%d, mem%d",
"%s, cl%d, cr%d, rcr%d/%d, sc%d, tag%d, mem%d",
self.decision.type,
game.decision_stack:countClicks(self.side.id),
self.side.credits,
game.runner.recurring.credits_for_icebreakers,
game.runner.recurring.credits_for_virus_or_icebreakers,
self.side.score,
game.runner.tags,
game.runner.memory
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,12 @@
HCInstallCardComponent = class("HCInstallCardComponent", HumanControllerComponent)

function HCInstallCardComponent:onPrimary(card, slot)
if self.side:actionInstall(self.decision.card, self.decision.slot, slot) then
local discount = 0
if self.decision.type == DiscountedInstallDecision.Type then
discount = self.decision.discount
end

if self.side:actionInstall(self.decision.card, self.decision.slot, slot, false, discount) then
self.decision:handledTop(2)
return true
else
Expand Down
5 changes: 4 additions & 1 deletion app/scripts/decision/phases/DiscountedInstallDecision.lua
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
--- @class DiscountedInstallDecision: Decision
--- @field card Card
--- @field slot string
--- @field discount number
DiscountedInstallDecision = class("DiscountedInstallDecision", Decision, { Type = "discounted_install"})

--- @param side string
--- @param slot string
--- @param card Card
--- @param discount number
--- @return DiscountedInstallDecision
function DiscountedInstallDecision:New(side, slot, card)
function DiscountedInstallDecision:New(side, slot, card, discount)
return construct(self, Decision:New(self.Type, side), {
card = card,
slot = slot,
discount = discount,
})
end
7 changes: 7 additions & 0 deletions app/scripts/game.lua
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,12 @@ function game:boardCardsIter()
remoteSlot(4),
remoteSlot(5),
remoteSlot(6),
remoteIceSlot(1),
remoteIceSlot(2),
remoteIceSlot(3),
remoteIceSlot(4),
remoteIceSlot(5),
remoteIceSlot(6),
SLOT_CORP_HQ,
SLOT_RUNNER_PROGRAMS,
SLOT_RUNNER_HARDWARE,
Expand Down Expand Up @@ -230,6 +236,7 @@ function game:onInit()

board:cardAppend(SLOT_CORP_HAND, Db:card(1094))
board:cardAppend(SLOT_RUNNER_HAND, Db:card(1039))
board:cardAppend(SLOT_RUNNER_HAND, Db:card(1005))
end

info("Game ready!")
Expand Down
5 changes: 3 additions & 2 deletions app/scripts/sides/Runner.lua
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,11 @@ function Runner:actionDrawCard()
end
end

function Runner:actionInstall(card, from, to, suppress_events)
function Runner:actionInstall(card, from, to, suppress_events, discount)
assert(card)
assert(from)
assert(to)
discount = discount or 0

if card.meta:isCardConsole() and to ~= SLOT_RUNNER_CONSOLE then
return false
Expand All @@ -76,7 +77,7 @@ function Runner:actionInstall(card, from, to, suppress_events)
return false
end

if self:spendCredits(card.meta.info.cost) then
if self:spendCredits(card.meta.info.cost - discount) then
card.faceup = true
card.meta.rezzed = true

Expand Down

0 comments on commit 8956df4

Please sign in to comment.