Package controller

Examples of controller.Sho


        }
    }
    private model.Player currentPlayer;

    public ShoUI() {
        s = new Sho("A", "B", "C");
        mevent = new ShoMouseEvents();
        currentPlayer = s.getCurrentPlayer();
    }
View Full Code Here


*/
public class ShoCLI {
    public static void main(String[] args)
    {
        Scanner d= new Scanner(System.in);
        Sho s= new Sho("A","B","C");
        System.out.println("Sho game created with 3 player A B C.");

       

        while (!s.isOver())
        {
            Player currentPlayer=s.getCurrentPlayer();
            System.out.println("*Turn is: "+s.getTurn() +" and player is : | "+currentPlayer.getLabel()
                    + " | Press enter to throw dice ");
            d.nextLine();
            int dice1=s.getB().dice1.throwDice();
            int dice2=s.getB().dice2.throwDice();
            int diceTotal=dice1+dice2;
            System.out.println("*Dice result:" + dice1+"+"+dice2+"="+diceTotal);
            System.out.println("*Select a tile to move from by typing its number."
                    + "\n-1 for starting tile, 0 to 63 for normal tile " );
            //parse user input
            int input=Integer.parseInt(d.nextLine());
            System.out.println("*Got: " +input);
            Tile source=null;
            //identify tile
            if (input<0)
            {
                source=s.getB().baseTiles[currentPlayer.getId()];
            }else source=s.getB().tiles[input];
            //get destination tile
            Tile dest = s.getB().getDest(source, diceTotal, currentPlayer);
            //get tokenStack at source
            TokenStack toMove=source.getOccupyingStack().getMovingStack();
            //add and check move of this tokenStack
             if (toMove.addMove(dest.getOccupyingStack(), diceTotal)){
                 System.out.print("Move is Valid:moving to "+dest.getId());
                 switch(toMove.getMoveType())
                 {
                     case KILL: System.out.println("kill");s.getB().kill(source, dest,toMove);break;
                     case NORMAL:System.out.println("moving"); s.getB().move(source, dest,toMove);break;
                     case STACK: System.out.println("stacking");s.getB().stack(source, dest,toMove);break;
                     case GOAL: System.out.println("reached goal");s.getB().goal(source, dest,toMove);break;
                 }
             }else
             {
                if (source.isStartingBase())
                {
                    System.out.print("Move is inValid:add"+dest.getId());
                    //need to return the toMove stack
                    source.getOccupyingStack().stackTokenStarting(toMove.getTokens());
                }
                s.getB().repeatThrow=true;
             }

            //display board
            System.out.print(s.getB().toString());
            //increment turn
            if (!s.getB().repeatThrow)
            {
                currentPlayer=s.getNextPlayer();

            }
        }
       
    }
View Full Code Here

TOP

Related Classes of controller.Sho

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.