Skip to content

v06 solitaire controllers DeckController.scs

George Heineman edited this page Feb 8, 2018 · 1 revision
	// this is a generic architecture for a deck controller. As such this can be reused as is
	// across all variations
	DeckController : {
		λname. {letbox NameParameter        = {name} in {
		λdp.   {letbox DeckMousePressed     = {dp box["m"]} in {

		box ["=======" NameParameter "\DeckController.java=======
package " NameParameter ";
import java.awt.event.MouseEvent;
import ks.common.view.*;
import ks.common.model.*;
import ks.common.controller.*;

/**
 * Controller for Decks. Typical actions involve just dealing cards from deck, so this
 * kind of controller is simpler to write. This standardized deck controller has only
 * press events (for now).
 */
public class DeckController extends SolitaireReleasedAdapter {

	protected " NameParameter " theGame;

	public DeckController(" NameParameter " theGame) {
		super(theGame);

		this.theGame = theGame;
	}

	// Deal cards
	public void mousePressed(MouseEvent me) {
	    Move m;

		// Action on press
		"
		DeckMousePressed
		"

		// have solitaire game refresh widgets that were affected
		theGame.refreshWidgets();
	}
}"]
		}}
		}}
	}

Clone this wiki locally