Skip to content

v06 solitaire Solitaire.scs

George Heineman edited this page Feb 8, 2018 · 1 revision
// This import is still textual in nature. Needs to be changed to reflect on the true import of declarations
// and types


// Part of view represented here.
	Game : {
	    λtc.     {letbox TestCases             = {tc}      in {
	    λhelps.  {letbox HelperFunctions       = {helps}   in {
		λcontrs. {letbox Controllers           = {contrs}  in {
		λmethod. {letbox MethodDeclarations    = {method}  in {
		λfield.  {letbox FieldDeclarations     = {field}   in {
		λwin.    {letbox WinParameter          = {win}     in {
		λinit.   {letbox InitializeParameter   = {init}    in {
		λname.   {letbox NameParameter         = {name}    in {

		box [

		"=======" NameParameter "/" NameParameter ".java=======
package " NameParameter ";

// it would be great to be able to accumulate import files throughout all of the mvars and
// then subsequently insert them here as one. note: this is an L2-level operation.
import ks.common.games.*;
import ks.common.view.*;
import ks.common.model.*;
import ks.common.controller.*;

import ks.client.gamefactory.GameWindow;
import ks.launcher.Main;

import javax.swing.*;
import java.awt.event.*;

/**
 * The Game plugin is the constant upon which all other plugins are refined.
 * <p>
 * It is a fully working plugin that has absolutely no behavior or meaning. It won't have the
 * Score or NumberOfCardsLeft, but it will at least be able to show a blank playing field.
 * <p>
 * @author: George T. Heineman (heineman@cs.wpi.edu)
 */
public class " NameParameter " extends Solitaire {

	// extra class attributes go here
	"
	FieldDeclarations
	"

	// controllers
	"
	Controllers

 	"=======+" NameParameter "/" NameParameter ".java=======

	// extra methods go here
	"
	MethodDeclarations
	"

	/** Enable refinements to determine whether game has been won. */
	public boolean hasWon () {
		"
			WinParameter
		"
		return false;
	}

	/** Refinement determines initializations. */
	public void initialize() {
		"
		InitializeParameter
		"

		// Cover the Container for any events not handled by a widget:
		getContainer().setMouseMotionAdapter(new ks.common.controller.SolitaireMouseMotionAdapter(this));
		getContainer().setMouseAdapter (new ks.common.controller.SolitaireReleasedAdapter(this));
		getContainer().setUndoAdapter (new SolitaireUndoAdapter(this));
	}

	/** Refinement determines name. */
	public String getName() {
		return \"" NameParameter "\";
	}

	/**
	 * Helper routine for setting default widgets. This is defined so that any future layer
	 * can use this method to define a reasonable default set of controllers for the widget.
	 */
	protected void setDefaultControllers (Widget w) {
		w.setMouseMotionAdapter (new ks.common.controller.SolitaireMouseMotionAdapter(this));
		w.setMouseAdapter (new ks.common.controller.SolitaireReleasedAdapter(this));
		w.setUndoAdapter (new SolitaireUndoAdapter(this));
	}

	// force to be able to launch directly. HACK
	public static void main (String[] args) {
		final JFrame jf = new JFrame();
		JPanel jp = new JPanel();
		JButton jb = new JButton (\"Start\");
		jp.add(jb);
		jf.add(jp);
		jf.setSize(200, 200);
		jf.setVisible(true);
		jf.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);

		jb.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent ae) {

				// use temporary window as peer for retrieving deck images.
				CardImagesLoader.getDeck(jf, \"oxymoron\");

				jf.setVisible(false);
				final GameWindow gw = Main.generateWindow(new " NameParameter "(), Deck.OrderBySuit);
				// properly exist program once selected.
				gw.addWindowListener(new WindowAdapter() {
					public void windowClosing (WindowEvent we) {
						System.exit(0);
					}
				});
				gw.setVisible(true);
			}
		});
	}
}

			"
			// place at end to not interfere with code generation. Should handle this a different way.
			HelperFunctions
			TestCases
			]

		 }}
		 }}
		 }}
		 }}
		 }}
		 }}
		 }}
		 }}
	}