comp.lang.ada
 help / color / mirror / Atom feed
From: "Jeffrey R. Carter" <spam.jrcarter.not@spam.not.acm.org>
Subject: Re: Card game deck but with trumps suit for tarot "divination" Is there a better way than enumerating all cards?
Date: Sun, 28 Jan 2018 10:46:54 +0100
Date: 2018-01-28T10:46:54+01:00	[thread overview]
Message-ID: <p4k66f$jnb$1@dont-email.me> (raw)
In-Reply-To: <40142b86-fdcf-49d3-bee7-2fdbb04c6db0@googlegroups.com>

On 01/28/2018 10:23 AM, bozovic.bojan@gmail.com wrote:
>>
>>     type Card (Trump : Boolean) is
>>        record
>>           case Trump is
>>              when True =>
>>                 Trump_Value : Major_Arcana;
>>              when False =>
>>                 Suit        : Suits;
>>                 Value       : Values;
>>        end record;

With the addition of the missing "end case;" and a default for the discriminant 
so you can have an array of this type, this is the way I'd approach it.

> Thanks for the input, I'll look into your suggestion, but the main problem is each card has its "divinatoy meaning". I've used Tarot_Card_Position because it makes more sense to shuffle deck indexed in integer than in enumeration type and draw then a number of cars from it. But I know I wrote some awful code, as I really have little experience and no formal education.

Yes, a deck is a sequence of cards; representing it as an array means the index 
values are meaningless. While the deck starts out with 78 cards, after dealing 
some cards it is shorter, so something like

Max_Cards : constant := 78;

subtype Deck_Length is integer     range 0 .. Max_Cards;
subtype Deck_Index  is Deck_Length range 1 .. Max_Cards;

type Deck_List is array (Deck_Index range <>) of Card_Info;

type Deck_Info (Length : Deck_Length := 0) is record
    Deck : Deck_List (1 .. Length);
end record;

would make sense.

You might want to look at PragmARC.Deck_Handler which has already dealt with 
these issues.

https://github.com/jrcarter/PragmARC

-- 
Jeff Carter
"We use a large, vibrating egg."
Annie Hall
44

  reply	other threads:[~2018-01-28  9:46 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-01-28  7:48 Card game deck but with trumps suit for tarot "divination" Is there a better way than enumerating all cards? bozovic.bojan
2018-01-28  8:57 ` Jacob Sparre Andersen
2018-01-28  9:23   ` bozovic.bojan
2018-01-28  9:46     ` Jeffrey R. Carter [this message]
2018-01-28 14:17       ` bozovic.bojan
2018-01-28 16:39     ` Dennis Lee Bieber
2018-01-29 23:16     ` Randy Brukardt
2018-01-30  2:30       ` bozovic.bojan
2018-02-02 19:07       ` Robert Eachus
2018-02-02 23:00         ` Dennis Lee Bieber
2018-02-02 23:05         ` Randy Brukardt
2018-02-03  8:17           ` Jeffrey R. Carter
2018-02-03 16:59           ` Robert Eachus
2018-02-06  0:39             ` Randy Brukardt
2018-02-06  3:17               ` Robert Eachus
2018-02-06  8:30           ` Petter Fryklund
2018-02-07 20:03             ` Card game deck but with trumps suit for tarot "divination" Is there a better way Robert Eachus
2018-02-07 21:10               ` Bojan Bozovic
2018-02-08 23:06                 ` Robert Eachus
2018-01-28 11:01   ` Card game deck but with trumps suit for tarot "divination" Is there a better way than enumerating all cards? gautier_niouzes
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox