- Added multiplayer functions
- Only active user can roll the dice - Only active user can select answers - Card will be destroyed if active user selects answer
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
function Card(game_board_size, s, a1, a2, a3, a4, d) {
|
||||
function Card(game_board_size, s, a1, a2, a3, a4, d, your_turn) {
|
||||
this.card = new PIXI.Graphics();
|
||||
this.s = s;
|
||||
this.a1 = a1;
|
||||
@@ -10,6 +10,7 @@ function Card(game_board_size, s, a1, a2, a3, a4, d) {
|
||||
if (a3.status) this.right_answer = this.a3.text;
|
||||
if (a4.status) this.right_answer = this.a4.text;
|
||||
this.d = d;
|
||||
this.your_turn = your_turn;
|
||||
this.card_x = game_board_size * 0.25 + 2.5;
|
||||
this.card_y = game_board_size / 2 - game_board_size * 0.72 / 2 + 2.5;
|
||||
this.card_height = game_board_size * 0.72;
|
||||
@@ -49,19 +50,27 @@ function Card(game_board_size, s, a1, a2, a3, a4, d) {
|
||||
|
||||
// Answers
|
||||
this.buttons.push(new Button(0xffffff, 0xcccccc, 0x4169E1, this.card_width - 40, 150, this.card_x + 20, this.card_y + this.card_height - 120 - 170 * 4, this.a1.text, this.a1.status, true, function () {
|
||||
select_answer(0, _this.a1.text);
|
||||
if (this.your_turn) {
|
||||
select_answer(0, _this.a1.text);
|
||||
}
|
||||
}));
|
||||
|
||||
this.buttons.push(new Button(0xffffff, 0xcccccc, 0x4169E1, this.card_width - 40, 150, this.card_x + 20, this.card_y + this.card_height - 120 - 170 * 3, this.a2.text, this.a2.status, true, function () {
|
||||
select_answer(1, _this.a2.text);
|
||||
if (this.your_turn) {
|
||||
select_answer(1, _this.a2.text);
|
||||
}
|
||||
}));
|
||||
|
||||
this.buttons.push(new Button(0xffffff, 0xcccccc, 0x4169E1, this.card_width - 40, 150, this.card_x + 20, this.card_y + this.card_height - 120 - 170 * 2, this.a3.text, this.a3.status, true, function () {
|
||||
select_answer(2, _this.a3.text);
|
||||
if (this.your_turn) {
|
||||
select_answer(2, _this.a3.text);
|
||||
}
|
||||
}));
|
||||
|
||||
this.buttons.push(new Button(0xffffff, 0xcccccc, 0x4169E1, this.card_width - 40, 150, this.card_x + 20, this.card_y + this.card_height - 120 - 170 * 1, this.a4.text, this.a4.status, true, function () {
|
||||
select_answer(3, _this.a4.text);
|
||||
if (this.your_turn) {
|
||||
select_answer(3, _this.a4.text);
|
||||
}
|
||||
}));
|
||||
|
||||
this.buttons.forEach(button => this.card.addChild(button.getButton()));
|
||||
@@ -81,7 +90,7 @@ function Card(game_board_size, s, a1, a2, a3, a4, d) {
|
||||
rolled_number = null;
|
||||
rolled_number_text.destroy();
|
||||
border_card_stack.clear();
|
||||
_this.card.destroy();
|
||||
socket.emit('card finished', d);
|
||||
} else {
|
||||
alert("Bitte wähle eine Antwortmöglichkeit aus");
|
||||
}
|
||||
@@ -90,6 +99,11 @@ function Card(game_board_size, s, a1, a2, a3, a4, d) {
|
||||
app.stage.addChild(this.card);
|
||||
};
|
||||
|
||||
this.destroyCard = function () {
|
||||
if (this.card !== null) {
|
||||
this.card.destroy();
|
||||
}
|
||||
};
|
||||
|
||||
function select_answer(id, text) {
|
||||
_this.buttons.forEach(button => button.unSelectButton());
|
||||
|
||||
Reference in New Issue
Block a user