mirror of
https://github.com/overte-org/overte.git
synced 2025-04-17 06:46:22 +02:00
user data cleanup
This commit is contained in:
parent
87d472a5a9
commit
b1d29cf888
2 changed files with 7 additions and 32 deletions
examples
|
@ -1,8 +1,6 @@
|
|||
(function(){
|
||||
this.FIRST_TILE = null; // Global position of the first tile (1a)
|
||||
this.TILE_SIZE = null; // Size of one tile
|
||||
this.whitesDeadPieces = null;
|
||||
this.blacksDeadPieces = null;
|
||||
|
||||
this.wantDebug = false;
|
||||
this.active = false;
|
||||
|
@ -59,16 +57,11 @@
|
|||
|
||||
if (!(this.boardUserData &&
|
||||
this.boardUserData.firstTile &&
|
||||
this.boardUserData.tileSize &&
|
||||
this.boardUserData.whitesDeadPieces &&
|
||||
this.boardUserData.blacksDeadPieces &&
|
||||
this.boardUserData.pieces)) {
|
||||
this.boardUserData.tileSize)) {
|
||||
print("Incomplete boardUserData " + this.boardID.id);
|
||||
} else {
|
||||
this.FIRST_TILE = this.boardUserData.firstTile;
|
||||
this.TILE_SIZE = this.boardUserData.tileSize;
|
||||
this.whitesDeadPieces = this.boardUserData.whitesDeadPieces;
|
||||
this.blacksDeadPieces = this.boardUserData.blacksDeadPieces;
|
||||
|
||||
this.active = true;
|
||||
}
|
||||
|
@ -139,9 +132,10 @@
|
|||
}
|
||||
this.moveDeadPiece = function() {
|
||||
var myPos = this.getIndexPosition(this.properties.position);
|
||||
|
||||
for (var i = 0; i < this.boardUserData.pieces.length; i++) {
|
||||
var piece = this.boardUserData.pieces[i];
|
||||
var others = Entities.findEntities(this.properties.position, this.properties.dimensions.y);
|
||||
|
||||
for (var i = 0; i < others.length; i++) {
|
||||
var piece = others[i];
|
||||
|
||||
if (piece.id != this.entityID.id) {
|
||||
var properties = Entities.getEntityProperties(piece);
|
||||
|
|
|
@ -79,8 +79,7 @@ ChessGame.Board = (function(position, scale) {
|
|||
firstTile: this.tilePosition(1, 1),
|
||||
tileSize: this.tileSize,
|
||||
whitesDeadPieces: this.tilePosition(0,0),
|
||||
blacksDeadPieces: this.tilePosition(9,9),
|
||||
pieces: new Array()
|
||||
blacksDeadPieces: this.tilePosition(9,9)
|
||||
}
|
||||
this.entityProperties = {
|
||||
type: "Model",
|
||||
|
@ -242,25 +241,7 @@ ChessGame.update = function() {
|
|||
for(var j = 1; j <= 8; j++) {
|
||||
ChessGame.makePiece(ChessGame.PAWN, row - 1, j, isWhite);
|
||||
}
|
||||
}
|
||||
|
||||
if (ChessGame.pieces.length > 0) {
|
||||
var unknown = 0;
|
||||
ChessGame.board.userDataObject.pieces = new Array();
|
||||
for(var i = 0; i < ChessGame.pieces.length; i++) {
|
||||
ChessGame.pieces[i].entity = Entities.identifyEntity(ChessGame.pieces[i].entity);
|
||||
if (ChessGame.pieces[i].entity.isKnownID) {
|
||||
ChessGame.board.userDataObject.pieces.push(ChessGame.pieces[i].entity)
|
||||
} else {
|
||||
unknown++;
|
||||
}
|
||||
}
|
||||
ChessGame.board.updateUserData();
|
||||
|
||||
if (unknown === 0) {
|
||||
print("Board complete");
|
||||
Script.update.disconnect(ChessGame.update);
|
||||
}
|
||||
Script.update.disconnect(ChessGame.update);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue