Commit 26778f08 authored by Romain DELEAU's avatar Romain DELEAU

remove symbol on taskPaste if already used in the role

parent a21bd548
......@@ -162,7 +162,8 @@ export class AnnexeTaskComponent implements OnInit {
}
onClickPaste() {
this.role.tasks[this.i][this.j] = this.copyTaskService.onClickPaste(this.scenario);;
let newTask: Task = this.copyTaskService.onClickPaste(this.scenario);
this.role.tasks[this.i][this.j] = newTask;
if (this.role.isAlreadyUsedIdentifier((this.role.tasks[this.i][this.j] as Task).identifier)) {
this._snackBar.open(this.translate.instant('snackbar_identifier'), '', { duration: 5000, panelClass: 'snackbar-fail' });
(this.role.tasks[this.i][this.j] as Task).identifier = '';
......
......@@ -17,6 +17,7 @@ import { MinimapService } from 'src/app/services/minimap/minimap.service';
import { TranslateService } from '@ngx-translate/core';
import { UnityService } from 'src/app/services/unity/unity.service';
import { CopyTaskService } from 'src/app/services/copyTask/copy-task.service';
import { Symbol } from 'src/app/class/symbol/symbol';
@Component({
selector: 'app-final-task',
......@@ -165,7 +166,11 @@ export class FinalTaskComponent implements OnInit {
}
onClickPaste() {
this.role.tasks[this.i][this.j] = this.copyTaskService.onClickPaste(this.scenario);;
let newTask: Task = this.copyTaskService.onClickPaste(this.scenario);
if (this.canUseSymbol(newTask.symbol.symbol, newTask.symbol.color) == 'disable') {
newTask.symbol = new Symbol();
}
this.role.tasks[this.i][this.j] = newTask;
if (this.role.isAlreadyUsedIdentifier((this.role.tasks[this.i][this.j] as Task).identifier)) {
this._snackBar.open(this.translate.instant('snackbar_identifier'), '', { duration: 5000, panelClass: 'snackbar-fail' });
(this.role.tasks[this.i][this.j] as Task).identifier = '';
......
......@@ -17,6 +17,7 @@ import { MinimapService } from 'src/app/services/minimap/minimap.service';
import { TranslateService } from '@ngx-translate/core';
import { UnityService } from 'src/app/services/unity/unity.service';
import { CopyTaskService } from 'src/app/services/copyTask/copy-task.service';
import { Symbol } from 'src/app/class/symbol/symbol';
@Component({
selector: 'app-optionnal-task',
......@@ -170,7 +171,11 @@ export class OptionnalTaskComponent implements OnInit {
}
onClickPaste() {
this.role.tasks[this.i][this.j] = this.copyTaskService.onClickPaste(this.scenario);;
let newTask: Task = this.copyTaskService.onClickPaste(this.scenario);
if (this.canUseSymbol(newTask.symbol.symbol, newTask.symbol.color) == 'disable') {
newTask.symbol = new Symbol();
}
this.role.tasks[this.i][this.j] = newTask;
if (this.role.isAlreadyUsedIdentifier((this.role.tasks[this.i][this.j] as Task).identifier)) {
this._snackBar.open(this.translate.instant('snackbar_identifier'), '', { duration: 5000, panelClass: 'snackbar-fail' });
(this.role.tasks[this.i][this.j] as Task).identifier = '';
......
......@@ -17,6 +17,7 @@ import { MinimapService } from 'src/app/services/minimap/minimap.service';
import { TranslateService } from '@ngx-translate/core';
import { UnityService } from 'src/app/services/unity/unity.service';
import { CopyTaskService } from 'src/app/services/copyTask/copy-task.service';
import { Symbol } from 'src/app/class/symbol/symbol';
@Component({
selector: 'app-random-event',
......@@ -155,7 +156,11 @@ export class RandomEventComponent implements OnInit {
}
onClickPaste() {
this.role.tasks[this.i][this.j] = this.copyTaskService.onClickPaste(this.scenario);;
let newTask: Task = this.copyTaskService.onClickPaste(this.scenario);
if (this.canUseSymbol(newTask.symbol.symbol, newTask.symbol.color) == 'disable') {
newTask.symbol = new Symbol();
}
this.role.tasks[this.i][this.j] = newTask;
if (this.role.isAlreadyUsedIdentifier((this.role.tasks[this.i][this.j] as Task).identifier)) {
this._snackBar.open(this.translate.instant('snackbar_identifier'), '', { duration: 5000, panelClass: 'snackbar-fail' });
(this.role.tasks[this.i][this.j] as Task).identifier = '';
......
......@@ -97,7 +97,7 @@ export class RepeatTaskComponent implements OnInit {
}
onClickPaste() {
this.role.tasks[this.i][this.j] = this.copyTaskService.onClickPaste(this.scenario);;
this.role.tasks[this.i][this.j] = this.copyTaskService.onClickPaste(this.scenario);
}
moveTask(direction: string): void {
......
......@@ -18,6 +18,7 @@ import { TranslateService } from '@ngx-translate/core';
import { TutorialService } from 'src/app/services/tutorial/tutorial.service';
import { UnityService } from 'src/app/services/unity/unity.service';
import { CopyTaskService } from 'src/app/services/copyTask/copy-task.service';
import { Symbol } from 'src/app/class/symbol/symbol';
@Component({
selector: 'app-task',
......@@ -166,7 +167,11 @@ export class TaskComponent implements OnInit {
}
onClickPaste() {
this.role.tasks[this.i][this.j] = this.copyTaskService.onClickPaste(this.scenario);;
let newTask: Task = this.copyTaskService.onClickPaste(this.scenario);
if (this.canUseSymbol(newTask.symbol.symbol, newTask.symbol.color) == 'disable') {
newTask.symbol = new Symbol();
}
this.role.tasks[this.i][this.j] = newTask;
if (this.role.isAlreadyUsedIdentifier((this.role.tasks[this.i][this.j] as Task).identifier)) {
this._snackBar.open(this.translate.instant('snackbar_identifier'), '', { duration: 5000, panelClass: 'snackbar-fail' });
(this.role.tasks[this.i][this.j] as Task).identifier = '';
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment