Mercurial > hg > ristipolku
comparison game/Engine.java @ 194:f8626a142c4d
Adjust scoring method.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Tue, 23 Apr 2019 15:43:24 +0300 |
parents | 8dbaa093c562 |
children | ad336d22c3e8 |
comparison
equal
deleted
inserted
replaced
193:60871afc2702 | 194:f8626a142c4d |
---|---|
452 // Finish one move/turn of the game, resolve path and find placement | 452 // Finish one move/turn of the game, resolve path and find placement |
453 // of the next piece, or set "game over" state if required. | 453 // of the next piece, or set "game over" state if required. |
454 public void pieceFinishTurn() | 454 public void pieceFinishTurn() |
455 { | 455 { |
456 boolean finished = false; | 456 boolean finished = false; |
457 int connections = 0; | 457 int connections = 0, addScore = 0; |
458 | 458 |
459 if (currPiece != null) | 459 if (currPiece != null) |
460 { | 460 { |
461 G.smgr.play(sndPlaced); | 461 G.smgr.play(sndPlaced); |
462 } | 462 } |
464 while (!finished) | 464 while (!finished) |
465 { | 465 { |
466 if (currX >= 0 && currX < boardSize && currY >= 0 && currY < boardSize) | 466 if (currX >= 0 && currX < boardSize && currY >= 0 && currY < boardSize) |
467 { | 467 { |
468 int oldX = currX, oldY = currY; | 468 int oldX = currX, oldY = currY; |
469 finished = pieceCheck(board[currX][currY]); | |
470 | |
469 connections++; | 471 connections++; |
470 finished = pieceCheck(board[currX][currY]); | |
471 | 472 |
472 if (!finished) | 473 if (!finished) |
473 { | 474 { |
475 addScore += connections * connections; | |
476 | |
474 Lock write = pointLock.writeLock(); | 477 Lock write = pointLock.writeLock(); |
475 write.lock(); | 478 write.lock(); |
476 try | 479 try |
477 { | 480 { |
478 pointElems.add(new AnimatedPointElement( | 481 pointElems.add(new AnimatedPointElement( |
479 new IDMPoint( | 482 new IDMPoint( |
480 getScaledX() + ((oldX + 0.5f) * pscale), | 483 getScaledX() + ((oldX + 0.5f) * pscale), |
481 getScaledY() + ((oldY + 0.5f) * pscale)), | 484 getScaledY() + ((oldY + 0.5f) * pscale)), |
482 "" + connections)); | 485 "" + addScore)); |
483 } | 486 } |
484 finally | 487 finally |
485 { | 488 { |
486 write.unlock(); | 489 write.unlock(); |
487 } | 490 } |
488 } | 491 } |
489 | |
490 } | 492 } |
491 else | 493 else |
492 { | 494 { |
493 // Outside of the board, game over | 495 // Outside of the board, game over |
494 finished = true; | 496 finished = true; |
495 flagGameOver = true; | 497 flagGameOver = true; |
496 } | 498 } |
497 } | 499 } |
498 | 500 |
499 // Compute and add score | 501 // Increase number of moves |
500 gameScore += connections * connections; | 502 gameScore += addScore; |
501 moves++; | 503 moves++; |
502 | 504 |
503 // If game over, clear the game | 505 // If game over, clear the game |
504 if (flagGameOver) | 506 if (flagGameOver) |
505 { | 507 { |