From 8956df412a6466a5988e1085e024407fc57309ae Mon Sep 17 00:00:00 2001 From: Vasyl Horbachenko Date: Mon, 22 Jun 2020 00:40:42 +0000 Subject: [PATCH] WIP --- app/scripts/Side.lua | 5 ++++- app/scripts/cardspec/packs/core.lua | 19 ++++++++++++++----- .../controller/human/HumanController.lua | 3 ++- .../components/HCInstallCardComponent.lua | 7 ++++++- .../phases/DiscountedInstallDecision.lua | 5 ++++- app/scripts/game.lua | 7 +++++++ app/scripts/sides/Runner.lua | 5 +++-- 7 files changed, 40 insertions(+), 11 deletions(-) diff --git a/app/scripts/Side.lua b/app/scripts/Side.lua index c29dd66..7298bbb 100644 --- a/app/scripts/Side.lua +++ b/app/scripts/Side.lua @@ -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 diff --git a/app/scripts/cardspec/packs/core.lua b/app/scripts/cardspec/packs/core.lua index d70018c..ded107e 100644 --- a/app/scripts/cardspec/packs/core.lua +++ b/app/scripts/cardspec/packs/core.lua @@ -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 @@ -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, @@ -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 } @@ -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 } @@ -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 @@ -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 diff --git a/app/scripts/controller/human/HumanController.lua b/app/scripts/controller/human/HumanController.lua index 8f67985..842b14d 100644 --- a/app/scripts/controller/human/HumanController.lua +++ b/app/scripts/controller/human/HumanController.lua @@ -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 diff --git a/app/scripts/controller/human/components/HCInstallCardComponent.lua b/app/scripts/controller/human/components/HCInstallCardComponent.lua index 6bc1194..77015de 100644 --- a/app/scripts/controller/human/components/HCInstallCardComponent.lua +++ b/app/scripts/controller/human/components/HCInstallCardComponent.lua @@ -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 diff --git a/app/scripts/decision/phases/DiscountedInstallDecision.lua b/app/scripts/decision/phases/DiscountedInstallDecision.lua index 36ff19e..2914cc5 100644 --- a/app/scripts/decision/phases/DiscountedInstallDecision.lua +++ b/app/scripts/decision/phases/DiscountedInstallDecision.lua @@ -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 diff --git a/app/scripts/game.lua b/app/scripts/game.lua index de815cd..b4b77b4 100644 --- a/app/scripts/game.lua +++ b/app/scripts/game.lua @@ -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, @@ -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!") diff --git a/app/scripts/sides/Runner.lua b/app/scripts/sides/Runner.lua index cb2d77a..59d30f4 100644 --- a/app/scripts/sides/Runner.lua +++ b/app/scripts/sides/Runner.lua @@ -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 @@ -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