I don't really know where to post this (it's not a problem I'm having, its not actual code. . . yet, but here goes):

I'm planning to work on a quick GUI application with Tk called PerlSol (a solitare program in Perl). I've outlined a basic plan (with some holes, admitingly), and want some input. In particular, it seems to me that using OOP would be the way to go (I'm originally a C/C++ programmer and know a great deal about OOP and how it relates to C/C++, however I'm new to Perl's quirks, so any suggestions as to this would be helpful: I'm planning to read perlboot and perltoot and whatever else may help with this).

The plan (if it can be called that) is presented here, in all its humbleness (its just something quick I want; the program isn't designed to be major, just a small project, but I want some guidance, and a detailed, or not-so-detailed, plan often helps in making code in my opinion).

What I plan to do is make a module that will facilitate the creation of games based on a defined set of rules. For example, for a normal (as I first learnt it) solitare game, you could create seven piles of 1 to 7 cards respectively, only showing the top card, create another pile of cards (the deck), create a waste pile, create four piles to be filled starting with aces, then one could create the 'rules' for these piles (max. number of cards, if there is one, increasing and/or same suit, etc.). The current design plans to facilitate these 'behind the scene' details, so the specific game can be concerned mainly with creating bindings and functions to deal with those bindings. Of course, this is just a projected way of dealing with this (IF ANYTHING BETTER CAN BE DONE, I'D LIKE TO KNOW, I'm posting this so I don't waste too much of my time learning I should be doing something different)

(I make up my own conventions at times, but it should be self-explanatory--it is to me, anyway! I use [something here] to denote that something here is optional. . .I'v seen this various places, the rest follows)

# Don't freak out about not having 'use strict' etc. # :) This is just psuedo code at places my $card = new Card([%attr]); $card->show([x,y]); # displays card on screen, optionally # with the upper-left coordinate # being (x,y) ->suit([val]); # returns (and optionally sets) the # suit to value (data type undecided) ->value([val]); # returns (and optionally sets) the # card number to value (1-13,A,K,Q,J) ->where([pile]); # returns (and optionally sets) the # pile where card is placed ->state([state]); # Sets card to be face up/face down ## "Friend" (from C++, loose usage) functions (designed for ## use with an array of cards (or maybe hash?) IsAlternatingColor(); # e.g., ...black,red,black,red... IsSameColor(); # e.g., ...black,black,black... IsAlternatingSuit(); # e.g., ...diamond,club,heart... IsSameSuit(); # e.g., ...spade,spade,spade... IsIncreasing(); # e.g., 2,3,4,5... IsDecreasing(); # e.g., K,Q,J,10... my $pile = new Pile([%attr]); $pile->maxcards([val]); # returns (and optionally # sets) max. amount of cards # (or NO_LIMIT constant) $pile->nextcard(); # returns suit/value of next # card, beginning at top $pile->get(x); # same thing, but xth card # (0 is top, 1 is second, ...) $pile->rules(rules); # Rules that cards must abide # by (e.g., decreasing) ## A tableau is a 2-d array of piles ## A waste/stock/foundation/etc. is a pile (or a collection ## thereof) ## Terms inspired by some of the free downloadable ## solitare programs, e.g., 1 2 3 Free Solitare ## at: www.123freesolitaire.com/ User-Level notes ---------------- Undo feature Change deck style Change different features of display Deign your own game Next Move AutoPlay (last two use a primitive AI algorithm; of course, I don't plan to do all these things at first, some are just ideas I 'may' choose to implement later -- its just a simple program for someone I know)


In reply to PerlSol (solitaire in Perl) by dimmesdale

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.