Having problem modifying a script

So, I'm trying to modified a script that does something with ALL actors, but I want it to do it with the last actor that made the last action in battle. For this, I tried to make that the call for actor is equal to a variable, but it's not working. The original part of script is this:

Code:
def has_card_in_deck?(id)
   for actor in $game_party.members
      for card in actor.deck
        return true if card.id == id
      end
    end
    return false
  end

So, I tried to change the $game_party.members to return the ID of the actor based on a variable:

Code:
def has_card_in_deck?(id)
    for actor in $game_variables[27]
      for card in actor.deck
        return true if card.id == id
      end
    end
    return false
  end

Also tried with: $game_party.members[$gameVariables.value(27)]
and $gameActors.actor($gameVariables.value(27))
but non of these worked neither.

But I'm not good at ruby as you can see. So any help is welcome.

Thanks in advance!

Original thread: https://forums.rpgmakerweb.com/threads/having-problem-modifying-a-script.146782/