fafranco82 / swdestinydb

Star Wars Destiny Deckbuilder
52 stars 25 forks source link

Helper text #349

Open mlogie opened 3 years ago

mlogie commented 3 years ago

Hi @fafranco82 I'm happy to make this change, but can't find where to do so. On the db, there's some helper text for things like Guardian - you can hover over the text and how that keyword works pops up. However, I'd like to add this for Detect and for an upcoming mechanic from ARH. Also, the Guardian text is incorrect, so I can edit it. Where is the code for this located?

fafranco82 commented 3 years ago

Hi,

the search controller call to CardsData::getCardInfo, that, if there is no api, calls for text field a series of function found in CardsData itself:

$cardinfo['text'] = $this->replaceSymbols($cardinfo['text']);
$cardinfo['text'] = $this->addAbbrTags($cardinfo['text']);
$cardinfo['text'] = $this->splitInParagraphs($cardinfo['text']);

Of all those, addAbbrTags is where helper text resides:

public function addAbbrTags($text)
{
      $locale = $this->request_stack->getCurrentRequest()->getLocale();

      foreach(\AppBundle\Helper\Constants::KEYWORDS as $keyword)
      {
          /** @Ignore */
          $translated = $this->translator->trans('keyword.'.$keyword.".name", array(), "messages", $locale);

          $text = preg_replace_callback("/\b($translated)\b/i", function ($matches) use ($keyword) {
              return "<abbr data-keyword=\"$keyword\">".$matches[1]."</abbr>";
          }, $text);
      }
      return $text;
}

The current keywords are found in Constants::KEYWORDS, and then looks for a string keyword._<keyword>_.name, and then in JS use keyword._<keyword>_.title to long description shown in tooltip.

In short, you must add the new keyword(s) in Constants file, and then add 2 new messages for each keyword...

For the last part, I use Localise platform, I can send you an invitation to add that strings, or write them down here and I will add it. (send me an email telling me where send you an invitation).

mlogie commented 3 years ago

Thanks @fafranco82. I've made a pull request for the new keywords on the GitHub repo. If it's ok with you, here are the text strings for the keywords. I've included Guardian as the helper text for guardian on the db is incorrect (it was updated by FFG in 2017 I believe. The db version is the pre-update version of this text). Guardian: "After a character with Guardian is activated, its controller may deal it damage equal to the value of a die showing damage in an opponent’s dice pool. Then remove that die." Piloting: "After a character with Piloting is activated, its controller may choose a vehicle they control and activate it. That character is piloting that vehicle. Piloting expires at the end of the round." Detect: "After this card is activated, reveal a random non-detected card in an opponent’s hand. That card remains revealed until the end of the action phase and is Detected." Renew: "You may play this card from your discard pile for its Renew cost. Then set it aside."