diff --git a/src/activities/activities.txt b/src/activities/activities.txt index afb7b334a..640d2095f 100644 --- a/src/activities/activities.txt +++ b/src/activities/activities.txt @@ -1,126 +1,127 @@ # The list of activities that will be loaded at GCompris start. # Keep it sorted advanced_colors algebra_by algebra_div algebra_minus algebra_plus algorithm align4 align4-2players alphabet-sequence babymatch babyshapes baby_wordprocessor balancebox ballcatch braille_alphabets braille_fun canal_lock chess chess_2players chess_partyend chronos clickanddraw clickgame click_on_letter click_on_letter_up clockgame color_mix color_mix_light colors details drawnumber enumerate erase erase_2clic erase_clic explore_farm_animals explore_monuments explore_world_animals explore_world_music fifteen followline football geo-country geography gletters gnumch-equality gnumch-factors gnumch-inequality gnumch-multiples gnumch-primes graph-coloring guessnumber hangman hanoi hanoi_real hexagon imagename instruments intro_gravity land_safe lang leftright lightsoff louis-braille magic-hat-minus magic-hat-plus maze mazeinvisible mazerelative melody memory memory-enumerate memory-math-add memory-math-add-minus memory-math-add-minus-mult-div memory-math-add-minus-mult-div-tux memory-math-add-minus-tux memory-math-add-tux memory-math-div memory-math-div-tux memory-math-minus memory-math-minus-tux memory-math-mult memory-math-mult-div memory-math-mult-div-tux memory-math-mult-tux memory-sound memory-sound-tux memory-tux memory-wordnumber mining missing-letter money money_back money_back_cents money_cents mosaic nine_men_morris +nine_men_morris_2players numbers-odd-even paintings penalty photo_hunter planegame readingh readingv redraw redraw_symmetrical renewable_energy reversecount scalesboard scalesboard_weight scalesboard_weight_avoirdupois simplepaint smallnumbers smallnumbers2 sudoku superbrain tangram target tic_tac_toe tic_tac_toe_2players traffic watercycle wordsgame diff --git a/src/activities/nine_men_morris/DragPoint.qml b/src/activities/nine_men_morris/DragPoint.qml new file mode 100644 index 000000000..94fe69109 --- /dev/null +++ b/src/activities/nine_men_morris/DragPoint.qml @@ -0,0 +1,98 @@ +/* GCompris - DragPoint.qml + * + * Copyright (C) 2016 Pulkit Gupta + * + * Authors: + * Pulkit Gupta + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, see . + */ +import QtQuick 2.1 + +import "../../core" +import "nine_men_morris.js" as Activity + +import GCompris 1.0 + +Rectangle { + id: dragPoint + width: parent.width/26 + height: width + radius: width/2 + opacity: 1.0 + border.color: "#803300" + border.width: state == "EMPTY" ? 0 : width/6 + state: "AVAILABLE" + + property int index + property bool test + property bool pieceBeingRemoved + property bool firstPhase + property QtObject leftPiece + property QtObject rightPiece + property QtObject upperPiece + property QtObject lowerPiece + + states: [ + State { + name: "AVAILABLE" // Green color + PropertyChanges{ + target: dragPoint + color: "#00ff00" + } + }, + State { + name: "UNAVAILABLE" // Red color + PropertyChanges{ + target: dragPoint + color: "Red" + } + }, + State { + name: "EMPTY" // Brown color + PropertyChanges{ + target: dragPoint + color: "#803300" + } + }, + State { + name: "1" // Red color + PropertyChanges { + target: dragPoint + color: "Red" + } + }, + State { + name: "2" // Red color + PropertyChanges { + target: dragPoint + color: "Red" + } + } + ] + + MouseArea { + id: area + enabled: parent.state == "AVAILABLE" && !pieceBeingRemoved + anchors.centerIn: parent + width: 2.5*parent.width + height: 2.5*parent.height + onClicked: { + if (firstPhase) + Activity.handleCreate(index) + else + Activity.movePiece(index) + } + } +} diff --git a/src/activities/nine_men_morris/NineMenMorris.qml b/src/activities/nine_men_morris/NineMenMorris.qml index 8509bc1d6..d532e15f1 100644 --- a/src/activities/nine_men_morris/NineMenMorris.qml +++ b/src/activities/nine_men_morris/NineMenMorris.qml @@ -1,644 +1,818 @@ /* GCompris - NineMenMorris.qml * * Copyright (C) 2016 Pulkit Gupta * * Authors: * Pulkit Gupta * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, see . - */ +*/ import QtQuick 2.1 import "../../core" import "nine_men_morris.js" as Activity ActivityBase { id: activity property bool twoPlayer: false onStart: focus = true onStop: {} pageComponent: Image { id: background anchors.fill: parent source: Activity.url + "background.svg" sourceSize.width: Math.max(parent.width, parent.height) fillMode: Image.PreserveAspectCrop signal start signal stop Component.onCompleted: { activity.start.connect(start) activity.stop.connect(stop) } // Add here the QML items you need to access in javascript QtObject { id: items property Item main: activity.main property alias background: background property alias board: board + property alias dragPointsModel: dragPointsModel + property alias dragPoints: dragPoints property alias tutorialImage: tutorialImage.source property alias tutorialTxt: tutorialTxt.text property alias tutNum: tutorialTxt.tutNum property bool isTutorial property alias player1: player1 - property alias firstInitial: firstInitial + property alias firstInitialVisible: firstInitial.visible + property alias firstPlayerPieces: firstPlayerPieces + property alias firstPlayerPiecesModel: firstPlayerPiecesModel + property alias firstPieceNumberCount: firstPieceNumber.count property alias player1background: player1background.visible property alias player1_score: player1_score.text property alias player1turn: player1turn property alias player1shrink: player1shrink property alias player1image: player1image property alias changeScalePlayer1: changeScalePlayer1 property alias rotateKonqi: rotateKonqi property alias player2: player2 - property alias secondInitial: secondInitial + property alias secondInitialVisible: secondInitial.visible + property alias secondPlayerPieces: secondPlayerPieces + property alias secondPlayerPiecesModel: secondPlayerPiecesModel + property alias secondPieceNumberCount: secondPieceNumber.count property alias player2background: player2background.visible property alias player2_score: player2_score.text property alias player2turn: player2turn property alias player2shrink: player2shrink property alias player2image: player2image property alias changeScalePlayer2: changeScalePlayer2 property alias rotateTux: rotateTux property bool gameDone property int counter - property int playSecond + property bool playSecond + property bool firstPhase + property bool pieceBeingRemoved + property alias bar: bar property alias bonus: bonus + property alias positionSet: positionSet + property alias instructionTxt: instruction.text } + Loader { + id: positionSet + asynchronous: false + } + onStart: Activity.start(items, twoPlayer) onStop: Activity.stop() Image { id: board source: Activity.url + "board.svg" - sourceSize.width: 3 * Math.min(background.width / 4 , background.height / 6) + //sourceSize.width: 5 * Math.min(background.width / 4 , background.height / 6) + sourceSize.width: Math.min(background.height - 1.4 * player1.height - 1.2 * bar.height, 0.7 * background.width) visible: !items.isTutorial anchors { verticalCenter: parent.verticalCenter horizontalCenter: parent.horizontalCenter + verticalCenterOffset : -0.25 * player1.height + } + + Repeater { + id: dragPoints + model: dragPointsModel + delegate: point + Component { + id: point + DragPoint { + id: dragPoint + pieceBeingRemoved: items.pieceBeingRemoved + x: posX * parent.width - width / 2 + y: posY * parent.height - height / 2 + index: myIndex + firstPhase: items.firstPhase + } + } } - MouseArea { + /* MouseArea { id: area enabled: true hoverEnabled: true width: parent.width height: parent.height - onClicked: {Activity.handleCreate(parent)} - } + onClicked: { + console.log("Doneb") + //Activity.handleCreate(parent) + } + } */ + } + + ListModel { + id: dragPointsModel } Rectangle { id: firstInitial anchors { left: board.right - leftMargin: 0.05 * parent.width - top: board.top - topMargin: 15 + leftMargin: 15 + bottom: board.verticalCenter + bottomMargin: 30 } - width: Math.min(0.9*parent.width - board.x - board.width, 0.65*board.width) - height: board.height/3 - visible: !items.isTutorial + width: Math.min(Math.min(0.9 * parent.width - board.x - board.width, 0.68 * board.width), 150) + height: 0.18 * board.height + visible: !items.isTutorial && items.firstPhase opacity: 0.8 radius: 10 border.width: 2 border.color: "black" gradient: Gradient { GradientStop { position: 0.0; color: "#6b4723" } GradientStop { position: 0.9; color: "#996633" } GradientStop { position: 1.0; color: "#AAA" } } - Image { - id: initialWhite - source: Activity.url + "white_piece.svg" - sourceSize.height: Math.min(parent.height*0.8,parent.width*0.4) - x: parent.width*0.06 - anchors.verticalCenter: parent.verticalCenter - } + Repeater { + id: firstPlayerPieces + model: firstPlayerPiecesModel + delegate: firstPieceInitial + Component { + id: firstPieceInitial + Piece { + id: firstPiece + state: "1" //items.playSecond % 2 ? "2": "1" + firstPhase: items.firstPhase + //source: Activity.url + "white_piece.svg" + //width: (grid.height / 4) * 1.1 + //height: (grid.height / 4) * 1.1 + sourceSize.height: Math.min(firstInitial.height * 0.8,firstInitial.width * 0.4) + x: firstInitial.width * 0.06 + anchors.verticalCenter: firstInitial.verticalCenter + chance: items.counter % 2 + playSecond: items.playSecond + gameDone: items.gameDone + //opacity: 1 + } + } + } GCText { - id: whiteNumber + id: firstPieceNumber anchors { verticalCenter: parent.verticalCenter - left: initialWhite.right - leftMargin: 7 + right: parent.right + rightMargin: parent.width * 0.1 } - fontSize: initialWhite.height/2 + fontSize: Math.min(parent.height * 0.8,parent.width * 0.4) / 2 color: "white" style: Text.Outline styleColor: "black" horizontalAlignment: Text.AlignHCenter property int count: 9 text: "X%1".arg(count) - } - + } } + ListModel { + id: firstPlayerPiecesModel + } + Rectangle { id: secondInitial anchors { left: board.right - leftMargin: 0.05 * parent.width - bottom: board.bottom - bottomMargin: 15 + leftMargin: 15 + top: board.verticalCenter + topMargin: 30 } - width: Math.min(0.9*parent.width - board.x - board.width, 0.65*board.width) - height: board.height/3 - visible: !items.isTutorial + width: Math.min(Math.min(0.9 * parent.width - board.x - board.width, 0.68 * board.width), 150) + height: 0.18 * board.height + visible: !items.isTutorial && items.firstPhase opacity: 0.8 radius: 10 border.width: 2 border.color: "black" gradient: Gradient { GradientStop { position: 0.0; color: "#6b4723" } GradientStop { position: 0.9; color: "#996633" } GradientStop { position: 1.0; color: "#AAA" } } - - Image { - id: initialBlack - source: Activity.url + "black_piece.svg" - sourceSize.height: Math.min(parent.height*0.8,parent.width*0.4) - x: parent.width*0.06 - anchors.verticalCenter: parent.verticalCenter - } + Repeater { + id: secondPlayerPieces + model: secondPlayerPiecesModel + delegate: secondPieceInitial + Component { + id: secondPieceInitial + /* Image { + id: initialBlack + source: Activity.url + "black_piece.svg" + sourceSize.height: Math.min(parent.height * 0.8,parent.width * 0.4) + x: parent.width * 0.06 + anchors.verticalCenter: parent.verticalCenter + } */ + Piece { + id: secondPiece + state: "2" //items.playSecond % 2 ? "1": "2" + firstPhase: items.firstPhase + //source: Activity.url + "black_piece.svg" + //width: (grid.height/4) * 1.1 + //height: (grid.height/4) * 1.1 + sourceSize.height: Math.min(secondInitial.height * 0.8,secondInitial.width * 0.4) + x: secondInitial.width * 0.06 + anchors.verticalCenter: secondInitial.verticalCenter + chance: items.counter % 2 + playSecond: items.playSecond + gameDone: items.gameDone + //opacity: 1 + } + } + } GCText { - id: blackNumber + id: secondPieceNumber anchors { verticalCenter: parent.verticalCenter - left: initialBlack.right - leftMargin: 7 + right: parent.right + rightMargin: parent.width * 0.1 } - fontSize: initialBlack.height/2 + fontSize: Math.min(parent.height * 0.8,parent.width * 0.4) / 2 color: "white" style: Text.Outline styleColor: "black" horizontalAlignment: Text.AlignHCenter property int count: 9 text: "X%1".arg(count) - } - + } } - // Tutorial section starts - Image { - id: previousTutorial - source: Activity.url + "bar_previous.svg" - sourceSize.height: skipTutorial.height*1.1 - visible: items.isTutorial && tutorialTxt.tutNum != 1 - anchors { - top: parent.top - topMargin: 5 - right: skipTutorialContainer.left - rightMargin: 5 - } - - MouseArea { - id: previousArea - width: parent.width - height: parent.height - onClicked: {Activity.tutorialPrevious()} - } - } - - Image { - id: nextTutorial - source: Activity.url + "bar_next.svg" - sourceSize.height: skipTutorial.height*1.1 - visible: items.isTutorial && tutorialTxt.tutNum != 5 - anchors { - top: parent.top - topMargin: 5 - left: skipTutorialContainer.right - leftMargin: 5 - } - - MouseArea { - id: nextArea - width: parent.width - height: parent.height - onClicked: {Activity.tutorialNext()} - } - } - - GCText { - id: skipTutorial + ListModel { + id: secondPlayerPiecesModel + } + + // Instruction section starts + GCText { + id: instruction anchors { horizontalCenter: parent.horizontalCenter //left: parent.left //leftMargin: 5 top: parent.top topMargin: 5 } - fontSize: 12 //Math.min(parent.width/10, parent.height/2.5) + fontSize: 13 //Math.min(parent.width/10, parent.height/2.5) color: "white" style: Text.Outline styleColor: "black" - horizontalAlignment: Text.AlignHCenter - width: Math.min(implicitWidth, 0.8*parent.width ) - wrapMode: TextEdit.WordWrap - visible: items.isTutorial - text: qsTr("Skip Tutorial") + horizontalAlignment: Text.AlignHLeft + width: implicitWidth//Math.min(implicitWidth, 0.9 * parent.width - 2 * player1.width) + //wrapMode: TextEdit.WordWrap + visible: !items.isTutorial + //text: qsTr("Remove a Piece") z: 2 } Rectangle { - id: skipTutorialContainer - anchors.top: skipTutorial.top - anchors.horizontalCenter: skipTutorial.horizontalCenter - width: skipTutorial.width + 10 - height: skipTutorial.fontSize * 2.28 * Math.ceil(skipTutorial.implicitWidth / skipTutorial.width) + id: instructionContainer + anchors.top: instruction.top + anchors.horizontalCenter: parent.horizontalCenter + width: instruction.width + 20 + height: instruction.fontSize * 2.28 * Math.ceil(instruction.implicitWidth / instruction.width) opacity: 0.8 radius: 10 border.width: 2 border.color: "black" - visible: items.isTutorial + visible: !items.isTutorial gradient: Gradient { GradientStop { position: 0.0; color: "#000" } GradientStop { position: 0.9; color: "#666" } GradientStop { position: 1.0; color: "#AAA" } } - MouseArea { - id: skipArea - hoverEnabled: true - width: parent.width - height: parent.height - onEntered: {skipTutorialContainer.border.color = "#62db53"} - onExited: {skipTutorialContainer.border.color = "black"} - onClicked: {Activity.tutorialSkip()} - } } - - GCText { - id: tutorialTxt + + /* GCText { + id: instruction anchors { horizontalCenter: parent.horizontalCenter //left: parent.left //leftMargin: 5 - top: skipTutorial.bottom - topMargin: skipTutorial.height*0.5 + top: parent.top + topMargin: 5 } fontSize: 13 //Math.min(parent.width/10, parent.height/2.5) color: "white" style: Text.Outline styleColor: "black" horizontalAlignment: Text.AlignHLeft - width: Math.min(implicitWidth, 0.8*parent.width )//, textWidth * tutorialTxt.parent.width) + width: Math.min(implicitWidth, 0.8 * parent.width )//, textWidth * tutorialTxt.parent.width) wrapMode: TextEdit.WordWrap - visible: items.isTutorial + visible: !items.isTutorial text: "Tutorial" z: 2 - property int tutNum: 1 - - /* - function changeTutorialText() { - if (tutNum == 1) { - text = qsTr("Each player starts with 9 pieces. Initially, they take turns to \ - place all their 9 peices onto the empty spots on the board.") - } - } - */ } Rectangle { - id: tutorialTxtContainer - anchors.top: tutorialTxt.top - anchors.horizontalCenter: tutorialTxt.horizontalCenter - width: tutorialTxt.width + 20 - height: tutorialTxt.fontSize * 2.5 * Math.ceil(tutorialTxt.implicitWidth / tutorialTxt.width) + id: instructionContainer + anchors.top: instruction.top + anchors.horizontalCenter: instruction.horizontalCenter + width: instruction.width + 20 + height: instruction.fontSize * 2.5 * Math.ceil(instruction.implicitWidth / instruction.width) opacity: 0.8 radius: 10 border.width: 2 border.color: "black" - visible: items.isTutorial + visible: !items.isTutorial gradient: Gradient { GradientStop { position: 0.0; color: "#000" } GradientStop { position: 0.9; color: "#666" } GradientStop { position: 1.0; color: "#AAA" } } - } - - Image { - id: tutorialImage - source: Activity.url + "tutorial" + tutorialTxt.tutNum + ".svg" - property int heightNeed: background.height - tutorialTxtContainer.height - bar.height - 4*skipTutorialContainer.height - //sourceSize.height: Math.min(background.height - tutorialTxtContainer.height - 1.2*bar.height - 2*skipTutorial.height, 0.5*background.width) - //sourceSize.width: background.width - //height: sourceSize.height >= sourceSize.width ? heightNeed : 0.5*background.width //heightNeed*parent.width/sourceSize.width - width: (sourceSize.width/sourceSize.height) > (0.9*background.width/heightNeed) ? 0.9*background.width : - (sourceSize.width*heightNeed)/sourceSize.height - fillMode: Image.PreserveAspectFit - visible: items.isTutorial - anchors { - top: tutorialTxt.bottom - topMargin: 10 - //bottom: bar.top - //bottomMargin: 10 - horizontalCenter: parent.horizontalCenter - } - } - // Tutorial section ends - - PropertyAnimation { - id: player1turn - target: changeScalePlayer1 - properties: "scale" - from: 1.0 - to: 1.4 - duration: 500 - onStarted:{ - player1.state = "first" - player2.state = "second" - rotateTux.stop() - player2image.rotation = 0 - rotateKonqi.start() - player2shrink.start() - } - onStopped: {Activity.shouldComputerPlay()} - } - - PropertyAnimation { - id: player1shrink - target: changeScalePlayer1 - properties: "scale" - from: 1.4 - to: 1.0 - duration: 500 - } - - PropertyAnimation { - id: player2turn - target: changeScalePlayer2 - properties: "scale" - from: 1.0 - to: 1.4 - duration: 500 - onStarted:{ - player1.state = "second" - player2.state = "first" - rotateKonqi.stop() - player1image.rotation = 0 - rotateTux.start() - player1shrink.start() - } - onStopped: {Activity.shouldComputerPlay()} - } - - PropertyAnimation { - id: player2shrink - target: changeScalePlayer2 - properties: "scale" - from: 1.4 - to: 1.0 - duration: 500 - } - - SequentialAnimation { - id: rotateKonqi - loops: Animation.Infinite - NumberAnimation { - target: player1image - property: "rotation" - from: -30; to: 30 - duration: 750 - easing.type: Easing.InOutQuad - } - NumberAnimation { - target: player1image - property: "rotation" - from: 30; to: -30 - duration: 750 - easing.type: Easing.InOutQuad - } - } - - SequentialAnimation { - id: rotateTux - loops: Animation.Infinite - NumberAnimation { - target: player2image - property: "rotation" - from: -30; to: 30 - duration: 750 - easing.type: Easing.InOutQuad - } - NumberAnimation { - target: player2image - property: "rotation" - from: 30; to: -30 - duration: 750 - easing.type: Easing.InOutQuad - } - } + } */ + // Instruction section ends + // Player scores section start Rectangle { id: player2 - height: Math.min(background.height/7,Math.min(background.width/7,bar.height * 1.05)) - width: height*11/8 + height: Math.min(background.height/10,Math.min(background.width/7,bar.height * 1.05)) + width: height * 11/8 anchors { top: background.top topMargin: 5 right: background.right rightMargin: 5 } radius: 5 state: "second" visible: !items.isTutorial Image { id: player2background source: Activity.url + "score_2.svg" - sourceSize.height: parent.height*0.93 + sourceSize.height: parent.height * 0.93 anchors.centerIn: parent Image { id: player2image source: Activity.url + "TuxBlack.svg" - sourceSize.height: parent.height*0.8 - x: parent.width*0.06 + sourceSize.height: parent.height * 0.8 + x: parent.width * 0.05 anchors.verticalCenter: parent.verticalCenter } GCText { id: player2_score anchors.verticalCenter: parent.verticalCenter - x: parent.width*0.65 + x: parent.width * 0.65 color: "#2a2a2a" - fontSize: largeSize + fontSize: mediumSize } } states: [ State { name: "first" PropertyChanges { target: player2image source: Activity.url + "TuxBlack.svg" } PropertyChanges { target: player2 color: "#49bbf0" } }, State { name: "second" PropertyChanges { target: player2 color: "transparent" } PropertyChanges { target: player2image source: Activity.url + "TuxBlack.svg" } }, State { name: "win" PropertyChanges { target: player2image source: Activity.url + "win.svg" } PropertyChanges { target: player2 color: "#f7ec5d" } } ] transform: Scale { id: changeScalePlayer2 property real scale: 1 origin.x: player2.width origin.y: 0 xScale: scale yScale: scale } } Rectangle { id: player1 - height: Math.min(background.height/7,Math.min(background.width/7,bar.height * 1.05)) - width: height*11/8 + height: Math.min(background.height/10,Math.min(background.width/9,bar.height * 0.9)) + width: height * 11/8 anchors { top: background.top topMargin: 5 left: background.left leftMargin: 5 } radius: 5 state: "second" visible: !items.isTutorial Image { id: player1background source: Activity.url + "score_1.svg" - sourceSize.height: parent.height*0.93 + sourceSize.height: parent.height * 0.93 anchors.centerIn: parent - anchors.horizontalCenterOffset: 0.5 + //anchors.horizontalCenterOffset: 0.5 Image { id: player1image source: Activity.url + "KonqiWhite.svg" - sourceSize.height: parent.height*0.8 - x: parent.width*0.06 + sourceSize.height: parent.height * 0.8 + x: parent.width * 0.05 anchors.verticalCenter: parent.verticalCenter } GCText { id: player1_score anchors.verticalCenter: parent.verticalCenter color: "#2a2a2a" - x: parent.width*0.65 - fontSize: largeSize + x: parent.width * 0.65 + fontSize: mediumSize } } states: [ State { name: "first" PropertyChanges { target: player1image source: Activity.url + "KonqiWhite.svg" } PropertyChanges { target: player1 color: "#f07c49" } }, State { name: "second" PropertyChanges { target: player1 color: "transparent" } PropertyChanges { target: player1image source: Activity.url + "KonqiWhite.svg" } }, State { name: "win" PropertyChanges { target: player1image source: Activity.url + "win.svg" } PropertyChanges { target: player1 color: "#f7ec5d" } } ] transform: Scale { id: changeScalePlayer1 property real scale: 1 xScale: scale yScale: scale } } + // Player scores section ends + + // Animation section start + PropertyAnimation { + id: player1turn + target: changeScalePlayer1 + properties: "scale" + from: 1.0 + to: 1.4 + duration: 500 + onStarted:{ + player1.state = "first" + player2.state = "second" + rotateTux.stop() + player2image.rotation = 0 + rotateKonqi.start() + player2shrink.start() + } + onStopped: {Activity.shouldComputerPlay()} + } + + PropertyAnimation { + id: player1shrink + target: changeScalePlayer1 + properties: "scale" + from: 1.4 + to: 1.0 + duration: 500 + } + + PropertyAnimation { + id: player2turn + target: changeScalePlayer2 + properties: "scale" + from: 1.0 + to: 1.4 + duration: 500 + onStarted:{ + player1.state = "second" + player2.state = "first" + rotateKonqi.stop() + player1image.rotation = 0 + rotateTux.start() + player1shrink.start() + } + onStopped: {Activity.shouldComputerPlay()} + } + + PropertyAnimation { + id: player2shrink + target: changeScalePlayer2 + properties: "scale" + from: 1.4 + to: 1.0 + duration: 500 + } + + SequentialAnimation { + id: rotateKonqi + loops: Animation.Infinite + NumberAnimation { + target: player1image + property: "rotation" + from: -30; to: 30 + duration: 750 + easing.type: Easing.InOutQuad + } + NumberAnimation { + target: player1image + property: "rotation" + from: 30; to: -30 + duration: 750 + easing.type: Easing.InOutQuad + } + } + + SequentialAnimation { + id: rotateTux + loops: Animation.Infinite + NumberAnimation { + target: player2image + property: "rotation" + from: -30; to: 30 + duration: 750 + easing.type: Easing.InOutQuad + } + NumberAnimation { + target: player2image + property: "rotation" + from: 30; to: -30 + duration: 750 + easing.type: Easing.InOutQuad + } + } + // Animation section ends + + + // Tutorial section starts + Image { + id: previousTutorial + source: Activity.url + "bar_previous.svg" + sourceSize.height: skipTutorial.height * 1.1 + visible: items.isTutorial && tutorialTxt.tutNum != 1 + anchors { + top: parent.top + topMargin: 5 + right: skipTutorialContainer.left + rightMargin: 5 + } + + MouseArea { + id: previousArea + width: parent.width + height: parent.height + onClicked: {Activity.tutorialPrevious()} + } + } + + Image { + id: nextTutorial + source: Activity.url + "bar_next.svg" + sourceSize.height: skipTutorial.height * 1.1 + visible: items.isTutorial && tutorialTxt.tutNum != 5 + anchors { + top: parent.top + topMargin: 5 + left: skipTutorialContainer.right + leftMargin: 5 + } + + MouseArea { + id: nextArea + width: parent.width + height: parent.height + onClicked: {Activity.tutorialNext()} + } + } + + GCText { + id: skipTutorial + anchors { + horizontalCenter: parent.horizontalCenter + //left: parent.left + //leftMargin: 5 + top: parent.top + topMargin: 5 + } + fontSize: 12 //Math.min(parent.width/10, parent.height/2.5) + color: "white" + style: Text.Outline + styleColor: "black" + horizontalAlignment: Text.AlignHCenter + width: Math.min(implicitWidth, 0.8 * parent.width ) + wrapMode: TextEdit.WordWrap + visible: items.isTutorial + text: qsTr("Skip Tutorial") + z: 2 + } + + Rectangle { + id: skipTutorialContainer + anchors.top: skipTutorial.top + anchors.horizontalCenter: skipTutorial.horizontalCenter + width: skipTutorial.width + 10 + height: skipTutorial.fontSize * 2.28 * Math.ceil(skipTutorial.implicitWidth / skipTutorial.width) + opacity: 0.8 + radius: 10 + border.width: 2 + border.color: "black" + visible: items.isTutorial + gradient: Gradient { + GradientStop { position: 0.0; color: "#000" } + GradientStop { position: 0.9; color: "#666" } + GradientStop { position: 1.0; color: "#AAA" } + } + MouseArea { + id: skipArea + hoverEnabled: true + width: parent.width + height: parent.height + onEntered: {skipTutorialContainer.border.color = "#62db53"} + onExited: {skipTutorialContainer.border.color = "black"} + onClicked: {Activity.tutorialSkip()} + } + } + + GCText { + id: tutorialTxt + anchors { + horizontalCenter: parent.horizontalCenter + //left: parent.left + //leftMargin: 5 + top: skipTutorial.bottom + topMargin: skipTutorial.height * 0.5 + } + fontSize: 13 //Math.min(parent.width/10, parent.height/2.5) + color: "white" + style: Text.Outline + styleColor: "black" + horizontalAlignment: Text.AlignHLeft + width: Math.min(implicitWidth, 0.8 * parent.width )//, textWidth * tutorialTxt.parent.width) + wrapMode: TextEdit.WordWrap + visible: items.isTutorial + text: "Tutorial" + z: 2 + property int tutNum: 1 + + /* + function changeTutorialText() { + if (tutNum == 1) { + text = qsTr("Each player starts with 9 pieces. Initially, they take turns to \ + place all their 9 peices onto the empty spots on the board.") + } + } + */ + } + + Rectangle { + id: tutorialTxtContainer + anchors.top: tutorialTxt.top + anchors.horizontalCenter: tutorialTxt.horizontalCenter + width: tutorialTxt.width + 20 + height: tutorialTxt.fontSize * 2.5 * Math.ceil(tutorialTxt.implicitWidth / tutorialTxt.width) + opacity: 0.8 + radius: 10 + border.width: 2 + border.color: "black" + visible: items.isTutorial + gradient: Gradient { + GradientStop { position: 0.0; color: "#000" } + GradientStop { position: 0.9; color: "#666" } + GradientStop { position: 1.0; color: "#AAA" } + } + } + + Image { + id: tutorialImage + source: Activity.url + "tutorial" + tutorialTxt.tutNum + ".svg" + property int heightNeed: background.height - tutorialTxtContainer.height - bar.height - + 4 * skipTutorialContainer.height + //sourceSize.height: Math.min(background.height - tutorialTxtContainer.height - 1.2 * bar.height - 2 * skipTutorial.height, 0.5 * background.width) + //sourceSize.width: background.width + //height: sourceSize.height >= sourceSize.width ? heightNeed : 0.5 * background.width //heightNeed * parent.width/sourceSize.width + width: (sourceSize.width/sourceSize.height) > (0.9 * background.width/heightNeed) ? 0.9 * background.width : + (sourceSize.width * heightNeed)/sourceSize.height + fillMode: Image.PreserveAspectFit + visible: items.isTutorial + anchors { + top: tutorialTxt.bottom + topMargin: 10 + //bottom: bar.top + //bottomMargin: 10 + horizontalCenter: parent.horizontalCenter + } + } + // Tutorial section ends DialogHelp { id: dialogHelp onClose: home() } Bar { id: bar content: BarEnumContent { value: (twoPlayer ? (help | home | reload) : (help | home | level | reload))} onHelpClicked: { displayDialog(dialogHelp) } onPreviousLevelClicked: Activity.previousLevel() onNextLevelClicked: Activity.nextLevel() onHomeClicked: activity.home() onReloadClicked: { Activity.reset() } } Bonus { id: bonus Component.onCompleted: win.connect(Activity.nextLevel) } } } diff --git a/src/activities/nine_men_morris/Piece.qml b/src/activities/nine_men_morris/Piece.qml index b624e08d7..fc065fa41 100644 --- a/src/activities/nine_men_morris/Piece.qml +++ b/src/activities/nine_men_morris/Piece.qml @@ -1,56 +1,170 @@ /* GCompris - Piece.qml * * Copyright (C) 2016 Pulkit Gupta * * Authors: * Pulkit Gupta * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, see . */ import QtQuick 2.1 +import QtGraphicalEffects 1.0 import "../../core" import "nine_men_morris.js" as Activity import GCompris 1.0 Image { id: piece + property QtObject pieceParent + property double moveX + property double moveY + property int parentIndex: -1 + property bool canBeRemoved: false + property bool initial: true + property bool firstPhase + property bool isSelected: false + property bool playSecond + property bool gameDone + property int chance + opacity: 1.0//0.5 - opacity: 1.0 + ParallelAnimation { + id: pieceAnimation + NumberAnimation { + target: piece + easing.type: Easing.OutQuad + property: "x" + to: moveX + duration: 430 + } + NumberAnimation { + target: piece + easing.type: Easing.OutQuad + property: "y" + to: moveY + duration: 430 + } + onStarted: { + piece.anchors.verticalCenter = undefined + piece.anchors.centerIn = undefined + //piece.sourceSize.height = pieceParent.width*2.5 + //piece.sourceSize.height = Qt.binding(function() { return pieceParent.parent.width/8 }) + //piece.sourceSize.height = Qt.binding(function() { return pieceParent.width*2.5 }) + } + onStopped: { + //tileImage.parent = tileImage.tileImageParent + //tileImage.anchors.centerIn = tileImage.currentTargetSpot == null ? tileImage.parent : tileImage.currentTargetSpot + //updateOkButton() + piece.parent = pieceParent + piece.anchors.centerIn = pieceParent + piece.parent.state = piece.state + if (Activity.checkMill(piece)) + Activity.UpdateRemovablePiece() + else if (firstPhase) + Activity.continueGame() + else + Activity.checkGameWon() + } + } + /*ParentAnimation { + id: pieceAnimation + target: piece + newParent: pieceParent + NumberAnimation { properties: "x,y"; duration: 1000 } + onStarted: { + console.log("start") + } + onStopped: { + console.log("stop") + } + }*/ states: [ - State { - name: "invisible" - PropertyChanges { - target: piece - opacity: 0 - } - }, - State { - name: "1" // Player 1 - PropertyChanges{ - target: piece - source: Activity.url + "white_piece.svg" - } + State { + name: "invisible" + PropertyChanges { + target: piece + visible: false + } + }, + State { + name: "1" // Player 1 + PropertyChanges{ + target: piece + source: playSecond ? Activity.url + "black_piece.svg" : Activity.url + "white_piece.svg" + } }, State { name: "2" // Player 2 PropertyChanges { target: piece - source: Activity.url + "black_piece.svg" + source: playSecond ? Activity.url + "white_piece.svg" : Activity.url + "black_piece.svg" } } ] + + MouseArea { + id: area + property bool turn: chance ? piece.state == "2" : piece.state == "1" + enabled: ((canBeRemoved && !turn) || (!firstPhase && turn)) + && (piece.parentIndex != -1) && !gameDone + anchors.centerIn: parent + width: parent.width + height: parent.height + onClicked: { + //console.log("gameDone",gameDone,"enabled",enabled) + if (canBeRemoved) + Activity.removePiece(index) + else { + isSelected = true + Activity.pieceSelected(index); + } + } + } + + Rectangle { + id: boundary + anchors.centerIn: parent + width: parent.width + height: parent.height + visible: ((parent.visible && area.enabled && firstPhase) || isSelected) || canBeRemoved + opacity: 1 + radius: width/2 + border.width: 3 + border.color: "green" + color: "transparent" + z: -1 + } + + /* + Behavior on parent { + //ParentAnimation { + //NumberAnimation { properties: "x,y"; duration: 1000 } + //} + NumberAnimation { duration: 1000 } + }*/ + + function move(pieceChangeParent) { + piece.pieceParent = pieceChangeParent + piece.parentIndex = pieceChangeParent.index + piece.sourceSize.height = Qt.binding(function() { return pieceParent.width*2.5 }) + var coord = piece.parent.mapFromItem(pieceChangeParent.parent, pieceChangeParent.x + pieceChangeParent.width/2 - + piece.width/2, pieceChangeParent.y + pieceChangeParent.height/2 - piece.height/2) + piece.moveX = coord.x + piece.moveY = coord.y + pieceAnimation.start() + } } diff --git a/src/activities/nine_men_morris/nine_men_morris.js b/src/activities/nine_men_morris/nine_men_morris.js index c5bef1c4a..bd7188de1 100644 --- a/src/activities/nine_men_morris/nine_men_morris.js +++ b/src/activities/nine_men_morris/nine_men_morris.js @@ -1,240 +1,642 @@ /* GCompris - nine_men_morris.js * * Copyright (C) 2016 Pulkit Gupta * * Authors: * Pulkit Gupta * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, see . */ .pragma library .import QtQuick 2.0 as Quick var currentLevel = 0 var numberOfLevel = 5 var items var url = "qrc:/gcompris/src/activities/nine_men_morris/resource/" -//var currentPiece +var currentPiece var currentPlayer var currentLocation var twoPlayer var track = [] //For tracking moves var stopper //For stopping game when doing reset +//var dragPoints = [] +//var firstPhase +var currentRepeater +var otherRepeater +//var items.pieceBeingRemoved +var numberOfFirstPieces +var numberOfSecondPieces +var chance function start(items_, twoPlayer_) { items = items_ currentLevel = 1 currentPlayer = 1 items.player1_score = 0 items.player2_score = 0 twoPlayer = twoPlayer_ numberOfLevel = 6 - items.playSecond = 0 + items.playSecond = false + + // First time Drag point creation + var dragPointComponent = Qt.createComponent("qrc:/gcompris/src/activities/nine_men_morris/DragPoint.qml") + if (dragPointComponent.status == dragPointComponent.Error) { + // Error Handling + console.log("Error loading component:", dragPointComponent.errorString()); + } + var filename = url + "position.qml" + items.positionSet.source = filename + var positionData = items.positionSet.item + var positionDataLength = positionData.positions.length + for (var i = 0 ; i < positionDataLength ; i++) { + /*dragPoints[i] = dragPointComponent.createObject( + items.board, { + "posX": positionData.positions[i].x, + "posY": positionData.positions[i].y, + "index": i + });*/ + items.dragPointsModel.append( { + "posX": positionData.positions[i].x, + "posY": positionData.positions[i].y, + "myIndex": i + } ) + } + + // For assigning left and right piece + for (var i = 0 ; i < 24 ; i++) { + if (i % 3) + items.dragPoints.itemAt(i).leftPiece = items.dragPoints.itemAt(i - 1) + else + items.dragPoints.itemAt(i).leftPiece = null + if ((i + 1) % 3) + items.dragPoints.itemAt(i).rightPiece = items.dragPoints.itemAt(i + 1) + else + items.dragPoints.itemAt(i).rightPiece = null + } + + // Start assigning upper and lower piece + items.dragPoints.itemAt(0).upperPiece = items.dragPoints.itemAt(9) + items.dragPoints.itemAt(0).lowerPiece = null + items.dragPoints.itemAt(1).upperPiece = items.dragPoints.itemAt(4) + items.dragPoints.itemAt(1).lowerPiece = null + items.dragPoints.itemAt(2).upperPiece = items.dragPoints.itemAt(14) + items.dragPoints.itemAt(2).lowerPiece = null + items.dragPoints.itemAt(3).upperPiece = items.dragPoints.itemAt(10) + items.dragPoints.itemAt(3).lowerPiece = null + items.dragPoints.itemAt(4).upperPiece = items.dragPoints.itemAt(7) + items.dragPoints.itemAt(4).lowerPiece = items.dragPoints.itemAt(1) + items.dragPoints.itemAt(5).upperPiece = items.dragPoints.itemAt(13) + items.dragPoints.itemAt(5).lowerPiece = null + items.dragPoints.itemAt(6).upperPiece = items.dragPoints.itemAt(11) + items.dragPoints.itemAt(6).lowerPiece = null + items.dragPoints.itemAt(7).upperPiece = null + items.dragPoints.itemAt(7).lowerPiece = items.dragPoints.itemAt(4) + items.dragPoints.itemAt(8).upperPiece = items.dragPoints.itemAt(12) + items.dragPoints.itemAt(8).lowerPiece = null + items.dragPoints.itemAt(9).upperPiece = items.dragPoints.itemAt(21) + items.dragPoints.itemAt(9).lowerPiece = items.dragPoints.itemAt(0) + items.dragPoints.itemAt(10).upperPiece = items.dragPoints.itemAt(18) + items.dragPoints.itemAt(10).lowerPiece = items.dragPoints.itemAt(3) + items.dragPoints.itemAt(11).upperPiece = items.dragPoints.itemAt(15) + items.dragPoints.itemAt(11).lowerPiece = items.dragPoints.itemAt(6) + items.dragPoints.itemAt(12).upperPiece = items.dragPoints.itemAt(17) + items.dragPoints.itemAt(12).lowerPiece = items.dragPoints.itemAt(8) + items.dragPoints.itemAt(13).upperPiece = items.dragPoints.itemAt(20) + items.dragPoints.itemAt(13).lowerPiece = items.dragPoints.itemAt(5) + items.dragPoints.itemAt(14).upperPiece = items.dragPoints.itemAt(23) + items.dragPoints.itemAt(14).lowerPiece = items.dragPoints.itemAt(2) + items.dragPoints.itemAt(15).upperPiece = null + items.dragPoints.itemAt(15).lowerPiece = items.dragPoints.itemAt(11) + items.dragPoints.itemAt(16).upperPiece = items.dragPoints.itemAt(19) + items.dragPoints.itemAt(16).lowerPiece = null + items.dragPoints.itemAt(17).upperPiece = null + items.dragPoints.itemAt(17).lowerPiece = items.dragPoints.itemAt(12) + items.dragPoints.itemAt(18).upperPiece = null + items.dragPoints.itemAt(18).lowerPiece = items.dragPoints.itemAt(10) + items.dragPoints.itemAt(19).upperPiece = items.dragPoints.itemAt(22) + items.dragPoints.itemAt(19).lowerPiece = items.dragPoints.itemAt(16) + items.dragPoints.itemAt(20).upperPiece = null + items.dragPoints.itemAt(20).lowerPiece = items.dragPoints.itemAt(13) + items.dragPoints.itemAt(21).upperPiece = null + items.dragPoints.itemAt(21).lowerPiece = items.dragPoints.itemAt(9) + items.dragPoints.itemAt(22).upperPiece = null + items.dragPoints.itemAt(22).lowerPiece = items.dragPoints.itemAt(19) + items.dragPoints.itemAt(23).upperPiece = null + items.dragPoints.itemAt(23).lowerPiece = items.dragPoints.itemAt(14) + // End assigning upper and lower piece + if (!twoPlayer) tutorial() else initLevel() } function stop() { } function initLevel() { items.bar.level = currentLevel items.counter = 0 items.gameDone = false - items.board.anchors.horizontalCenterOffset = -0.25*items.board.width - items.board.sourceSize.width = 3 * Math.min(items.background.width / 4 , items.background.height / 6) + items.firstPhase = true + items.pieceBeingRemoved = false + numberOfFirstPieces = 0 + numberOfSecondPieces = 0 + items.firstPieceNumberCount = 9 + items.secondPieceNumberCount = 9 + items.instructionTxt = qsTr("Place a Piece") + //items.board.sourceSize.width = 3.5 * Math.min(items.background.width / 4 , items.background.height / 6) + items.board.anchors.horizontalCenterOffset = -0.18 * items.board.width //items.pieces.clear() track = [] /*for(var y = 0; y < items.rows; y++) { for(var x = 0; x < items.columns; x++) { items.pieces.append({'stateTemp': "invisible"}) } }*/ - if (items.playSecond) + + // Clear first and second player pieces, and initialize dragPoints + items.firstPlayerPieces.model.clear() + items.secondPlayerPieces.model.clear() + for (var i = 0 ; i < 24 ; ++i) + items.dragPoints.itemAt(i).state = "AVAILABLE" + + // Create first and second player pieces + for (var i = 0 ; i < 9 ; ++i) { + items.firstPlayerPiecesModel.append({})/* { + //"state": items.playSecond % 2 ? "2": "1", + "myIndex": i + /*"sourceSize.height": Math.min(firstInitial.height*0.8,firstInitial.width*0.4), + "x": firstInitial.width*0.06, + "anchors.verticalCenter": firstInitial.verticalCenter + })*/ + items.secondPlayerPiecesModel.append({})/* { + //"state": items.playSecond % 2 ? "2": "1", + "myIndex": i + /*"sourceSize.height": Math.min(firstInitial.height*0.8,firstInitial.width*0.4), + "x": firstInitial.width*0.06, + "anchors.verticalCenter": firstInitial.verticalCenter + })*/ + } + if (items.playSecond) { + currentRepeater = items.firstPlayerPieces + otherRepeater = items.secondPlayerPieces initiatePlayer2() - else - initiatePlayer1() + } + else { + currentRepeater = items.firstPlayerPieces + otherRepeater = items.secondPlayerPieces + initiatePlayer1() + } stopper = 0 if (items.playSecond) changePlayToSecond() } function tutorial() { items.isTutorial = true /* items.board.anchors.horizontalCenterOffset = -0.25*items.board.width //items.board.anchors.verticalCenterOffset = 0.25*items.board.height items.board.anchors.verticalCenter = undefined items.board.anchors.bottom = items.bar.top items.board.anchors.bottomMargin = 20 items.board.sourceSize.width = 2 * Math.min(items.background.width / 4 , items.background.height / 6) */ setTutorial(1) } function setTutorial(tutNum) { //var src = "tutorial" + tutNum + ".svg" //items.tutorialImage = url + src if (tutNum == 1) { items.tutorialTxt = qsTr("You and Tux starts with 9 pieces each, and take turns to place " + "your pieces on to the empty spots (by clicking on the spots) on the board. ") } else if (tutNum == 2) { items.tutorialTxt = qsTr("If you form a mill (line of 3 pieces), then select a piece of Tux, and remove " + "it. Pieces of formed mill can not be removed unless no other pieces are left on board.") } else if (tutNum == 3) { items.tutorialTxt = qsTr("After all the pieces are placed, you and Tux will take turns to move them. " + "Click on one of your pieces, and then on the adjacent empty spot to move " + "it there. Green color spot indicates where you can move.") } else if (tutNum == 4) { items.tutorialTxt = qsTr("If you are left with 3 pieces, your pieces will gain the ability to 'fly' " + "and can be moved to any vacant spot on the board.") } else if (tutNum == 5) { items.tutorialTxt = qsTr("If you immobilize the computer or leave it with less than 3 pieces, then " + "you win the game.") } /* else { items.isTutorial = false initLevel() }*/ } function tutorialNext() { setTutorial(++items.tutNum) } function tutorialPrevious() { setTutorial(--items.tutNum) } function tutorialSkip() { items.isTutorial = false initLevel() } function nextLevel() { if(numberOfLevel <= ++currentLevel ) { currentLevel = 1 } reset(); } function previousLevel() { if(--currentLevel < 1) { currentLevel = numberOfLevel - 1 } reset(); } function reset() { stopper = 1 stopAnimations() items.player1image.rotation = 0 items.player2image.rotation = 0 if (items.playSecond) - items.playSecond = 0 + items.playSecond = false else - items.playSecond = 1 + items.playSecond = true initLevel() } function stopAnimations() { items.player1turn.stop() items.player2turn.stop() items.player1shrink.stop() items.player2shrink.stop() items.rotateKonqi.stop() items.rotateTux.stop() } //Initial values at the start of game when its player 1 turn function initiatePlayer1() { items.changeScalePlayer1.scale = 1.4 items.changeScalePlayer2.scale = 1.0 items.player1.state = "first" items.player2.state = "second" items.rotateKonqi.start() } //Initial values at the start of game when its player 1 turn function initiatePlayer2() { items.changeScalePlayer1.scale = 1.0 items.changeScalePlayer2.scale = 1.4 items.player1.state = "second" items.player2.state = "first" items.rotateTux.start() } //Change scale of score boxes according to turns function changeScale() { if (items.playSecond) { if (items.counter%2 == 0) items.player2turn.start() else items.player1turn.start() } else { if (items.counter%2 == 0) items.player1turn.start() else items.player2turn.start() } } function changePlayToSecond() { if (items.playSecond == 0) { - items.playSecond = 1 + items.playSecond = true reset() return 0 } if (!twoPlayer) { } } //Changing play to second in single player mode function changePlayToFirst() { - items.playSecond = 0 + items.playSecond = false reset() } //Create the piece at given position -function handleCreate(parent) { - - items.firstInitial.visible = false - items.secondInitial.visible = false +function handleCreate(index) { + currentPiece = currentRepeater.itemAt(items.counter/2) + //items.dragPoints.itemAt(index).state = currentPiece.state + if(currentPiece.state == "2") {// && !items.playSecond || currentPiece.state == "1" && !items.playSecond) { + items.secondPieceNumberCount-- + //items.dragPoints.itemAt(index).state = "2" + numberOfSecondPieces++ + } + else { + items.firstPieceNumberCount-- + //items.dragPoints.itemAt(index).state = "1" + numberOfFirstPieces++ + } + //dragPoints[index].state = "UNAVAILABLE" + //piece.itemAt(items.counter/2).parent = dragPoints[index] + //piece.itemAt(items.counter/2).pieceParent = dragPoints[index] + currentPiece.move(items.dragPoints.itemAt(index)) +} + +function secondPhase() { + //items.firstInitialVisible = false + //items.secondInitialVisible = false + items.firstPhase = false items.board.anchors.horizontalCenterOffset = 0 //items.board.anchors.verticalCenterOffset = -10 - items.board.sourceSize.width = 3.4 * Math.min(items.background.width / 4 , items.background.height / 6) - + //items.board.sourceSize.width = 3.4 * Math.min(items.background.width / 4 , items.background.height / 6) + //items.board.sourceSize.width = Math.min(items.background.height - 1.4*items.player1.height - 1.2*items.bar.height, + //0.9*items.background.width) + for (var i = 0 ; i < 24 ; ++i) { + if (items.dragPoints.itemAt(i).state != "1" && items.dragPoints.itemAt(i).state != "2") + items.dragPoints.itemAt(i).state = "EMPTY" + } + + items.instructionTxt = qsTr("Move a Piece") +} + +function pieceSelected(pieceIndex) { + + currentPiece.isSelected = false + currentPiece = currentRepeater.itemAt(pieceIndex) + currentPiece.isSelected = true + + if ((currentPiece.state == "1" && numberOfFirstPieces > 4) || (currentPiece.state == "2" && numberOfSecondPieces > 4)) { + // Initialize values + //console.log("If") + for (var i = 0 ; i < 24 ; ++i) { + if (items.dragPoints.itemAt(i).state == "EMPTY" || items.dragPoints.itemAt(i).state == "AVAILABLE") + items.dragPoints.itemAt(i).state = "UNAVAILABLE" + } + + // Now assign values + var index = currentRepeater.itemAt(pieceIndex).parentIndex // Drag Point index + + if (items.dragPoints.itemAt(index).leftPiece) { + if (items.dragPoints.itemAt(index).leftPiece.state == "UNAVAILABLE") + items.dragPoints.itemAt(index).leftPiece.state = "AVAILABLE" + } + if (items.dragPoints.itemAt(index).upperPiece) { + if (items.dragPoints.itemAt(index).upperPiece.state == "UNAVAILABLE") + items.dragPoints.itemAt(index).upperPiece.state = "AVAILABLE" + } + if (items.dragPoints.itemAt(index).rightPiece) { + if (items.dragPoints.itemAt(index).rightPiece.state == "UNAVAILABLE") + items.dragPoints.itemAt(index).rightPiece.state = "AVAILABLE" + } + if (items.dragPoints.itemAt(index).lowerPiece) { + if (items.dragPoints.itemAt(index).lowerPiece.state == "UNAVAILABLE") + items.dragPoints.itemAt(index).lowerPiece.state = "AVAILABLE" + } + } + else { + //console.log("else") + for (var i = 0 ; i < 24 ; ++i) { + if (items.dragPoints.itemAt(i).state == "EMPTY" || items.dragPoints.itemAt(i).state == "UNAVAILABLE") + items.dragPoints.itemAt(i).state = "AVAILABLE" + } + } +} + +function movePiece(index) { + currentPiece.parent.state = "EMPTY" + currentPiece.isSelected = false + for (var i = 0 ; i < 24 ; ++i) { + if (items.dragPoints.itemAt(i).state != "1" && items.dragPoints.itemAt(i).state != "2") + items.dragPoints.itemAt(i).state = "EMPTY" + } + currentPiece.move(items.dragPoints.itemAt(index)) + //currentPiece.parent.state = currentPiece.state } function setmove() { } function shouldComputerPlay() { } + +// continueGame() called by Piece when its animation stops and checkMill(piece) is false or +// called after removePiece(index) has removed a piece +function continueGame() { + items.counter++ + //console.log(items.counter) + if(items.counter%2) { + currentRepeater = items.secondPlayerPieces + otherRepeater = items.firstPlayerPieces + } + else { + currentRepeater = items.firstPlayerPieces + otherRepeater = items.secondPlayerPieces + } + if(items.counter == 18) + secondPhase() + changeScale() +} + +function checkMill(piece) { + var index = piece.parentIndex + var state = piece.state + //var millFormed = false + /*console.log(index) + //console.log(index, state, dragPoints[1].state, dragPoints[2].state) + if(!millFormed && index == 0) { + if (dragPoints[1].state == dragPoints[2].state && dragPoints[2].state == state) + //console.log("mill") + }*/ + if (items.dragPoints.itemAt(index).leftPiece) { + if (items.dragPoints.itemAt(index).leftPiece.leftPiece) { + if (piece.state == items.dragPoints.itemAt(index).leftPiece.state && + piece.state == items.dragPoints.itemAt(index).leftPiece.leftPiece.state) + return true; + } + } + if (items.dragPoints.itemAt(index).upperPiece) { + if (items.dragPoints.itemAt(index).upperPiece.upperPiece) { + if (piece.state == items.dragPoints.itemAt(index).upperPiece.state && + piece.state == items.dragPoints.itemAt(index).upperPiece.upperPiece.state) + return true; + } + } + if (items.dragPoints.itemAt(index).rightPiece) { + if (items.dragPoints.itemAt(index).rightPiece.rightPiece) { + if (piece.state == items.dragPoints.itemAt(index).rightPiece.state && + piece.state == items.dragPoints.itemAt(index).rightPiece.rightPiece.state) + return true; + } + } + if (items.dragPoints.itemAt(index).lowerPiece) { + if (items.dragPoints.itemAt(index).lowerPiece.lowerPiece) { + if (piece.state == items.dragPoints.itemAt(index).lowerPiece.state && + piece.state == items.dragPoints.itemAt(index).lowerPiece.lowerPiece.state) + return true; + } + } + if (items.dragPoints.itemAt(index).lowerPiece) { + if (items.dragPoints.itemAt(index).upperPiece) { + if (piece.state == items.dragPoints.itemAt(index).lowerPiece.state && + piece.state == items.dragPoints.itemAt(index).upperPiece.state) + return true; + } + } + if (items.dragPoints.itemAt(index).leftPiece) { + if (items.dragPoints.itemAt(index).rightPiece) { + if (piece.state == items.dragPoints.itemAt(index).leftPiece.state && + piece.state == items.dragPoints.itemAt(index).rightPiece.state) + return true; + } + } + + /*switch(index) { + case 0: + case 21: + if (state == items.dragPoints.itemAt(index + 1).state && state == items.dragPoints.itemAt(index + 2).state) + return true + break; + case 1: + //code block + break; + //default: + //default code block + }*/ +} + +// UpdateRemovablePiece called by Piece when its animation stops and checkMill(piece) is true +function UpdateRemovablePiece() { + items.pieceBeingRemoved = true + var foundOne = false + for(var i = 0 ; i < 9 ; ++i) { + //console.log(i) + if (otherRepeater.itemAt(i).parentIndex != -1) { + if (!checkMill(otherRepeater.itemAt(i)) && otherRepeater.itemAt(i).visible == true) { + foundOne = true + otherRepeater.itemAt(i).canBeRemoved = true // Mark pieces of other player for removal + } + } + } + if (!foundOne) { + for(var i = 0 ; i < 9 ; ++i) { + if ((otherRepeater.itemAt(i).parentIndex != -1) && (otherRepeater.itemAt(i).visible == true)) + otherRepeater.itemAt(i).canBeRemoved = true + } + } + items.instructionTxt = qsTr("Remove a Piece") +} + +// removePiece(index) called by Piece when items.pieceBeingRemoved is true +function removePiece(index) { + //console.log(index) + otherRepeater.itemAt(index).visible = false + otherRepeater.itemAt(index).parent.state = items.firstPhase ? "AVAILABLE" : "EMPTY" + for(var i = 0 ; i < 9 ; ++i) + otherRepeater.itemAt(i).canBeRemoved = false + items.pieceBeingRemoved = false + + // Decrease number of pieces of other player by 1 + if (items.counter%2) + numberOfFirstPieces-- + else + numberOfSecondPieces-- + if (items.firstPhase) { + items.instructionTxt = items.firstPhase ? qsTr("Place a Piece") : qsTr("Move a Piece") + continueGame() + } + else + checkGameWon() +} + +function checkGameWon() { + + // Check if other player can mover or not + var flag = true; + for (var i = 0 ; i < 9 ; ++i) { + //console.log("otherRepeater.itemAt(i).visible",otherRepeater.itemAt(i).visible) + if (otherRepeater.itemAt(i).visible) { + //console.log("left",otherRepeater.itemAt(i).parent.leftPiece ? otherRepeater.itemAt(i).parent.leftPiece.state : "Null") + //console.log("right",otherRepeater.itemAt(i).parent.rightPiece ? otherRepeater.itemAt(i).parent.rightPiece.state : "Null") + //console.log("upper",otherRepeater.itemAt(i).parent.upperPiece ? otherRepeater.itemAt(i).parent.upperPiece.state : "Null") + //console.log("lower",otherRepeater.itemAt(i).parent.lowerPiece ? otherRepeater.itemAt(i).parent.lowerPiece.state : "Null") + if ((otherRepeater.itemAt(i).parent.leftPiece && + otherRepeater.itemAt(i).parent.leftPiece.state == "EMPTY") || + (otherRepeater.itemAt(i).parent.rightPiece && + otherRepeater.itemAt(i).parent.rightPiece.state == "EMPTY") || + (otherRepeater.itemAt(i).parent.upperPiece && + otherRepeater.itemAt(i).parent.upperPiece.state == "EMPTY") || + (otherRepeater.itemAt(i).parent.lowerPiece && + otherRepeater.itemAt(i).parent.lowerPiece.state == "EMPTY")) { + flag = false + break + } + } + } + //console.log("flag", flag) + //console.log("currentPiece.state",currentPiece.state) + if (((numberOfSecondPieces < 3 && !items.playSecond) || (numberOfFirstPieces < 3 && items.playSecond)) || + (flag && ((currentPiece.state == "1" && !items.playSecond) || (currentPiece.state == "2" && items.playSecond)))) { + items.gameDone = true + items.player1_score++ + items.player1.state = "win" + items.instructionTxt = "Congratulation" + items.bonus.good("flower") + if(twoPlayer) { + items.instructionTxt = "Congratulation Player 1" + items.bonus.isWin = false + } + } + else if (((numberOfFirstPieces < 3 && !items.playSecond) || (numberOfSecondPieces < 3 && items.playSecond)) || + (flag && ((currentPiece.state == "2" && !items.playSecond) || (currentPiece.state == "1" && items.playSecond)))) { + items.gameDone = true + items.player2_score++ + items.player2.state = "win" + if(twoPlayer) { + items.bonus.good("flower") + items.instructionTxt = "Congratulation Player 2" + items.bonus.isWin = false + } + else { + items.instructionTxt = "Try Again" + items.bonus.bad("tux") + } + } + else { + // Continue the game + items.instructionTxt = items.firstPhase ? qsTr("Place a Piece") : qsTr("Move a Piece") + continueGame() + } +} diff --git a/src/activities/nine_men_morris/nine_men_morris.svg b/src/activities/nine_men_morris/nine_men_morris.svg index 87f525501..5f72fa788 100644 --- a/src/activities/nine_men_morris/nine_men_morris.svg +++ b/src/activities/nine_men_morris/nine_men_morris.svg @@ -1,976 +1,1243 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - + transform="matrix(0.34071359,0,0,0.34071359,557.20579,191.03282)" + id="g4863-4-1"> + style="opacity:0.972;fill:#ffffff;fill-opacity:1;fill-rule:evenodd;stroke:#000000;stroke-width:0.19006631;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:3.54999995;stroke-dasharray:none;stroke-opacity:1" + id="path3338-1-36-5-8" + cx="62.756008" + cy="187.87152" + r="60.469025" /> - - + style="opacity:0.972;fill:url(#radialGradient4847-5-6);fill-opacity:1;stroke:#000000;stroke-width:0.19006631;stroke-miterlimit:3.54999995;stroke-dasharray:none;stroke-opacity:1" + id="path4839-8-0" + cx="62.386898" + cy="187.69385" + r="51.94767" /> + + + style="opacity:0.972;fill:#ffffff;fill-opacity:1;fill-rule:evenodd;stroke:#000000;stroke-width:0.19006631;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:3.54999995;stroke-dasharray:none;stroke-opacity:1" + id="path3338-1-36-5-5" + cx="62.756008" + cy="187.87152" + r="60.469025" /> + style="opacity:0.972;fill:url(#radialGradient4847-5-5);fill-opacity:1;stroke:#000000;stroke-width:0.19006631;stroke-miterlimit:3.54999995;stroke-dasharray:none;stroke-opacity:1" + id="path4839-8-9" + cx="62.386898" + cy="187.69385" + r="51.94767" /> + + - - - - - - - - - - - - - - - + + + + + + + - - - - - - - - - - - - - + transform="matrix(0.31815013,0,0,0.31815013,428.779,65.163638)" + id="g4234-0"> + id="path3338-7" + style="opacity:0.73699999;fill:url(#radialGradient4214-1);fill-opacity:1;fill-rule:evenodd;stroke:#000000;stroke-width:0.18812783px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1" /> + id="path3338-1-5" + style="opacity:1;fill:url(#radialGradient4232-6);fill-opacity:1;fill-rule:evenodd;stroke:#000000;stroke-width:0.18812783px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1" /> + id="path4505-8" + style="opacity:1;fill:url(#radialGradient4513-4);fill-opacity:1;stroke:#000000;stroke-width:0.01939472;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1;filter:url(#filter4230-4)" /> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + id="g4863-4" + transform="matrix(0.34071359,0,0,0.34071359,495.46553,288.68542)"> + r="60.469025" + cy="187.87152" + cx="62.756008" + id="path3338-1-36-5" + style="opacity:0.972;fill:#ffffff;fill-opacity:1;fill-rule:evenodd;stroke:#000000;stroke-width:0.19006631;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:3.54999995;stroke-dasharray:none;stroke-opacity:1" /> - + r="51.94767" + cy="187.69385" + cx="62.386898" + id="path4839-8" + style="opacity:0.972;fill:url(#radialGradient4847-5);fill-opacity:1;stroke:#000000;stroke-width:0.19006631;stroke-miterlimit:3.54999995;stroke-dasharray:none;stroke-opacity:1" /> + + + - - - - + inkscape:label="Calque 1" + id="layer1-3" + transform="matrix(0.2704163,0,0,0.2704163,-48.895105,-95.843867)" + style="opacity:1"> + + + + + + + + + + + + + + + + + + + + + + + + + + + + id="g4234" + transform="matrix(0.23170302,-0.06208464,0.06208464,0.23170302,23.721078,21.960702)"> + id="path3338-1-3" + cx="60.58815" + cy="187.32954" /> + cy="189.97308" + r="59.932152" /> + cy="187.32954" + r="59.932152" /> + cy="158.18535" + rx="46.414616" + ry="25.63587" /> + + + + transform="matrix(0.31815013,0,0,0.31815013,429.14373,290.2838)" + id="g4234-0-5"> + id="path3338-7-5" + style="opacity:0.73699999;fill:url(#radialGradient4214-1-29);fill-opacity:1;fill-rule:evenodd;stroke:#000000;stroke-width:0.18812783px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1" /> + id="path3338-1-5-2" + style="opacity:1;fill:url(#radialGradient4232-6-7);fill-opacity:1;fill-rule:evenodd;stroke:#000000;stroke-width:0.18812783px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1" /> + id="path4505-8-9" + style="opacity:1;fill:url(#radialGradient4513-4-2);fill-opacity:1;stroke:#000000;stroke-width:0.01939472;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1;filter:url(#filter4230-4-32)" /> - - - - image/svg+xml Openclipart 2009-05-28T22:36:41 The board setout of Nine Men's Morris. https://openclipart.org/detail/26344/nine-mens-morris-by-chovynz chovynz black and white game line art morris nine diff --git a/src/activities/nine_men_morris/resource/black_piece.svg b/src/activities/nine_men_morris/resource/black_piece.svg index 2e2f4b536..16358218e 100644 --- a/src/activities/nine_men_morris/resource/black_piece.svg +++ b/src/activities/nine_men_morris/resource/black_piece.svg @@ -1,234 +1,172 @@ - - - - - - - - + gradientTransform="matrix(0.99178056,0,0,0.99178056,197.13508,-77.722239)" /> - - + gradientTransform="matrix(0.99173517,-0.00948721,0.0087356,0.91316033,144.4005,39.72234)" /> + fit-margin-top="5" + fit-margin-left="5" + fit-margin-right="5" + fit-margin-bottom="5" /> image/svg+xml - + - - - - - - - - - - - + transform="translate(-14.640589,-9.8598672)"> + + + + diff --git a/src/activities/nine_men_morris/resource/board.svg b/src/activities/nine_men_morris/resource/board.svg index b117727e8..7aec692d4 100644 --- a/src/activities/nine_men_morris/resource/board.svg +++ b/src/activities/nine_men_morris/resource/board.svg @@ -1,274 +1,154 @@ - - - - - - - - - - - - - - - - - - - - image/svg+xml Openclipart Nine Men's Morris 2009-05-28T22:36:41 The board setout of Nine Men's Morris. https://openclipart.org/detail/26344/nine-mens-morris-by-chovynz chovynz black and white game line art morris nine diff --git a/src/activities/nine_men_morris/resource/position.qml b/src/activities/nine_men_morris/resource/position.qml new file mode 100644 index 000000000..07a09162f --- /dev/null +++ b/src/activities/nine_men_morris/resource/position.qml @@ -0,0 +1,122 @@ +/* GCompris + * + * Copyright (C) 2016 Pulkit Gupta + * + * Authors: + * Pulkit Gupta (Qt Quick port) + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, see . + */ +import QtQuick 2.0 + +QtObject { + property variant positions : [ + { + "x" : "0.05", + "y" : "0.948", + }, + { + "x" : "0.500", + "y" : "0.948", + }, + { + "x" : "0.95", + "y" : "0.948", + }, + { + "x" : "0.19", + "y" : "0.814", + }, + { + "x" : "0.500", + "y" : "0.814", + }, + { + "x" : "0.81", + "y" : "0.814", + }, + { + "x" : "0.313", + "y" : "0.687", + }, + { + "x" : "0.500", + "y" : "0.687", + }, + { + "x" : "0.689", + "y" : "0.687", + }, + { + "x" : "0.05", + "y" : "0.499", + }, + { + "x" : "0.19", + "y" : "0.499", + }, + { + "x" : "0.313", + "y" : "0.499", + }, + { + "x" : "0.689", + "y" : "0.499", + }, + { + "x" : "0.81", + "y" : "0.499", + }, + { + "x" : "0.95", + "y" : "0.499", + }, + { + "x" : "0.313", + "y" : "0.311", + }, + { + "x" : "0.500", + "y" : "0.311", + }, + { + "x" : "0.689", + "y" : "0.311", + }, + { + "x" : "0.19", + "y" : "0.188", + }, + { + "x" : "0.500", + "y" : "0.188", + }, + { + "x" : "0.81", + "y" : "0.188", + }, + { + "x" : "0.05", + "y" : "0.054", + }, + { + "x" : "0.500", + "y" : "0.054", + }, + { + "x" : "0.95", + "y" : "0.054", + } + ] +} diff --git a/src/activities/nine_men_morris/resource/tutorial1.svg b/src/activities/nine_men_morris/resource/tutorial1.svg index e7d01b219..a1d11083f 100644 --- a/src/activities/nine_men_morris/resource/tutorial1.svg +++ b/src/activities/nine_men_morris/resource/tutorial1.svg @@ -1,533 +1,553 @@ X9 X9 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml Openclipart - + 2009-05-28T22:36:41 The board setout of Nine Men's Morris. https://openclipart.org/detail/26344/nine-mens-morris-by-chovynz chovynz black and white game line art morris nine diff --git a/src/activities/nine_men_morris_2players/ActivityInfo.qml b/src/activities/nine_men_morris_2players/ActivityInfo.qml new file mode 100644 index 000000000..80887f389 --- /dev/null +++ b/src/activities/nine_men_morris_2players/ActivityInfo.qml @@ -0,0 +1,35 @@ +/* GCompris - ActivityInfo.qml + * + * Copyright (C) 2016 Pulkit Gupta + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, see . + */ +import GCompris 1.0 + +ActivityInfo { + name: "nine_men_morris_2players/NineMenMorris2players.qml" + difficulty: 2 + icon: "nine_men_morris_2players/nine_men_morris_2players.svg" + author: "Pulkit Gupta <pulkitnsit@gmail.com>" + demo: true + title: "Nine men's morris (with a friend)" + description: "Reduce the opponent to two pieces, or by leaving him without a legal move." + //intro: "put here in comment the text for the intro voice" + goal: "" + prerequisite: "" + manual: "Play with a friend. First take turns to place nine pieces, and then take turns to move pieces" + credit: "" + section: "strategy" + createdInVersion: 6000 +} diff --git a/src/activities/nine_men_morris_2players/CMakeLists.txt b/src/activities/nine_men_morris_2players/CMakeLists.txt new file mode 100644 index 000000000..f46695c7a --- /dev/null +++ b/src/activities/nine_men_morris_2players/CMakeLists.txt @@ -0,0 +1 @@ +GCOMPRIS_ADD_RCC(activities/nine_men_morris_2players *.qml *.svg *.js resource/*) diff --git a/src/activities/nine_men_morris/Piece.qml b/src/activities/nine_men_morris_2players/NineMenMorris2players.qml similarity index 54% copy from src/activities/nine_men_morris/Piece.qml copy to src/activities/nine_men_morris_2players/NineMenMorris2players.qml index b624e08d7..07e1e91a4 100644 --- a/src/activities/nine_men_morris/Piece.qml +++ b/src/activities/nine_men_morris_2players/NineMenMorris2players.qml @@ -1,56 +1,28 @@ -/* GCompris - Piece.qml +/* GCompris - NineMenMorris2players.qml * * Copyright (C) 2016 Pulkit Gupta * * Authors: * Pulkit Gupta * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, see . - */ +*/ import QtQuick 2.1 import "../../core" -import "nine_men_morris.js" as Activity +import "../nine_men_morris" -import GCompris 1.0 - -Image { - id: piece - - opacity: 1.0 - - states: [ - State { - name: "invisible" - PropertyChanges { - target: piece - opacity: 0 - } - }, - State { - name: "1" // Player 1 - PropertyChanges{ - target: piece - source: Activity.url + "white_piece.svg" - } - }, - State { - name: "2" // Player 2 - PropertyChanges { - target: piece - source: Activity.url + "black_piece.svg" - } - } - ] +NineMenMorris { + twoPlayer: true } diff --git a/src/activities/nine_men_morris/nine_men_morris.svg b/src/activities/nine_men_morris_2players/nine_men_morris_2players.svg similarity index 100% copy from src/activities/nine_men_morris/nine_men_morris.svg copy to src/activities/nine_men_morris_2players/nine_men_morris_2players.svg