Skip to content

Commit 31e760a

Browse files
committed
Final
1 parent c69a86f commit 31e760a

File tree

4 files changed

+88
-3
lines changed

4 files changed

+88
-3
lines changed

src/main/java/FileManager.java

+42-1
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,12 @@ boolean saveCustomBoard(int[][] board) throws IOException {
8787
boolean couldNotCheck5=false;
8888
boolean movable8=true;
8989
boolean couldNotCheck8=false;
90-
90+
boolean movable7=true;
91+
boolean couldNotCheck7=false;
92+
boolean movable9=true;
93+
boolean couldNotCheck9=false;
94+
boolean movable10=true;
95+
boolean couldNotCheck10=false;
9196
for(ArrayList<Integer> all:friends)
9297
{
9398
System.out.println(all);
@@ -140,6 +145,30 @@ boolean saveCustomBoard(int[][] board) throws IOException {
140145
}
141146
else
142147
couldNotCheck8=true;
148+
149+
150+
151+
if(((all.get(1)+2)>11)&&((all.get(2)+2)>22)){
152+
if(board[all.get(1)+2][all.get(2)+2]!=-1)
153+
movable7=false;
154+
}
155+
else
156+
couldNotCheck7=true;
157+
158+
if(((all.get(1)-1)>11)&&((all.get(2)-1)>22)){
159+
if(board[all.get(1)-1][all.get(2)-1]!=-1)
160+
movable9=false;
161+
}
162+
else
163+
couldNotCheck9=true;
164+
if(((all.get(1)+1)>11)&&((all.get(2)+1)>22)){
165+
if(board[all.get(1)+1][all.get(2)+1]!=-1)
166+
movable10=false;
167+
}
168+
else
169+
couldNotCheck10=true;
170+
171+
143172
}
144173
System.out.println("CurrentId:" +currentID);
145174
for(ArrayList<Integer> all:friends) {
@@ -169,6 +198,18 @@ else if(movable8&&(!couldNotCheck8))
169198
{
170199
board[all.get(1)-2][all.get(2)-2]=currentID;
171200
}
201+
else if(movable7&&(!couldNotCheck7))
202+
{
203+
board[all.get(1)+2][all.get(2)+2]=currentID;
204+
}
205+
else if(movable9&&(!couldNotCheck9))
206+
{
207+
board[all.get(1)-1][all.get(2)-1]=currentID;
208+
}
209+
else if(movable10&&(!couldNotCheck10))
210+
{
211+
board[all.get(1)+1][all.get(2)+1]=currentID;
212+
}
172213
else
173214
System.out.println("OLMADI");
174215
}

src/main/java/GameController.java

+3-1
Original file line numberDiff line numberDiff line change
@@ -442,8 +442,10 @@ public void playPause(MouseEvent e) {
442442
@Override
443443
public void handle(KeyEvent event) {
444444
preview.setPentomino(pentominoTransform(event));
445-
if(game instanceof SinglePlayerGame){
445+
if(game instanceof SinglePlayerGame &&((SinglePlayerGame) game).getGameScore() >= 10 && event.getCode() == KeyCode.H){
446+
((SinglePlayerGame) game).getPlayer().setHighScore(((SinglePlayerGame) game).getPlayer().getHighScore() - 10);
446447
generateHint(event);
448+
playerLabel.setText(((SinglePlayerGame) game).getPlayer().getPlayerName() + " " + ((SinglePlayerGame) game).getPlayer().getHighScore());
447449
}
448450
event.consume();
449451
}

src/main/java/customSingleController.java

+42
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import javafx.event.EventHandler;
12
import javafx.fxml.FXML;
23
import javafx.fxml.FXMLLoader;
34
import javafx.geometry.Rectangle2D;
@@ -6,6 +7,7 @@
67
import javafx.scene.layout.AnchorPane;
78
import javafx.stage.Screen;
89
import javafx.stage.Stage;
10+
import kataminoDragCell.KataminoDragCell;
911

1012
import java.io.IOException;
1113
import java.net.URL;
@@ -16,6 +18,46 @@ public class customSingleController extends SinglePlayerGameController {
1618
public void initialize(URL location, ResourceBundle resources) {
1719
super.initialize(location,resources);
1820
levelButton.setButtonName("Boards");
21+
EventHandler eventHandler = new EventHandler<MouseEvent>() {
22+
@Override
23+
public void handle(MouseEvent event) {
24+
if (gridStack.isVisible()) {
25+
KataminoDragCell[][] temp= new KataminoDragCell[11][22];
26+
try {
27+
int rowNode = 0;
28+
int colNode = 0;
29+
for (Node node : gameTilePane.getChildren()) {
30+
if (node instanceof KataminoDragCell) {
31+
if (node.getBoundsInParent().contains(event.getX(), event.getY())) {
32+
Integer[] location = findLocationTilePane(node, gameTilePane);
33+
rowNode = location[0];
34+
colNode = location[1];
35+
}
36+
}
37+
}
38+
for (int o = 0; o < 11; o++)
39+
{
40+
for (int k = 0; k < 22; k++){
41+
temp[o][k]=(KataminoDragCell) gameTilePane.getChildren().get(o * 22 + k);
42+
}
43+
}
44+
game.getGameBoard().setGrid(temp);
45+
if(((SinglePlayerGame)game).getPlayer() != null&&((((SinglePlayerGame)game).getPlayer().getAccessibleLevel())==(((SinglePlayerGame)game).getCurrentLevel()) ))
46+
( (SinglePlayerGame)game).savePlayerBoard();
47+
gridStack.setVisible(clashCheck(rowNode, colNode));
48+
} catch (Exception e) {
49+
System.out.println(e);
50+
}
51+
52+
if(isFull()){
53+
stopwatchLabel.setText("You Won!!");
54+
pauseGame();
55+
}
56+
}
57+
}
58+
};
59+
gameTilePane.setOnMouseReleased(eventHandler);
60+
gridStack.setOnMouseReleased(eventHandler);
1961
}
2062

2163
@Override

src/players.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
[{"playerName":"aa","highScore":198,"accessibleLevel":3,"latestBoard":[[1,-1,-1,2,2,2,-1,-1,3,-1,3,-1,-1,-1,5,-1,-1,-1,10,10,10,10],[1,-1,-1,2,2,-1,-1,-1,3,3,3,-1,-1,5,5,5,-1,-1,-1,10,-1,-1],[1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,5,-1,-1,-1,-1,-1,-1,-1],[1,1,-1,-1,-1,0,0,0,0,0,0,0,0,0,0,0,0,-1,11,11,-1,-1],[-1,-1,-1,-1,-1,0,0,0,0,0,0,0,0,0,0,0,0,-1,11,-1,-1,-1],[4,-1,-1,-1,-1,0,0,0,0,0,0,0,0,0,0,0,0,11,11,-1,12,-1],[4,-1,-1,-1,-1,0,0,0,0,0,0,0,0,0,0,0,0,-1,-1,-1,12,-1],[4,4,-1,-1,-1,0,0,0,0,0,0,0,0,0,0,0,0,-1,12,12,12,-1],[-1,4,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,8,8,-1,-1,-1,9,9,-1],[-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,8,8,-1,-1,-1,9,9,-1,-1],[-1,6,6,6,6,6,-1,-1,-1,-1,-1,-1,-1,8,-1,-1,-1,-1,-1,9,-1,-1]],"latestTime":2},{"playerName":"t","highScore":99,"accessibleLevel":2,"latestBoard":[[-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2],[-2,-2,-2,-2,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-2,-2,-2,-2,-2],[-2,-2,-2,-2,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-2,-2,-2,-2,-2],[-2,-2,-2,-2,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-2,-2,-2,-2,-2],[-2,-2,-2,-2,-1,-1,-1,-1,6,6,6,-1,-1,-1,-1,-1,-1,-2,-2,-2,-2,-2],[-2,-2,-2,-2,-1,-1,-1,-1,6,-1,-1,-1,-1,-1,-1,-1,-1,-2,-2,-2,-2,-2],[-2,-2,-2,-2,-1,-1,-1,-1,6,-1,-1,-1,0,-1,-1,-1,-1,-2,-2,-2,-2,-2],[-2,-2,-2,-2,-1,-1,-1,-1,-1,-1,-1,-1,0,-1,-1,-1,-1,-2,-2,-2,-2,-2],[-2,-2,-2,-2,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-2,-2,-2,-2,-2],[-2,-2,-2,-2,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-2,-2,-2,-2,-2],[-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2]],"latestTime":127},{"playerName":"yepyeni","highScore":198,"accessibleLevel":3,"latestBoard":[[1,-1,-1,2,2,2,-1,-1,3,3,-1,-1,-1,-1,5,-1,-1,-1,10,10,10,10],[1,-1,-1,2,2,-1,-1,-1,3,-1,-1,-1,-1,5,5,5,-1,-1,-1,10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