Gregory James Caldwell Jr.
Robert Shaffer
December 7, 2014


We will visually represent decks and individual cards. The visuals will be based on analysis preformed on the decks.


Concepts Demonstrated

Object Orientation is used to create and manage the card and deck objects. Lambda functions are used in both managing objects and preforming analysis. Map and Filter are used in preforming analysis.

External Technology and Libraries

lang/pson library was used set positions of images. 2htdp/image library was used to create and display images. htdp/error library was used for handling image errors. Card database was gathered from Card images was gathered from json library was used for handling the card database, because it is in Json form. We also made more extensive use of the string library functions.

Favorite Lines of Code

  • Partner One: Gregory James Caldwell Jr.
        (list (text "Card Name" 36 "black") ;;; Card Name
              (text "Deck Name" 36 "black") ;;; Deck Name
              (text (Stat_to_String_1 60) 40 (Color_Coder 3)) ;;; Stat 1
        (list (make-posn 120 30) ;;; Card Name Position 
              (make-posn 120 70)  ;;; Deck Name Position 
              (make-posn 225 150)  ;;; Stat 1 Position 
        (rectangle 800 600 "solid" "darkcyan"))

This code is a snippet from the Card UI Handler that places pieces of images and text on the screen, the highlight is the small helper function Color_Coder that changes the color of the text based on how often a card shows up in a deck.

  • Partner Two: Robert Shaffer
    (define (find-card card-name)
      (car (memf (lambda (x) (equal? (hash-ref x 'name) card-name)) card-list))) 
    (define (make-card card-name)
      (let ((card (find-card card-name)))
        (lambda (message)
          (cond ((eq? message 'get-name)         (lambda (self) card-name))
                ((eq? message 'get-manaCost)     (lambda (self) (hash-ref card 'manaCost)))
                ((eq? message 'get-cmc)          (lambda (self) (catch-errors 0 (hash-ref card 'cmc))))
                ((eq? message 'get-colors)       (lambda (self) (hash-ref card 'colors)))
                ((eq? message 'get-type)         (lambda (self) (hash-ref card 'type)))

This code was made simpler through the find-card function. It also shows how I kept card objects small in size by storing only the name and accessing the rest of information through the card database.

Technology Used Block Diagram

Additional Remarks

Challenges: During the creation of the project we came into several challenges due to the complexity of Magic the Gathering.

Formats: MTG is broken down into several formats, Standard, Modern, Legacy, Vintage and many more. We decided to stick to Standard one of the smaller formats only allowing card from the last 2 years in it's card pool, but we designed our program to be very easily expandable, so eventually we could be able to do analysis on decks encompassing cards from the entire 14,000 card pool.

Same Card Printed in Multiply Sets: WOTC the company that runs MTG sometimes reprints cards with different art, flavor text, or reminder text. To handle this we noticed that we designed the database to use the first card it grabs on the find, because although they might have different art, the functionality of the card stays the same, leaving no need to check for every occurrence of the card in the database.

Size Limits on Decks: Error was very important during this project, but something needed a very delicate solution the different formats in MTG have different deck size limits Standard has 60 Card Minimum, while EDH has a strict 100 card requirement all of which must be singletons. The eventual solution was to not impose a limit on the number of cards a deck could contain.