From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=unavailable autolearn_force=no version=3.4.4 Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail From: "Jeffrey R. Carter" Newsgroups: comp.lang.ada 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 Organization: Also freenews.netfront.net; news.tornevall.net; news.eternal-september.org Message-ID: References: <87y3ki743m.fsf@jacob-sparre.dk> <40142b86-fdcf-49d3-bee7-2fdbb04c6db0@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Injection-Date: Sun, 28 Jan 2018 09:46:55 -0000 (UTC) Injection-Info: reader02.eternal-september.org; posting-host="94d070d98a6c92d4c41f3819cc5c0a4f"; logging-data="20203"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19B8VXrAasa2NOWV3gcfefpQQBWy8vYOb8=" User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.5.0 In-Reply-To: <40142b86-fdcf-49d3-bee7-2fdbb04c6db0@googlegroups.com> Content-Language: en-US Cancel-Lock: sha1:vDiKKrGyPPbYvdM0FA3PzjfisTY= Xref: reader02.eternal-september.org comp.lang.ada:50192 Date: 2018-01-28T10:46:54+01:00 List-Id: 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