Jump to content

Trying to replicate Sequencer in negotiation doesn't work well


RageLeague

Recommended Posts

I am trying to add a sequencer equivalent (restore all charges to an item anywhere in your deck) in negotiation. For some reason, it will either show a card on the screen that can never go away or be played (if you choose a card from hand, unlike in battle), or it just hard crash the game (when trying to do something like card:TransferCard(minigame.trash_deck) on the chosen card). There seem to be some issues.

Link to comment
Share on other sites

Okay, here is the replicated card

    sequencer_negotiation =
    {
        name = "Sequencer",
        flavour = "'Universal energy my friend, that's what the blue is all about.'",
        desc = "Restore all uses to an item card in your hand.",
        icon = "battle/sequencer.tex",

        item_tags = ITEM_TAGS.UTILITY,
        rarity = CARD_RARITY.UNCOMMON,

        cost = 1,
        max_charges = 3,

        battle_counterpart = "sequencer",

        flags = CARD_FLAGS.REPLENISH | CARD_FLAGS.EXPEND,

        GetCardsOwnedBySelf = function(self)
            if self.negotiator:IsPlayer() and self.engine then
                return table.merge( self.engine.hand_deck.cards, self.engine.discard_deck.cards, self.engine.draw_deck.cards )
            end
            -- return self.engine:GetHandDeck()
        end,

        CanPlayCard = function( self, card, engine, target )
            if not self:GetCardsOwnedBySelf() then
                return false, CARD_PLAY_REASONS.NO_VALID_TARGETS
            end
            for i, card in ipairs(self:GetCardsOwnedBySelf()) do
                if card:IsPartiallySpent() then
                    return true
                end
            end
            return false, CARD_PLAY_REASONS.NO_VALID_TARGETS
        end,

        OnPostResolve = function( self, minigame, targets )
            local card = minigame:ChooseCardsFromTable( self:GetCardsOwnedBySelf(), 1, 1, Negotiation.Card.IsPartiallySpent, LOC "CARD_ENGINE.CHOOSE_SPENT_CARD", self )[1]
            if card then
                local original_deck = card.deck
                original_deck:RemoveCard(card)
                -- card:TransferCard(minigame.trash_deck)
                -- minigame:GetTrashDeck():InsertCard( card )
                card:RestoreCharges()
                -- card.show_dealt = false
                -- minigame:DealCard( card, original_deck )
                card:TransferCard(original_deck)
                -- card:NotifyChanged()
            end
        end,
    },

 

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

Please be aware that the content of this thread may be outdated and no longer applicable.

×
  • Create New...