Page 1 of 1

Tooltip on Stock Items

Posted: 28 November 2020, 09:47
by Bids
Hi all,
I have had a request from some players to add a tool tip on some special cards in my game when they are in your hand. I'm talking about 1 - 3 cards that can be in your hand out of 60 cards. In my code, these items are stock items.
So my question is: Is it desireable to have a tooltip on stock items? And how do I add a tooltip on them?
Thanks a lot!

Re: Tooltip on Stock Items

Posted: 28 November 2020, 12:55
by MGoulet
hi

Should you add tooltip on stock cards? Most of the game add tooltips on stock items (7 Wonders, Race for the Galaxy, Dungeon Roll, 13 Clues, ...)

Code: Select all

setup: function (gamedatas) {
    // ...
    var stock = new ebg.stock();
    stock.onItemCreate = dojo.hitch(this, function (card_div, card_type_id, card_id) {
        this.addTooltipToCard(card_id, card_type_id);
    });
    stock.onItemDelete = dojo.hitch(this, function (card_div, card_type_id, card_id) {
        this.removeTooltip(card_id);
    });
    // ...
},

Code: Select all

addTooltipToCard: function (div_id, card_type_id) {
    var card = this.gamedatas.card_types[card_type_id];
    var html = this.format_block("jstpl_tooltip_card", {
        name: _(card.name),
        type: _(card.type),
        subtype: _(card.subtype),
        color: _(card.color),
    });
    this.addTooltipHtml(div_id, html, '');
},