Exemplo n.º 1
0
    protected void Update()
    {
        int[] startLandCount = startLand.getRoleCount();
        int[] endLandCount   = endLand.getRoleCount();
        int[] boatCount      = boat.getRoleCount();

        int startPriestsCount = startLandCount[0];              //including roles on boat if the boat is at the same side
        int startDevilsCount  = startLandCount[1];

        int endPriestsCount = endLandCount[0];
        int endDevilsCount  = endLandCount[1];

        int boatPriestsCount = boatCount[0];
        int boatDevilsCount  = boatCount[1];

        if (boat.getBoatFlag() == 1)
        {
            startPriestsCount += boatPriestsCount;
            startDevilsCount  += boatDevilsCount;
        }
        else if (boat.getBoatFlag() == -1)
        {
            endPriestsCount += boatPriestsCount;
            endDevilsCount  += boatDevilsCount;
        }

        if ((startPriestsCount > 0 && startDevilsCount > startPriestsCount) || (endPriestsCount > 0 && endDevilsCount > endPriestsCount))               //lose
        {
            callback.JudgeEvent(JudgeEventType.lose);
        }
        else if (startDevilsCount + startPriestsCount == 0 && endPriestsCount + endDevilsCount == 6 && boatPriestsCount == 0 && boatDevilsCount == 0)           //win
        {
            callback.JudgeEvent(JudgeEventType.win);
        }
        else
        {
            callback.JudgeEvent(JudgeEventType.unfinish);               //continue playing
        }
    }
Exemplo n.º 2
0
    public int check()
    {
        int[] startLandCount = startLand.getRoleCount();
        int[] endLandCount   = endLand.getRoleCount();
        int[] boatCount      = boat.getRoleCount();

        int startPriestsCount = startLandCount[0];              //including roles on boat if the boat is at the same side
        int startDevilsCount  = startLandCount[1];

        int endPriestsCount = endLandCount[0];
        int endDevilsCount  = endLandCount[1];

        int boatPriestsCount = boatCount[0];
        int boatDevilsCount  = boatCount[1];

        if (boat.getBoatFlag() == 1)
        {
            startPriestsCount += boatPriestsCount;
            startDevilsCount  += boatDevilsCount;
        }
        else if (boat.getBoatFlag() == -1)
        {
            endPriestsCount += boatPriestsCount;
            endDevilsCount  += boatDevilsCount;
        }

        if ((startPriestsCount > 0 && startDevilsCount > startPriestsCount) || (endPriestsCount > 0 && endDevilsCount > endPriestsCount))               //lose
        {
            return(-1);
        }
        else if (startDevilsCount + startPriestsCount == 0 && endPriestsCount + endDevilsCount == 6 && boatPriestsCount == 0 && boatDevilsCount == 0)           //win
        {
            return(1);
        }
        return(0);              //continue playing
    }