Commit 760bff28 authored by Romain DELEAU's avatar Romain DELEAU

Traces on task reward (+ fix on newsupplementaryRole trace)

parent a11ce600
......@@ -200,7 +200,7 @@ export class RoleComponent implements OnInit {
addSupplementaryRole(): void {
this.role.supplementaryRoles.push(new SupplementaryRole());
this.scenario.traces.push(new Trace(this.scenario.traces.length,'new',this.missionIndex,this.i,'Secondary_role_['+this.role.supplementaryRoles.length+']', 'Role_['+this.i+']', '#9AD5EC', '*'));
this.scenario.traces.push(new Trace(this.scenario.traces.length,'new',this.missionIndex,this.i,'Secondary_role_['+(this.role.supplementaryRoles.length-1)+']', 'Role_['+this.i+']', '#9AD5EC', '*'));
this.minimapService.reset();
}
......
......@@ -6,7 +6,7 @@ matTooltipPosition="before" [matTooltipDisabled]="!tooltipService.activatedToolt
<div class="piece-form-content">
<div class="piece-form-content-type">
<label for="type">{{'rewards_type_label'| translate}}</label>
<select name="type" [(ngModel)]="task.rewardType" (change)="resetReward()">
<select name="type" [(ngModel)]="task.rewardType" (change)="resetReward($event)">
<option value="none" selected>{{'rewards_type_none' | translate}}</option>
<option value="object">{{'rewards_type_object' | translate}}</option>
<option value="character">{{'rewards_type_character' | translate}}</option>
......@@ -22,7 +22,7 @@ matTooltipPosition="before" [matTooltipDisabled]="!tooltipService.activatedToolt
-->
<div class="piece-form-content-object" *ngIf="task.rewardType == 'object'">
<input type="number" name="quantity" [(ngModel)]="task.rewardQuantity"/>
<select name="object_name" [(ngModel)]="task.reward">
<select name="object_name" [(ngModel)]="task.reward" (change)="editTrace($event,'task_reward')">
<option value="null" selected disabled>{{'rewards_object_placeholder' | translate}}</option>
<ng-container *ngFor="let ressource of scenario.ressources">
<option *ngIf="ressource.type == 'ressource'" [ngValue]="ressource">{{ressource.name}}</option>
......@@ -33,14 +33,14 @@ matTooltipPosition="before" [matTooltipDisabled]="!tooltipService.activatedToolt
</select>
</div>
<div class="piece-form-content-character" *ngIf="task.rewardType == 'character'">
<select name="character" [(ngModel)]="task.reward">
<select name="character" [(ngModel)]="task.reward" (change)="editTrace($event,'task_reward')">
<option value="null" selected disabled>{{'rewards_character_placeholder' | translate}}</option>
<option *ngFor="let character of scenario.characters" [ngValue]="character">{{character.name}}</option>
</select>
</div>
<div class="piece-form-content-skill" *ngIf="task.rewardType == 'skill'">
<input type="number" name="quantity" [(ngModel)]="task.rewardQuantity"/>
<select name="skill" [(ngModel)]="task.reward">
<select name="skill" [(ngModel)]="task.reward" (change)="editTrace($event,'task_reward')">
<option value="null" selected disabled>{{'rewards_skill_placeholder' | translate}}</option>
<ng-container *ngFor="let ressource of pieceDetailsService.parentAsRole().ressources">
<option *ngIf="ressource.type == 'attribut'" [ngValue]="ressource">{{ressource.name}}</option>
......
......@@ -3,6 +3,7 @@ import { TranslateService } from '@ngx-translate/core';
import { Role } from 'src/app/class/role/role';
import { Scenario } from 'src/app/class/scenario/scenario';
import { Task } from 'src/app/class/task/task';
import { Trace } from 'src/app/class/trace/trace';
import { PieceDetailsService } from 'src/app/services/piece-details/piece-details.service';
import { TooltipService } from 'src/app/services/tooltip/tooltip.service';
......@@ -22,7 +23,33 @@ export class RewardsComponent implements OnInit {
ngOnInit(): void {
}
resetReward() {
resetReward(event: any) {
this.task.resetReward();
this.editTrace(event, 'task_reward');
}
formatTraceTarget(): string {
let res: string = '';
if (this.pieceDetailsService.piece instanceof Task) {
switch(this.pieceDetailsService.piece.type) {
case 'normal': res = 'Task_['+this.pieceDetailsService.pieceIndex+']'; break;
case 'annexe': res = 'Side_task_['+this.pieceDetailsService.pieceIndex+']'; break;
case 'final': res = 'Final_task_['+this.pieceDetailsService.pieceIndex+']'; break;
case 'optionnal': res = 'Opt_task_['+this.pieceDetailsService.pieceIndex+']'; break;
case 'event': res = 'Event_task_['+this.pieceDetailsService.pieceIndex+']'; break;
case 'repeat': res = 'Repeat_task_['+this.pieceDetailsService.pieceIndex+']'; break;
}
}
return res;
}
editTrace(event: any, source: string): void {
if (this.task.reward != undefined) {
this.scenario.traces.push(new Trace(this.scenario.traces.length,'Select_task_reward_'+this.task.rewardType,this.pieceDetailsService.missionIndex,this.pieceDetailsService.roleIndex,source,this.formatTraceTarget(), '#CFE3B9'));
} else {
this.scenario.traces.push(new Trace(this.scenario.traces.length,'Deselect_task_reward',this.pieceDetailsService.missionIndex,this.pieceDetailsService.roleIndex,source,this.formatTraceTarget(), '#CFE3B9'));
}
}
}
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