From 991f95519f49284c2c62b12c0ba9fed8b37ac6e2 Mon Sep 17 00:00:00 2001 From: Chr1Z93 Date: Thu, 11 May 2023 15:12:50 +0200 Subject: [PATCH] cleaned up code --- src/arkhamdb/DeckImporterMain.ttslua | 50 ++++++---------------------- 1 file changed, 11 insertions(+), 39 deletions(-) diff --git a/src/arkhamdb/DeckImporterMain.ttslua b/src/arkhamdb/DeckImporterMain.ttslua index 66452455..c4b0d56f 100644 --- a/src/arkhamdb/DeckImporterMain.ttslua +++ b/src/arkhamdb/DeckImporterMain.ttslua @@ -428,45 +428,17 @@ end ---@param card Object Card which needs to be set the state for ---@param loadAltInvestigator String Contains the name of alternative art for the investigator ("normal", "revised" or "promo") function loadAltArt(card, loadAltInvestigator) - if loadAltInvestigator == "normal" then return end - - -- lookup correct stateId for investigator and alt art state - local baseId = string.gsub(JSON.decode(card.getGMNotes()).id, "-m", "") - - local stateIdTable = {} - -- Roland Banks - stateIdTable["01001"] = {} - stateIdTable["01001"]["revised"] = 2 - stateIdTable["01001"]["promo"] = 3 - -- Daisy Walker - stateIdTable["01002"] = {} - stateIdTable["01002"]["revised"] = 2 - -- "Skids" O'Toole - stateIdTable["01003"] = {} - stateIdTable["01003"]["revised"] = 2 - -- Agnes Baker - stateIdTable["01004"] = {} - stateIdTable["01004"]["revised"] = 2 - -- Wendy Adams - stateIdTable["01005"] = {} - stateIdTable["01005"]["revised"] = 2 - -- Jenny Barnes - stateIdTable["02003"] = {} - stateIdTable["02003"]["promo"] = 2 - -- Carolyn Fern - stateIdTable["05001"] = {} - stateIdTable["05001"]["promo"] = 2 - -- Dexter Drake - stateIdTable["07004"] = {} - stateIdTable["07004"]["promo"] = 2 - -- Silas Marsh - stateIdTable["07005"] = {} - stateIdTable["07005"]["promo"] = 2 - -- Norman Withers - stateIdTable["08004"] = {} - stateIdTable["08004"]["promo"] = 2 - - card.setState(stateIdTable[baseId][loadAltInvestigator]) + -- states are set up this way: + -- 1 - normal, 2 - revised/promo, 3 - promo (if 2 is revised) + -- This means we can always load the 2nd state for revised and just get the last state for promo + if loadAltInvestigator == "normal" then + return + elseif loadAltInvestigator == "revised" then + card.setState(2) + elseif loadAltInvestigator == "promo" then + local states = card.getStates() + card.setState(#states) + end end function log(message)