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