Commit f9ff153d authored by Romain DELEAU's avatar Romain DELEAU

add discussion/sentence/response rewards

parent 88e5cb61
...@@ -315,6 +315,39 @@ export class AppComponent { ...@@ -315,6 +315,39 @@ export class AppComponent {
discussionData discussionData
); );
discussion.character = character as Character; discussion.character = character as Character;
discussion.rewards = discussion.rewards.map((rewardData: any) => {
if (rewardData.type == 'skill') {
return Object.assign(new SkillReward(), rewardData);
}
if (rewardData.type == 'character') {
return Object.assign(new CharacterReward(), rewardData);
}
if (rewardData.type == 'quest') {
return Object.assign(new QuestReward(), rewardData);
}
if (rewardData.type == 'object') {
return Object.assign(new ObjectReward(), rewardData);
}
});
discussion.rewards.forEach((reward: Reward, index: number) => {
if (reward instanceof SkillReward) {
let i: number = role.ressources.findIndex(element => element.type == 'attribut' && element.name == reward.skill.name && element.number == reward.skill.number);
reward.skill = role.ressources[i];
}
if (reward instanceof CharacterReward) {
let i: number = scenario.characters.findIndex(element => element.color == reward.character.color && element.description == reward.character.description && element.name == reward.character.name);
reward.character = scenario.characters[i];
}
if (reward instanceof ObjectReward) {
if (scenario.ressources.some(element => element.name == reward.object.name && element.type == 'ressource' && element.number == reward.object.number)) {
let i: number = scenario.ressources.findIndex(element => element.name == reward.object.name && element.type == 'ressource' && element.number == reward.object.number);
reward.object = scenario.ressources[i];
} else {
let i: number = role.ressources.findIndex(element => element.name == reward.object.name && element.type == 'ressource' && element.number == reward.object.number);
reward.object = role.ressources[i];
}
}
});
return discussion; return discussion;
}); });
role.sentences = role.sentences.map((sentenceData: any) => { role.sentences = role.sentences.map((sentenceData: any) => {
...@@ -324,7 +357,78 @@ export class AppComponent { ...@@ -324,7 +357,78 @@ export class AppComponent {
return Object.assign(new DeclarativeSentence(sentenceData.ID), sentenceData); return Object.assign(new DeclarativeSentence(sentenceData.ID), sentenceData);
} }
}); });
role.sentences.forEach(sentence => {
sentence.rewards = sentence.rewards.map((rewardData: any) => {
if (rewardData.type == 'skill') {
return Object.assign(new SkillReward(), rewardData);
}
if (rewardData.type == 'character') {
return Object.assign(new CharacterReward(), rewardData);
}
if (rewardData.type == 'quest') {
return Object.assign(new QuestReward(), rewardData);
}
if (rewardData.type == 'object') {
return Object.assign(new ObjectReward(), rewardData);
}
});
sentence.rewards.forEach((reward: Reward, index: number) => {
if (reward instanceof SkillReward) {
let i: number = role.ressources.findIndex(element => element.type == 'attribut' && element.name == reward.skill.name && element.number == reward.skill.number);
reward.skill = role.ressources[i];
}
if (reward instanceof CharacterReward) {
let i: number = scenario.characters.findIndex(element => element.color == reward.character.color && element.description == reward.character.description && element.name == reward.character.name);
reward.character = scenario.characters[i];
}
if (reward instanceof ObjectReward) {
if (scenario.ressources.some(element => element.name == reward.object.name && element.type == 'ressource' && element.number == reward.object.number)) {
let i: number = scenario.ressources.findIndex(element => element.name == reward.object.name && element.type == 'ressource' && element.number == reward.object.number);
reward.object = scenario.ressources[i];
} else {
let i: number = role.ressources.findIndex(element => element.name == reward.object.name && element.type == 'ressource' && element.number == reward.object.number);
reward.object = role.ressources[i];
}
}
});
});
role.responses = role.responses.map((responseData: any) => Object.assign(new Response(responseData.ID), responseData)); role.responses = role.responses.map((responseData: any) => Object.assign(new Response(responseData.ID), responseData));
role.responses.forEach(response => {
response.rewards = response.rewards.map((rewardData: any) => {
if (rewardData.type == 'skill') {
return Object.assign(new SkillReward(), rewardData);
}
if (rewardData.type == 'character') {
return Object.assign(new CharacterReward(), rewardData);
}
if (rewardData.type == 'quest') {
return Object.assign(new QuestReward(), rewardData);
}
if (rewardData.type == 'object') {
return Object.assign(new ObjectReward(), rewardData);
}
});
response.rewards.forEach((reward: Reward, index: number) => {
if (reward instanceof SkillReward) {
let i: number = role.ressources.findIndex(element => element.type == 'attribut' && element.name == reward.skill.name && element.number == reward.skill.number);
reward.skill = role.ressources[i];
}
if (reward instanceof CharacterReward) {
let i: number = scenario.characters.findIndex(element => element.color == reward.character.color && element.description == reward.character.description && element.name == reward.character.name);
reward.character = scenario.characters[i];
}
if (reward instanceof ObjectReward) {
if (scenario.ressources.some(element => element.name == reward.object.name && element.type == 'ressource' && element.number == reward.object.number)) {
let i: number = scenario.ressources.findIndex(element => element.name == reward.object.name && element.type == 'ressource' && element.number == reward.object.number);
reward.object = scenario.ressources[i];
} else {
let i: number = role.ressources.findIndex(element => element.name == reward.object.name && element.type == 'ressource' && element.number == reward.object.number);
reward.object = role.ressources[i];
}
}
});
});
role.tasks.forEach((inlineTasks: any[], index: number) => { role.tasks.forEach((inlineTasks: any[], index: number) => {
role.tasks[index] = inlineTasks.map((taskData: any) => { role.tasks[index] = inlineTasks.map((taskData: any) => {
if (taskData !== null) { if (taskData !== null) {
...@@ -475,7 +579,8 @@ export class AppComponent { ...@@ -475,7 +579,8 @@ export class AppComponent {
} }
this.cdr.detectChanges(); this.cdr.detectChanges();
this._snackBar.openFromComponent(LoadingsucessSnackbarComponent, { duration: 5000 }); this._snackBar.openFromComponent(LoadingsucessSnackbarComponent, { duration: 5000 });
} catch { } catch (e) {
console.error(e);
this._snackBar.openFromComponent(LoadingfailSnackbarComponent, { duration: 5000 }); this._snackBar.openFromComponent(LoadingfailSnackbarComponent, { duration: 5000 });
} }
}; };
......
import { Character } from "../character/character"; import { Character } from "../character/character";
import { CharacterReward } from "../rewards/character-reward/character-reward";
import { ObjectReward } from "../rewards/object-reward/object-reward";
import { QuestReward } from "../rewards/quest-reward/quest-reward";
import { Reward } from "../rewards/reward";
import { SkillReward } from "../rewards/skill-reward/skill-reward";
export class Discussion { export class Discussion {
...@@ -11,8 +16,66 @@ export class Discussion { ...@@ -11,8 +16,66 @@ export class Discussion {
name: string = ''; name: string = '';
ID: number = 0; ID: number = 0;
sentences: number[] = []; sentences: number[] = [];
results: [] = [];
firstSentenceID: number = -1; firstSentenceID: number = -1;
character: Character; character: Character;
isFirstDiscussion: boolean = false; isFirstDiscussion: boolean = false;
rewards: Reward[] = [];
addReward(): void {
this.rewards.push(new ObjectReward());
//this.scenario.traces.push(new Trace(this.scenario.traces.length, 'new', this.missionIndex, this.i, 'Reward_[' + this.role.rewards.length + ']', 'Role_[' + this.i + ']', '#9AD5EC', '*'));
}
changeRewardType(index: number, type: string): void {
switch (type) {
case 'quest': this.rewards[index] = new QuestReward();
//this.scenario.traces.push(new Trace(this.scenario.traces.length,'transform',this.missionIndex,this.i,'Reward_['+index+']_transform_into_[QuestReward]', 'Role_['+this.i+']', '#9AD5EC', '*'));
break;
case 'skill': this.rewards[index] = new SkillReward();
//this.scenario.traces.push(new Trace(this.scenario.traces.length,'transform',this.missionIndex,this.i,'Reward_['+index+']_transform_into_[SkillReward]', 'Role_['+this.i+']', '#9AD5EC', '*'));
break;
case 'character': this.rewards[index] = new CharacterReward();
//this.scenario.traces.push(new Trace(this.scenario.traces.length,'transform',this.missionIndex,this.i,'Reward_['+index+']_transform_into_[CharacterReward]', 'Role_['+this.i+']', '#9AD5EC', '*'));
break;
case 'object': this.rewards[index] = new ObjectReward();
//this.scenario.traces.push(new Trace(this.scenario.traces.length,'transform',this.missionIndex,this.i,'Reward_['+index+']_transform_into_[ObjectReward]', 'Role_['+this.i+']', '#9AD5EC', '*'));
break;
}
}
removeReward(index: number): void {
//const dialogRef = this.dialog.open(SuppressDialogComponent, { data: this.translate.instant('role_reward_delete') });
//dialogRef.afterClosed().subscribe(result => {
//if (result == true) {
this.rewards.splice(index, 1);
//this.scenario.traces.push(new Trace(this.scenario.traces.length, 'delete', this.missionIndex, this.i, 'Reward_[' + index + ']', 'Role_[' + this.i + ']', '#9AD5EC', '*'));
//} else {
//this.scenario.traces.push(new Trace(this.scenario.traces.length, 'cancel_delete', this.missionIndex, this.i, 'Reward_[' + index + ']', 'Role_[' + this.i + ']', '#9AD5EC', '*'));
//}
//});
}
getQuestReward(index: number): QuestReward {
return this.rewards[index] as QuestReward;
}
getCharacterReward(index: number): CharacterReward {
return this.rewards[index] as CharacterReward;
}
getSkillReward(index: number): SkillReward {
return this.rewards[index] as SkillReward;
}
getObjectReward(index: number): ObjectReward {
return this.rewards[index] as ObjectReward;
}
changeQuestReward(roleIntitule: string, index: number, event: any) {
let value: string = event.target.value;
let reward = new QuestReward();
reward.intitule = roleIntitule;
reward.questName = value;
this.rewards[index] = reward;
}
} }
import { CharacterReward } from "../rewards/character-reward/character-reward";
import { ObjectReward } from "../rewards/object-reward/object-reward";
import { QuestReward } from "../rewards/quest-reward/quest-reward";
import { Reward } from "../rewards/reward";
import { SkillReward } from "../rewards/skill-reward/skill-reward";
export class Response { export class Response {
constructor(ID: number) { constructor(ID: number) {
...@@ -7,7 +13,65 @@ export class Response { ...@@ -7,7 +13,65 @@ export class Response {
ID: number = 0; ID: number = 0;
value: string = ''; value: string = '';
nextSentence: number = -1; nextSentence: number = -1;
results: [] = [];
idInterrogativeSentence: number = 0; idInterrogativeSentence: number = 0;
rewards: Reward[] = [];
addReward(): void {
this.rewards.push(new ObjectReward());
//this.scenario.traces.push(new Trace(this.scenario.traces.length, 'new', this.missionIndex, this.i, 'Reward_[' + this.role.rewards.length + ']', 'Role_[' + this.i + ']', '#9AD5EC', '*'));
}
changeRewardType(index: number, type: string): void {
switch (type) {
case 'quest': this.rewards[index] = new QuestReward();
//this.scenario.traces.push(new Trace(this.scenario.traces.length,'transform',this.missionIndex,this.i,'Reward_['+index+']_transform_into_[QuestReward]', 'Role_['+this.i+']', '#9AD5EC', '*'));
break;
case 'skill': this.rewards[index] = new SkillReward();
//this.scenario.traces.push(new Trace(this.scenario.traces.length,'transform',this.missionIndex,this.i,'Reward_['+index+']_transform_into_[SkillReward]', 'Role_['+this.i+']', '#9AD5EC', '*'));
break;
case 'character': this.rewards[index] = new CharacterReward();
//this.scenario.traces.push(new Trace(this.scenario.traces.length,'transform',this.missionIndex,this.i,'Reward_['+index+']_transform_into_[CharacterReward]', 'Role_['+this.i+']', '#9AD5EC', '*'));
break;
case 'object': this.rewards[index] = new ObjectReward();
//this.scenario.traces.push(new Trace(this.scenario.traces.length,'transform',this.missionIndex,this.i,'Reward_['+index+']_transform_into_[ObjectReward]', 'Role_['+this.i+']', '#9AD5EC', '*'));
break;
}
}
removeReward(index: number): void {
//const dialogRef = this.dialog.open(SuppressDialogComponent, { data: this.translate.instant('role_reward_delete') });
//dialogRef.afterClosed().subscribe(result => {
//if (result == true) {
this.rewards.splice(index, 1);
//this.scenario.traces.push(new Trace(this.scenario.traces.length, 'delete', this.missionIndex, this.i, 'Reward_[' + index + ']', 'Role_[' + this.i + ']', '#9AD5EC', '*'));
//} else {
//this.scenario.traces.push(new Trace(this.scenario.traces.length, 'cancel_delete', this.missionIndex, this.i, 'Reward_[' + index + ']', 'Role_[' + this.i + ']', '#9AD5EC', '*'));
//}
//});
}
getQuestReward(index: number): QuestReward {
return this.rewards[index] as QuestReward;
}
getCharacterReward(index: number): CharacterReward {
return this.rewards[index] as CharacterReward;
}
getSkillReward(index: number): SkillReward {
return this.rewards[index] as SkillReward;
}
getObjectReward(index: number): ObjectReward {
return this.rewards[index] as ObjectReward;
}
changeQuestReward(roleIntitule: string, index: number, event: any) {
let value: string = event.target.value;
let reward = new QuestReward();
reward.intitule = roleIntitule;
reward.questName = value;
this.rewards[index] = reward;
}
} }
import { CharacterReward } from "../rewards/character-reward/character-reward";
import { ObjectReward } from "../rewards/object-reward/object-reward";
import { QuestReward } from "../rewards/quest-reward/quest-reward";
import { Reward } from "../rewards/reward";
import { SkillReward } from "../rewards/skill-reward/skill-reward";
export abstract class Sentence { export abstract class Sentence {
constructor(ID: number) { constructor(ID: number) {
...@@ -6,7 +12,64 @@ export abstract class Sentence { ...@@ -6,7 +12,64 @@ export abstract class Sentence {
ID: number = 0; ID: number = 0;
value: string = ''; value: string = '';
results: [] = [];
idDiscussion: number = 0; idDiscussion: number = 0;
rewards: Reward[] = [];
addReward(): void {
this.rewards.push(new ObjectReward());
//this.scenario.traces.push(new Trace(this.scenario.traces.length, 'new', this.missionIndex, this.i, 'Reward_[' + this.role.rewards.length + ']', 'Role_[' + this.i + ']', '#9AD5EC', '*'));
}
changeRewardType(index: number, type: string): void {
switch (type) {
case 'quest': this.rewards[index] = new QuestReward();
//this.scenario.traces.push(new Trace(this.scenario.traces.length,'transform',this.missionIndex,this.i,'Reward_['+index+']_transform_into_[QuestReward]', 'Role_['+this.i+']', '#9AD5EC', '*'));
break;
case 'skill': this.rewards[index] = new SkillReward();
//this.scenario.traces.push(new Trace(this.scenario.traces.length,'transform',this.missionIndex,this.i,'Reward_['+index+']_transform_into_[SkillReward]', 'Role_['+this.i+']', '#9AD5EC', '*'));
break;
case 'character': this.rewards[index] = new CharacterReward();
//this.scenario.traces.push(new Trace(this.scenario.traces.length,'transform',this.missionIndex,this.i,'Reward_['+index+']_transform_into_[CharacterReward]', 'Role_['+this.i+']', '#9AD5EC', '*'));
break;
case 'object': this.rewards[index] = new ObjectReward();
//this.scenario.traces.push(new Trace(this.scenario.traces.length,'transform',this.missionIndex,this.i,'Reward_['+index+']_transform_into_[ObjectReward]', 'Role_['+this.i+']', '#9AD5EC', '*'));
break;
}
}
removeReward(index: number): void {
//const dialogRef = this.dialog.open(SuppressDialogComponent, { data: this.translate.instant('role_reward_delete') });
//dialogRef.afterClosed().subscribe(result => {
//if (result == true) {
this.rewards.splice(index, 1);
//this.scenario.traces.push(new Trace(this.scenario.traces.length, 'delete', this.missionIndex, this.i, 'Reward_[' + index + ']', 'Role_[' + this.i + ']', '#9AD5EC', '*'));
//} else {
//this.scenario.traces.push(new Trace(this.scenario.traces.length, 'cancel_delete', this.missionIndex, this.i, 'Reward_[' + index + ']', 'Role_[' + this.i + ']', '#9AD5EC', '*'));
//}
//});
}
getQuestReward(index: number): QuestReward {
return this.rewards[index] as QuestReward;
}
getCharacterReward(index: number): CharacterReward {
return this.rewards[index] as CharacterReward;
}
getSkillReward(index: number): SkillReward {
return this.rewards[index] as SkillReward;
}
getObjectReward(index: number): ObjectReward {
return this.rewards[index] as ObjectReward;
}
changeQuestReward(roleIntitule: string, index: number, event: any) {
let value: string = event.target.value;
let reward = new QuestReward();
reward.intitule = roleIntitule;
reward.questName = value;
this.rewards[index] = reward;
}
} }
...@@ -13,9 +13,82 @@ ...@@ -13,9 +13,82 @@
</div> </div>
<div class="form-result"> <div class="form-result">
<label for="result">{{'discussion_result_label' | translate}}</label> <label for="result">{{'discussion_result_label' | translate}}</label>
<!--
<select name="result"> <select name="result">
<option [ngValue]="" disabled selected>{{'discussion_result_placeholder' | translate}}</option> <option [ngValue]="" disabled selected>{{'discussion_result_placeholder' | translate}}</option>
</select> </select>
-->
<div class="form-result-results">
<div class="form-result-results-result" *ngFor="let reward of discussion.rewards, let rewardIndex = index">
<div class="form-result-results-result-type">
<label>{{'role_reward_type_label' | translate}}</label>
<select [(ngModel)]="reward.type" (change)="discussion.changeRewardType(rewardIndex, reward.type)"
[matTooltip]="translate.instant('discussion_reward_type_discussion_tooltip')"
matTooltipPosition="above" [matTooltipDisabled]="!tooltipService.activatedTooltips">
<option value="quest">{{'role_reward_type_newQuest' | translate}}</option>
<option value="skill">{{'role_reward_type_skill' | translate}}</option>
<option value="character">{{'role_reward_type_character' | translate}}</option>
<option value="object">{{'role_reward_type_object' | translate}}</option>
<!--<option value="discuss">Changer de discussion</option>-->
</select>
</div>
<div class="form-result-results-result-quest" *ngIf="reward.type == 'quest'">
<select (change)="discussion.changeQuestReward(role.intitule, rewardIndex, $event)"
[matTooltip]="translate.instant('role_reward_type_newQuest_tooltip')"
matTooltipPosition="above" [matTooltipDisabled]="!tooltipService.activatedTooltips">
<option [ngValue]="null" selected disabled>{{'role_reward_quest_placeholder' | translate}}</option>
<ng-container *ngFor="let mission of scenario.missions; let indexMission = index">
<ng-container *ngFor="let quest of mission.roles; let indexRole = index">
<option [ngValue]="quest.questName" [selected]="discussion.getQuestReward(rewardIndex).intitule == quest.intitule && discussion.getQuestReward(rewardIndex).questName == quest.questName"
*ngIf="role.intitule && quest.questName && role.intitule == quest.intitule && role.questName != quest.questName">
{{quest.questName}}
</option>
</ng-container>
</ng-container>
</select>
</div>
<div class="form-result-results-result-skill" *ngIf="reward.type == 'skill'">
<input type="number" [(ngModel)]="discussion.getSkillReward(rewardIndex).quantity"/>
<select [(ngModel)]="discussion.getSkillReward(rewardIndex).skill"
[matTooltip]="translate.instant('role_reward_type_skill_tooltip')"
matTooltipPosition="above" [matTooltipDisabled]="!tooltipService.activatedTooltips">
<ng-container *ngFor="let skill of role.ressources">
<option [ngValue]="skill" *ngIf="skill.type == 'attribut'">{{skill.name}}</option>
</ng-container>
</select>
</div>
<div class="form-result-results-result-character" *ngIf="reward.type == 'character'">
<select [(ngModel)]="discussion.getCharacterReward(rewardIndex).character"
[matTooltip]="translate.instant('role_reward_type_character_tooltip')"
matTooltipPosition="above" [matTooltipDisabled]="!tooltipService.activatedTooltips">
<option [ngValue]="character" *ngFor="let character of scenario.characters">{{character.name}}</option>
</select>
</div>
<div class="form-result-results-result-object" *ngIf="reward.type == 'object'">
<input type="number" [(ngModel)]="discussion.getObjectReward(rewardIndex).quantity"/>
<select [(ngModel)]="discussion.getObjectReward(rewardIndex).object"
[matTooltip]="translate.instant('role_reward_type_object_tooltip')"
matTooltipPosition="above" [matTooltipDisabled]="!tooltipService.activatedTooltips">
<ng-container *ngFor="let ressource of scenario.ressources">
<option [ngValue]="ressource" *ngIf="ressource.type == 'ressource'">{{ressource.name}}</option>
</ng-container>
<ng-container *ngFor="let ressource of role.ressources">
<option [ngValue]="ressource" *ngIf="ressource.type == 'ressource'">{{ressource.name}}</option>
</ng-container>
</select>
</div>
<button mat-button class="form-result-button-remove" (click)="discussion.removeReward(rewardIndex)"><mat-icon fontIcon="remove"></mat-icon></button>
</div>
<button mat-button class="form-result-button-add" (click)="discussion.addReward()"><mat-icon fontIcon="add"></mat-icon></button>
</div>
</div> </div>
<div class="form-addSentence"> <div class="form-addSentence">
<button mat-button (click)="addDeclarativeSentence()">{{'discussion_buttons_newDeclarativeSentence' | translate}}</button> <button mat-button (click)="addDeclarativeSentence()">{{'discussion_buttons_newDeclarativeSentence' | translate}}</button>
...@@ -47,12 +120,6 @@ ...@@ -47,12 +120,6 @@
[disabled]="discussion.firstSentenceID != -1 && discussion.firstSentenceID != sentence.ID"/> [disabled]="discussion.firstSentenceID != -1 && discussion.firstSentenceID != sentence.ID"/>
<label for="firstSentence">{{'discussion_firstSentence_label' | translate}}</label> <label for="firstSentence">{{'discussion_firstSentence_label' | translate}}</label>
</div> </div>
<div class="form-result">
<label for="result">{{'discussion_result_label' | translate}}</label>
<select name="result">
<option [ngValue]="" disabled selected>{{'discussion_result_placeholder' | translate}}</option>
</select>
</div>
<div class="form-nextSentence"> <div class="form-nextSentence">
<label for="nextSentence">{{'discussion_nextSentence_label' | translate}}</label> <label for="nextSentence">{{'discussion_nextSentence_label' | translate}}</label>
<select name="nextSentence" [(ngModel)]="getSentenceAsDeclarativeSentence(sentence).nextSentence"> <select name="nextSentence" [(ngModel)]="getSentenceAsDeclarativeSentence(sentence).nextSentence">
...@@ -62,6 +129,85 @@ ...@@ -62,6 +129,85 @@
</ng-container> </ng-container>
</select> </select>
</div> </div>
<div class="form-result">
<label for="result">{{'discussion_result_label' | translate}}</label>
<!--
<select name="result">
<option [ngValue]="" disabled selected>{{'discussion_result_placeholder' | translate}}</option>
</select>
-->
<div class="form-result-results">
<div class="form-result-results-result" *ngFor="let reward of sentence.rewards, let rewardIndex = index">
<div class="form-result-results-result-type">
<label>{{'role_reward_type_label' | translate}}</label>
<select [(ngModel)]="reward.type" (change)="sentence.changeRewardType(rewardIndex, reward.type)"
[matTooltip]="translate.instant('discussion_reward_type_declarativeSentence_tooltip')"
matTooltipPosition="above" [matTooltipDisabled]="!tooltipService.activatedTooltips">
<option value="quest">{{'role_reward_type_newQuest' | translate}}</option>
<option value="skill">{{'role_reward_type_skill' | translate}}</option>
<option value="character">{{'role_reward_type_character' | translate}}</option>
<option value="object">{{'role_reward_type_object' | translate}}</option>
<!--<option value="discuss">Changer de discussion</option>-->
</select>
</div>
<div class="form-result-results-result-quest" *ngIf="reward.type == 'quest'">
<select (change)="sentence.changeQuestReward(role.intitule, rewardIndex, $event)"
[matTooltip]="translate.instant('role_reward_type_newQuest_tooltip')"
matTooltipPosition="above" [matTooltipDisabled]="!tooltipService.activatedTooltips">
<option [ngValue]="null" selected disabled>{{'role_reward_quest_placeholder' | translate}}</option>
<ng-container *ngFor="let mission of scenario.missions; let indexMission = index">
<ng-container *ngFor="let quest of mission.roles; let indexRole = index">
<option [ngValue]="quest.questName" [selected]="sentence.getQuestReward(rewardIndex).intitule == quest.intitule && sentence.getQuestReward(rewardIndex).questName == quest.questName"
*ngIf="role.intitule && quest.questName && role.intitule == quest.intitule && role.questName != quest.questName">
{{quest.questName}}
</option>
</ng-container>
</ng-container>
</select>
</div>
<div class="form-result-results-result-skill" *ngIf="reward.type == 'skill'">
<input type="number" [(ngModel)]="sentence.getSkillReward(rewardIndex).quantity"/>
<select [(ngModel)]="sentence.getSkillReward(rewardIndex).skill"
[matTooltip]="translate.instant('role_reward_type_skill_tooltip')"
matTooltipPosition="above" [matTooltipDisabled]="!tooltipService.activatedTooltips">
<ng-container *ngFor="let skill of role.ressources">
<option [ngValue]="skill" *ngIf="skill.type == 'attribut'">{{skill.name}}</option>
</ng-container>
</select>
</div>
<div class="form-result-results-result-character" *ngIf="reward.type == 'character'">
<select [(ngModel)]="sentence.getCharacterReward(rewardIndex).character"
[matTooltip]="translate.instant('role_reward_type_character_tooltip')"
matTooltipPosition="above" [matTooltipDisabled]="!tooltipService.activatedTooltips">
<option [ngValue]="character" *ngFor="let character of scenario.characters">{{character.name}}</option>
</select>
</div>
<div class="form-result-results-result-object" *ngIf="reward.type == 'object'">
<input type="number" [(ngModel)]="sentence.getObjectReward(rewardIndex).quantity"/>
<select [(ngModel)]="sentence.getObjectReward(rewardIndex).object"
[matTooltip]="translate.instant('role_reward_type_object_tooltip')"
matTooltipPosition="above" [matTooltipDisabled]="!tooltipService.activatedTooltips">
<ng-container *ngFor="let ressource of scenario.ressources">
<option [ngValue]="ressource" *ngIf="ressource.type == 'ressource'">{{ressource.name}}</option>
</ng-container>
<ng-container *ngFor="let ressource of role.ressources">
<option [ngValue]="ressource" *ngIf="ressource.type == 'ressource'">{{ressource.name}}</option>
</ng-container>
</select>
</div>
<button mat-button class="form-result-button-remove" (click)="sentence.removeReward(rewardIndex)"><mat-icon fontIcon="remove"></mat-icon></button>
</div>
<button mat-button class="form-result-button-add" (click)="sentence.addReward()"><mat-icon fontIcon="add"></mat-icon></button>
</div>
</div>
<button mat-button class="form-sentence-delete" (click)="deleteDeclarativeSentence(sentence.ID)">{{'discussion_buttons_deleteDeclarativeSentence' | translate}}</button> <button mat-button class="form-sentence-delete" (click)="deleteDeclarativeSentence(sentence.ID)">{{'discussion_buttons_deleteDeclarativeSentence' | translate}}</button>
</div> </div>
</mat-expansion-panel> </mat-expansion-panel>
...@@ -92,10 +238,76 @@ ...@@ -92,10 +238,76 @@
</div> </div>
<div class="form-result"> <div class="form-result">
<label for="result">{{'discussion_result_label' | translate}}</label> <label for="result">{{'discussion_result_label' | translate}}</label>
<select name="result"> <div class="form-result-results">
<option [ngValue]="" disabled selected>{{'discussion_result_placeholder' | translate}}</option> <div class="form-result-results-result" *ngFor="let reward of sentence.rewards, let rewardIndex = index">
<div class="form-result-results-result-type">
<label>{{'role_reward_type_label' | translate}}</label>
<select [(ngModel)]="reward.type" (change)="sentence.changeRewardType(rewardIndex, reward.type)"
[matTooltip]="translate.instant('discussion_reward_type_interrogativeSentence_tooltip')"
matTooltipPosition="above" [matTooltipDisabled]="!tooltipService.activatedTooltips">
<option value="quest">{{'role_reward_type_newQuest' | translate}}</option>
<option value="skill">{{'role_reward_type_skill' | translate}}</option>
<option value="character">{{'role_reward_type_character' | translate}}</option>
<option value="object">{{'role_reward_type_object' | translate}}</option>
<!--<option value="discuss">Changer de discussion</option>-->
</select>
</div>
<div class="form-result-results-result-quest" *ngIf="reward.type == 'quest'">
<select (change)="sentence.changeQuestReward(role.intitule, rewardIndex, $event)"
[matTooltip]="translate.instant('role_reward_type_newQuest_tooltip')"
matTooltipPosition="above" [matTooltipDisabled]="!tooltipService.activatedTooltips">
<option [ngValue]="null" selected disabled>{{'role_reward_quest_placeholder' | translate}}</option>
<ng-container *ngFor="let mission of scenario.missions; let indexMission = index">
<ng-container *ngFor="let quest of mission.roles; let indexRole = index">
<option [ngValue]="quest.questName" [selected]="sentence.getQuestReward(rewardIndex).intitule == quest.intitule && sentence.getQuestReward(rewardIndex).questName == quest.questName"
*ngIf="role.intitule && quest.questName && role.intitule == quest.intitule && role.questName != quest.questName">
{{quest.questName}}
</option>
</ng-container>
</ng-container>
</select>
</div>
<div class="form-result-results-result-skill" *ngIf="reward.type == 'skill'">
<input type="number" [(ngModel)]="sentence.getSkillReward(rewardIndex).quantity"/>
<select [(ngModel)]="sentence.getSkillReward(rewardIndex).skill"
[matTooltip]="translate.instant('role_reward_type_skill_tooltip')"
matTooltipPosition="above" [matTooltipDisabled]="!tooltipService.activatedTooltips">
<ng-container *ngFor="let skill of role.ressources">
<option [ngValue]="skill" *ngIf="skill.type == 'attribut'">{{skill.name}}</option>
</ng-container>
</select>
</div>
<div class="form-result-results-result-character" *ngIf="reward.type == 'character'">
<select [(ngModel)]="sentence.getCharacterReward(rewardIndex).character"
[matTooltip]="translate.instant('role_reward_type_character_tooltip')"
matTooltipPosition="above" [matTooltipDisabled]="!tooltipService.activatedTooltips">
<option [ngValue]="character" *ngFor="let character of scenario.characters">{{character.name}}</option>
</select>
</div>
<div class="form-result-results-result-object" *ngIf="reward.type == 'object'">
<input type="number" [(ngModel)]="sentence.getObjectReward(rewardIndex).quantity"/>
<select [(ngModel)]="sentence.getObjectReward(rewardIndex).object"
[matTooltip]="translate.instant('role_reward_type_object_tooltip')"
matTooltipPosition="above" [matTooltipDisabled]="!tooltipService.activatedTooltips">
<ng-container *ngFor="let ressource of scenario.ressources">
<option [ngValue]="ressource" *ngIf="ressource.type == 'ressource'">{{ressource.name}}</option>
</ng-container>
<ng-container *ngFor="let ressource of role.ressources">
<option [ngValue]="ressource" *ngIf="ressource.type == 'ressource'">{{ressource.name}}</option>
</ng-container>
</select> </select>
</div> </div>
<button mat-button class="form-result-button-remove" (click)="sentence.removeReward(rewardIndex)"><mat-icon fontIcon="remove"></mat-icon></button>
</div>
<button mat-button class="form-result-button-add" (click)="sentence.addReward()"><mat-icon fontIcon="add"></mat-icon></button>
</div>
</div>
<button mat-button class="form-sentence-addResponse" (click)="addResponse(getSentenceAsInterrogativeSentence(sentence))">{{'discussion_buttons_newResponse' | translate}}</button> <button mat-button class="form-sentence-addResponse" (click)="addResponse(getSentenceAsInterrogativeSentence(sentence))">{{'discussion_buttons_newResponse' | translate}}</button>
...@@ -113,12 +325,6 @@ ...@@ -113,12 +325,6 @@
<label for="sentence">{{'discussion_response' | translate}}</label> <label for="sentence">{{'discussion_response' | translate}}</label>
<textarea name="sentence" [(ngModel)]="response.value"></textarea> <textarea name="sentence" [(ngModel)]="response.value"></textarea>
</div> </div>
<div class="form-result">
<label for="result">{{'discussion_result_label' | translate}}</label>
<select name="result">
<option [ngValue]="" disabled selected>{{'discussion_result_placeholder' | translate}}</option>
</select>
</div>
<div class="form-nextSentence"> <div class="form-nextSentence">
<label for="nextSentence">{{'discussion_nextSentence_label' | translate}}</label> <label for="nextSentence">{{'discussion_nextSentence_label' | translate}}</label>
<select name="nextSentence" [(ngModel)]="response.nextSentence"> <select name="nextSentence" [(ngModel)]="response.nextSentence">
...@@ -128,6 +334,79 @@ ...@@ -128,6 +334,79 @@
</ng-container> </ng-container>
</select> </select>
</div> </div>
<div class="form-result">
<label for="result">{{'discussion_result_label' | translate}}</label>
<div class="form-result-results">
<div class="form-result-results-result" *ngFor="let reward of response.rewards, let rewardIndex = index">
<div class="form-result-results-result-type">
<label>{{'role_reward_type_label' | translate}}</label>
<select [(ngModel)]="reward.type" (change)="response.changeRewardType(rewardIndex, reward.type)"
[matTooltip]="translate.instant('discussion_reward_type_response_tooltip')"
matTooltipPosition="above" [matTooltipDisabled]="!tooltipService.activatedTooltips">
<option value="quest">{{'role_reward_type_newQuest' | translate}}</option>
<option value="skill">{{'role_reward_type_skill' | translate}}</option>
<option value="character">{{'role_reward_type_character' | translate}}</option>
<option value="object">{{'role_reward_type_object' | translate}}</option>
<!--<option value="discuss">Changer de discussion</option>-->
</select>
</div>
<div class="form-result-results-result-quest" *ngIf="reward.type == 'quest'">
<select (change)="response.changeQuestReward(role.intitule, rewardIndex, $event)"
[matTooltip]="translate.instant('role_reward_type_newQuest_tooltip')"
matTooltipPosition="above" [matTooltipDisabled]="!tooltipService.activatedTooltips">
<option [ngValue]="null" selected disabled>{{'role_reward_quest_placeholder' | translate}}</option>
<ng-container *ngFor="let mission of scenario.missions; let indexMission = index">
<ng-container *ngFor="let quest of mission.roles; let indexRole = index">
<option [ngValue]="quest.questName" [selected]="response.getQuestReward(rewardIndex).intitule == quest.intitule && response.getQuestReward(rewardIndex).questName == quest.questName"
*ngIf="role.intitule && quest.questName && role.intitule == quest.intitule && role.questName != quest.questName">
{{quest.questName}}
</option>
</ng-container>
</ng-container>
</select>
</div>
<div class="form-result-results-result-skill" *ngIf="reward.type == 'skill'">
<input type="number" [(ngModel)]="response.getSkillReward(rewardIndex).quantity"/>
<select [(ngModel)]="response.getSkillReward(rewardIndex).skill"
[matTooltip]="translate.instant('role_reward_type_skill_tooltip')"
matTooltipPosition="above" [matTooltipDisabled]="!tooltipService.activatedTooltips">
<ng-container *ngFor="let skill of role.ressources">
<option [ngValue]="skill" *ngIf="skill.type == 'attribut'">{{skill.name}}</option>
</ng-container>
</select>
</div>
<div class="form-result-results-result-character" *ngIf="reward.type == 'character'">
<select [(ngModel)]="response.getCharacterReward(rewardIndex).character"
[matTooltip]="translate.instant('role_reward_type_character_tooltip')"
matTooltipPosition="above" [matTooltipDisabled]="!tooltipService.activatedTooltips">
<option [ngValue]="character" *ngFor="let character of scenario.characters">{{character.name}}</option>
</select>
</div>
<div class="form-result-results-result-object" *ngIf="reward.type == 'object'">
<input type="number" [(ngModel)]="response.getObjectReward(rewardIndex).quantity"/>
<select [(ngModel)]="response.getObjectReward(rewardIndex).object"
[matTooltip]="translate.instant('role_reward_type_object_tooltip')"
matTooltipPosition="above" [matTooltipDisabled]="!tooltipService.activatedTooltips">
<ng-container *ngFor="let ressource of scenario.ressources">
<option [ngValue]="ressource" *ngIf="ressource.type == 'ressource'">{{ressource.name}}</option>
</ng-container>
<ng-container *ngFor="let ressource of role.ressources">
<option [ngValue]="ressource" *ngIf="ressource.type == 'ressource'">{{ressource.name}}</option>
</ng-container>
</select>
</div>
<button mat-button class="form-result-button-remove" (click)="response.removeReward(rewardIndex)"><mat-icon fontIcon="remove"></mat-icon></button>
</div>
<button mat-button class="form-result-button-add" (click)="response.addReward()"><mat-icon fontIcon="add"></mat-icon></button>
</div>
</div>
<button mat-button class="form-sentence-delete" (click)="deleteResponse(getSentenceAsInterrogativeSentence(sentence), response.ID)" *ngIf="countResponses(sentence.ID) > 1">{{'discussion_buttons_deleteResponse' | translate}}</button> <button mat-button class="form-sentence-delete" (click)="deleteResponse(getSentenceAsInterrogativeSentence(sentence), response.ID)" *ngIf="countResponses(sentence.ID) > 1">{{'discussion_buttons_deleteResponse' | translate}}</button>
</div> </div>
</mat-expansion-panel> </mat-expansion-panel>
......
...@@ -61,6 +61,61 @@ mat-dialog-actions { ...@@ -61,6 +61,61 @@ mat-dialog-actions {
&-result { &-result {
margin-top: 20px; margin-top: 20px;
&-results {
&-result {
margin-bottom: 5px;
&-type {
display: flex;
justify-content: space-between;
select {
width: 200px;
}
}
&-skill, &-object {
margin-top: 3px;
width: 250px;
display: flex;
justify-content: space-between;
input {
width: 30px;
text-align: center;
}
select {
width: 200px;
}
}
&-character, &-quest {
margin-top: 3px;
width: 250px;
select {
width: 250px;
}
}
}
}
&-button {
&-add {
margin-top: 5px;
width: 250px;
}
&-remove {
position: relative;
left: 100%;
transform: translateX(-100%);
margin-top: 5px;
}
}
} }
&-result, &-nextSentence { &-result, &-nextSentence {
...@@ -68,6 +123,10 @@ mat-dialog-actions { ...@@ -68,6 +123,10 @@ mat-dialog-actions {
display: flex; display: flex;
justify-content: space-between; justify-content: space-between;
margin-bottom: 5px; margin-bottom: 5px;
}
&-nextSentence {
margin-top: 5px;
select { select {
width: 250px; width: 250px;
......
...@@ -9,6 +9,8 @@ import { InterrogativeSentence } from 'src/app/class/sentence/interrogativeSente ...@@ -9,6 +9,8 @@ import { InterrogativeSentence } from 'src/app/class/sentence/interrogativeSente
import { Sentence } from 'src/app/class/sentence/sentence'; import { Sentence } from 'src/app/class/sentence/sentence';
import { TooltipService } from 'src/app/services/tooltip/tooltip.service'; import { TooltipService } from 'src/app/services/tooltip/tooltip.service';
import { SuppressDialogComponent } from '../suppress-dialog/suppress-dialog.component'; import { SuppressDialogComponent } from '../suppress-dialog/suppress-dialog.component';
import { QuestReward } from 'src/app/class/rewards/quest-reward/quest-reward';
import { Scenario } from 'src/app/class/scenario/scenario';
@Component({ @Component({
selector: 'app-discussion-dialog', selector: 'app-discussion-dialog',
...@@ -19,11 +21,13 @@ export class DiscussionDialogComponent implements OnInit { ...@@ -19,11 +21,13 @@ export class DiscussionDialogComponent implements OnInit {
role: Role; role: Role;
discussion: Discussion; discussion: Discussion;
scenario: Scenario;
constructor(public dialogRef: MatDialogRef<DiscussionDialogComponent>, constructor(public dialogRef: MatDialogRef<DiscussionDialogComponent>,
@Inject(MAT_DIALOG_DATA) public data: DialogDiscussionData, protected translate: TranslateService, protected tooltipService: TooltipService, public dialog: MatDialog) { @Inject(MAT_DIALOG_DATA) public data: DialogDiscussionData, protected translate: TranslateService, protected tooltipService: TooltipService, public dialog: MatDialog) {
this.role = this.data.role; this.role = this.data.role;
this.discussion = this.data.discussion; this.discussion = this.data.discussion;
this.scenario = this.data.scenario;
} }
ngOnInit(): void { ngOnInit(): void {
...@@ -177,4 +181,5 @@ export class DiscussionDialogComponent implements OnInit { ...@@ -177,4 +181,5 @@ export class DiscussionDialogComponent implements OnInit {
export interface DialogDiscussionData { export interface DialogDiscussionData {
role: Role; role: Role;
discussion: Discussion; discussion: Discussion;
scenario: Scenario;
} }
...@@ -53,6 +53,33 @@ export class GameCharactersComponent implements OnInit { ...@@ -53,6 +53,33 @@ export class GameCharactersComponent implements OnInit {
i--; i--;
} }
} }
role.discussions.forEach(discussion => {
for (let i = 0; i < discussion.rewards.length; i++) {
let reward: Reward = discussion.rewards[i];
if (reward.type == 'character') {
discussion.rewards.splice(i,1);
i--;
}
}
});
role.sentences.forEach(sentence => {
for (let i = 0; i < sentence.rewards.length; i++) {
let reward: Reward = sentence.rewards[i];
if (reward.type == 'character') {
sentence.rewards.splice(i,1);
i--;
}
}
});
role.responses.forEach(response => {
for (let i = 0; i < response.rewards.length; i++) {
let reward: Reward = response.rewards[i];
if (reward.type == 'character') {
response.rewards.splice(i,1);
i--;
}
}
});
role.tasks.forEach(inlineTasks => { role.tasks.forEach(inlineTasks => {
inlineTasks.forEach(task => { inlineTasks.forEach(task => {
if (task instanceof Task) { if (task instanceof Task) {
...@@ -103,6 +130,39 @@ export class GameCharactersComponent implements OnInit { ...@@ -103,6 +130,39 @@ export class GameCharactersComponent implements OnInit {
} }
} }
} }
role.discussions.forEach(discussion => {
for (let i = 0; i < discussion.rewards.length; i++) {
let reward: Reward = discussion.rewards[i];
if (reward.type == 'character') {
if ((reward as CharacterReward).character == this.scenario.characters[index]) {
discussion.rewards.splice(i,1);
i--;
}
}
}
});
role.sentences.forEach(sentence => {
for (let i = 0; i < sentence.rewards.length; i++) {
let reward: Reward = sentence.rewards[i];
if (reward.type == 'character') {
if ((reward as CharacterReward).character == this.scenario.characters[index]) {
sentence.rewards.splice(i,1);
i--;
}
}
}
});
role.responses.forEach(response => {
for (let i = 0; i < response.rewards.length; i++) {
let reward: Reward = response.rewards[i];
if (reward.type == 'character') {
if ((reward as CharacterReward).character == this.scenario.characters[index]) {
response.rewards.splice(i,1);
i--;
}
}
}
});
role.tasks.forEach(inlineTask => { role.tasks.forEach(inlineTask => {
inlineTask.forEach(task => { inlineTask.forEach(task => {
if (task instanceof Task) { if (task instanceof Task) {
......
...@@ -131,6 +131,7 @@ matTooltipPosition="left" [matTooltipDisabled]="!tooltipService.activatedTooltip ...@@ -131,6 +131,7 @@ matTooltipPosition="left" [matTooltipDisabled]="!tooltipService.activatedTooltip
<select (change)="changeQuestReward(i, $event)" <select (change)="changeQuestReward(i, $event)"
[matTooltip]="translate.instant('role_reward_type_newQuest_tooltip')" [matTooltip]="translate.instant('role_reward_type_newQuest_tooltip')"
matTooltipPosition="above" [matTooltipDisabled]="!tooltipService.activatedTooltips"> matTooltipPosition="above" [matTooltipDisabled]="!tooltipService.activatedTooltips">
<option [ngValue]="null" selected disabled>{{'role_reward_quest_placeholder' | translate}}</option>
<ng-container *ngFor="let mission of scenario.missions; let indexMission = index"> <ng-container *ngFor="let mission of scenario.missions; let indexMission = index">
<ng-container *ngFor="let quest of mission.roles; let indexRole = index"> <ng-container *ngFor="let quest of mission.roles; let indexRole = index">
<option [ngValue]="quest.questName" [selected]="getQuestReward(i).intitule == quest.intitule && getQuestReward(i).questName == quest.questName" <option [ngValue]="quest.questName" [selected]="getQuestReward(i).intitule == quest.intitule && getQuestReward(i).questName == quest.questName"
......
...@@ -219,6 +219,54 @@ export class RoleComponent implements OnInit { ...@@ -219,6 +219,54 @@ export class RoleComponent implements OnInit {
const dialogRef = this.dialog.open(CleanDialogComponent, { data: this.translate.instant('role_clean')+' '+(this.role.intitule ? '<'+this.role.intitule+'>' : (this.i+1)) }); const dialogRef = this.dialog.open(CleanDialogComponent, { data: this.translate.instant('role_clean')+' '+(this.role.intitule ? '<'+this.role.intitule+'>' : (this.i+1)) });
dialogRef.afterClosed().subscribe(result => { dialogRef.afterClosed().subscribe(result => {
if (result == true) { if (result == true) {
this.scenario.missions.forEach(mission => {
mission.roles.forEach(role => {
if (role.intitule == this.role.intitule) {
for (let i = 0; i < role.rewards.length; i++) {
let reward = role.rewards[i];
if (reward.type == 'quest') {
if ((reward as QuestReward).questName == this.role.questName) {
role.rewards.splice(i,1);
i--;
}
}
}
role.discussions.forEach(discussion => {
for (let i = 0; i < discussion.rewards.length; i++) {
let reward = discussion.rewards[i];
if (reward.type == 'quest') {
if ((reward as QuestReward).questName == this.role.questName) {
discussion.rewards.splice(i,1);
i--;
}
}
}
});
role.sentences.forEach(sentence => {
for (let i = 0; i < sentence.rewards.length; i++) {
let reward = sentence.rewards[i];
if (reward.type == 'quest') {
if ((reward as QuestReward).questName == this.role.questName) {
sentence.rewards.splice(i,1);
i--;
}
}
}
});
role.responses.forEach(response => {
for (let i = 0; i < response.rewards.length; i++) {
let reward = response.rewards[i];
if (reward.type == 'quest') {
if ((reward as QuestReward).questName == this.role.questName) {
response.rewards.splice(i,1);
i--;
}
}
}
});
}
});
});
this.role.intitule = ''; this.role.intitule = '';
this.role.questName = ''; this.role.questName = '';
this.role.description = ''; this.role.description = '';
...@@ -226,6 +274,9 @@ export class RoleComponent implements OnInit { ...@@ -226,6 +274,9 @@ export class RoleComponent implements OnInit {
this.role.rewards = []; this.role.rewards = [];
this.role.stuff = ''; this.role.stuff = '';
this.role.supplementaryRoles = []; this.role.supplementaryRoles = [];
this.role.discussions = [];
this.role.sentences = [];
this.role.responses = [];
this.role.tasks.forEach(inlineTasks => { this.role.tasks.forEach(inlineTasks => {
inlineTasks.forEach(task => { inlineTasks.forEach(task => {
this.role.ressources.forEach(ressource => { this.role.ressources.forEach(ressource => {
...@@ -287,7 +338,52 @@ export class RoleComponent implements OnInit { ...@@ -287,7 +338,52 @@ export class RoleComponent implements OnInit {
dialogRef.afterClosed().subscribe(result => { dialogRef.afterClosed().subscribe(result => {
let missionIndex: number = this.scenario.missions.findIndex(mission => mission == this.mission); let missionIndex: number = this.scenario.missions.findIndex(mission => mission == this.mission);
if (result == true) { if (result == true) {
this.mission.roles.forEach(role => { this.scenario.missions.forEach(mission => {
mission.roles.forEach(role => {
if (role.intitule == this.role.intitule) {
for (let i = 0; i < role.rewards.length; i++) {
let reward = role.rewards[i];
if (reward.type == 'quest') {
if ((reward as QuestReward).questName == this.role.questName) {
role.rewards.splice(i,1);
i--;
}
}
}
role.discussions.forEach(discussion => {
for (let i = 0; i < discussion.rewards.length; i++) {
let reward = discussion.rewards[i];
if (reward.type == 'quest') {
if ((reward as QuestReward).questName == this.role.questName) {
discussion.rewards.splice(i,1);
i--;
}
}
}
});
role.sentences.forEach(sentence => {
for (let i = 0; i < sentence.rewards.length; i++) {
let reward = sentence.rewards[i];
if (reward.type == 'quest') {
if ((reward as QuestReward).questName == this.role.questName) {
sentence.rewards.splice(i,1);
i--;
}
}
}
});
role.responses.forEach(response => {
for (let i = 0; i < response.rewards.length; i++) {
let reward = response.rewards[i];
if (reward.type == 'quest') {
if ((reward as QuestReward).questName == this.role.questName) {
response.rewards.splice(i,1);
i--;
}
}
}
});
}
role.tasks.forEach(inlineTask => { role.tasks.forEach(inlineTask => {
inlineTask.forEach(task => { inlineTask.forEach(task => {
if (task instanceof Task) { if (task instanceof Task) {
...@@ -300,6 +396,7 @@ export class RoleComponent implements OnInit { ...@@ -300,6 +396,7 @@ export class RoleComponent implements OnInit {
}); });
}); });
}); });
});
this.mission.roles.splice(this.i, 1); this.mission.roles.splice(this.i, 1);
this.scenario.traces.push(new Trace(this.scenario.traces.length,'delete',missionIndex,this.i,'all','Role_['+(this.i)+']','#9AD5EC')); this.scenario.traces.push(new Trace(this.scenario.traces.length,'delete',missionIndex,this.i,'all','Role_['+(this.i)+']','#9AD5EC'));
this.minimapService.reset(); this.minimapService.reset();
...@@ -348,19 +445,70 @@ export class RoleComponent implements OnInit { ...@@ -348,19 +445,70 @@ export class RoleComponent implements OnInit {
if (result == true) { if (result == true) {
for (let i = 0; i < this.role.rewards.length; i++) { for (let i = 0; i < this.role.rewards.length; i++) {
let reward: Reward = this.role.rewards[i]; let reward: Reward = this.role.rewards[i];
if (reward.type = 'object') { if (reward.type == 'object') {
if (this.role.ressources[index] == (reward as ObjectReward).object) { if (this.role.ressources[index] == (reward as ObjectReward).object) {
this.role.rewards.splice(i,1); this.role.rewards.splice(i,1);
i--; i--;
} }
} }
if (reward.type = 'skill') { if (reward.type == 'skill') {
if (this.role.ressources[index] == (reward as SkillReward).skill) { if (this.role.ressources[index] == (reward as SkillReward).skill) {
this.role.rewards.splice(i,1); this.role.rewards.splice(i,1);
i--; i--;
} }
} }
} }
this.role.discussions.forEach(discussion => {
for (let i = 0; i < discussion.rewards.length; i++) {
let reward: Reward = discussion.rewards[i];
if (reward.type == 'object') {
if (this.role.ressources[index] == (reward as ObjectReward).object) {
discussion.rewards.splice(i,1);
i--;
}
}
if (reward.type == 'skill') {
if (this.role.ressources[index] == (reward as SkillReward).skill) {
discussion.rewards.splice(i,1);
i--;
}
}
}
});
this.role.sentences.forEach(sentence => {
for (let i = 0; i < sentence.rewards.length; i++) {
let reward: Reward = sentence.rewards[i];
if (reward.type == 'object') {
if (this.role.ressources[index] == (reward as ObjectReward).object) {
sentence.rewards.splice(i,1);
i--;
}
}
if (reward.type == 'skill') {
if (this.role.ressources[index] == (reward as SkillReward).skill) {
sentence.rewards.splice(i,1);
i--;
}
}
}
});
this.role.responses.forEach(response => {
for (let i = 0; i < response.rewards.length; i++) {
let reward: Reward = response.rewards[i];
if (reward.type == 'object') {
if (this.role.ressources[index] == (reward as ObjectReward).object) {
response.rewards.splice(i,1);
i--;
}
}
if (reward.type == 'skill') {
if (this.role.ressources[index] == (reward as SkillReward).skill) {
response.rewards.splice(i,1);
i--;
}
}
}
});
this.role.tasks.forEach(inlineTasks => { this.role.tasks.forEach(inlineTasks => {
inlineTasks.forEach(task => { inlineTasks.forEach(task => {
if (task instanceof Task) { if (task instanceof Task) {
......
...@@ -52,6 +52,39 @@ export class RulesComponent implements OnInit { ...@@ -52,6 +52,39 @@ export class RulesComponent implements OnInit {
} }
} }
} }
role.discussions.forEach(discussion => {
for (let i = 0; i < discussion.rewards.length; i++) {
let reward: Reward = discussion.rewards[i];
if (reward.type == 'object') {
if (ressource == (reward as ObjectReward).object) {
discussion.rewards.splice(i,1);
i--;
}
}
}
});
role.sentences.forEach(sentence => {
for (let i = 0; i < sentence.rewards.length; i++) {
let reward: Reward = sentence.rewards[i];
if (reward.type == 'object') {
if (ressource == (reward as ObjectReward).object) {
sentence.rewards.splice(i,1);
i--;
}
}
}
});
role.responses.forEach(response => {
for (let i = 0; i < response.rewards.length; i++) {
let reward: Reward = response.rewards[i];
if (reward.type == 'object') {
if (ressource == (reward as ObjectReward).object) {
response.rewards.splice(i,1);
i--;
}
}
}
});
role.tasks.forEach(inlineTasks => { role.tasks.forEach(inlineTasks => {
inlineTasks.forEach(task => { inlineTasks.forEach(task => {
if (task instanceof Task) { if (task instanceof Task) {
...@@ -125,6 +158,39 @@ export class RulesComponent implements OnInit { ...@@ -125,6 +158,39 @@ export class RulesComponent implements OnInit {
} }
} }
} }
role.discussions.forEach(discussion => {
for (let i = 0; i < discussion.rewards.length; i++) {
let reward: Reward = discussion.rewards[i];
if (reward.type == 'object') {
if (this.scenario.ressources[index] == (reward as ObjectReward).object) {
discussion.rewards.splice(i,1);
i--;
}
}
}
});
role.sentences.forEach(sentence => {
for (let i = 0; i < sentence.rewards.length; i++) {
let reward: Reward = sentence.rewards[i];
if (reward.type == 'object') {
if (this.scenario.ressources[index] == (reward as ObjectReward).object) {
sentence.rewards.splice(i,1);
i--;
}
}
}
});
role.responses.forEach(response => {
for (let i = 0; i < response.rewards.length; i++) {
let reward: Reward = response.rewards[i];
if (reward.type == 'object') {
if (this.scenario.ressources[index] == (reward as ObjectReward).object) {
response.rewards.splice(i,1);
i--;
}
}
}
});
role.tasks.forEach(inlineTasks => { role.tasks.forEach(inlineTasks => {
inlineTasks.forEach(task => { inlineTasks.forEach(task => {
if (task instanceof Task) { if (task instanceof Task) {
......
...@@ -39,7 +39,7 @@ export class DiscussionsComponent implements OnInit { ...@@ -39,7 +39,7 @@ export class DiscussionsComponent implements OnInit {
this.role.discussions.push(discussion); this.role.discussions.push(discussion);
const dialogRef = this.dialog.open(DiscussionDialogComponent, { const dialogRef = this.dialog.open(DiscussionDialogComponent, {
width: '60vw', width: '60vw',
data: { role: this.role, discussion: discussion } data: { role: this.role, discussion: discussion, scenario: this.scenario }
}); });
} }
} }
...@@ -47,7 +47,7 @@ export class DiscussionsComponent implements OnInit { ...@@ -47,7 +47,7 @@ export class DiscussionsComponent implements OnInit {
openDiscussion(discussion: Discussion) { openDiscussion(discussion: Discussion) {
const dialogRef = this.dialog.open(DiscussionDialogComponent, { const dialogRef = this.dialog.open(DiscussionDialogComponent, {
width: '60vw', width: '60vw',
data: { role: this.role, discussion: discussion } data: { role: this.role, discussion: discussion, scenario: this.scenario }
}); });
} }
......
...@@ -138,6 +138,7 @@ ...@@ -138,6 +138,7 @@
"role_reward_type_label": "Type", "role_reward_type_label": "Type",
"role_reward_type_newQuest": "Start a new quest", "role_reward_type_newQuest": "Start a new quest",
"role_reward_type_newQuest_tooltip": "Choose a quest from another mission with the same Role name", "role_reward_type_newQuest_tooltip": "Choose a quest from another mission with the same Role name",
"role_reward_quest_placeholder": "Name of the quest",
"role_reward_type_skill": "Develop a field of expertise", "role_reward_type_skill": "Develop a field of expertise",
"role_reward_type_skill_tooltip": "Choose a skill created below", "role_reward_type_skill_tooltip": "Choose a skill created below",
"role_reward_type_character": "Retrieve the contact of an NPC", "role_reward_type_character": "Retrieve the contact of an NPC",
...@@ -147,6 +148,7 @@ ...@@ -147,6 +148,7 @@
"role_reward_type_object": "Retrieve an item", "role_reward_type_object": "Retrieve an item",
"role_reward_type_object_placeholder": "Name of the object", "role_reward_type_object_placeholder": "Name of the object",
"role_reward_type_object_delete": "this Object of the Reward", "role_reward_type_object_delete": "this Object of the Reward",
"role_reward_type_object_tooltip": "Choose a created object",
"role_reward_type_other": "Other", "role_reward_type_other": "Other",
"role_reward_delete": "this Reward", "role_reward_delete": "this Reward",
"role_personnalization_title": "Customization", "role_personnalization_title": "Customization",
...@@ -434,7 +436,7 @@ ...@@ -434,7 +436,7 @@
"discussion_declarativeSentence": "Sentence", "discussion_declarativeSentence": "Sentence",
"discussion_interrogativeSentence": "Question", "discussion_interrogativeSentence": "Question",
"discussion_response": "Response", "discussion_response": "Response",
"discussion_result_label": "Result", "discussion_result_label": "Results",
"discussion_result_placeholder": "Select a result", "discussion_result_placeholder": "Select a result",
"discussion_nextSentence_label": "Next sentence", "discussion_nextSentence_label": "Next sentence",
"discussion_nextSentence_placeholder": "Select the next sentence", "discussion_nextSentence_placeholder": "Select the next sentence",
...@@ -448,6 +450,10 @@ ...@@ -448,6 +450,10 @@
"discussion_delete": "this Discussion", "discussion_delete": "this Discussion",
"discussion_declarativeSentence_delete": "this Sentence", "discussion_declarativeSentence_delete": "this Sentence",
"discussion_interrogativeSentence_delete": "this Question", "discussion_interrogativeSentence_delete": "this Question",
"discussion_response_delete": "this Response" "discussion_response_delete": "this Response",
"discussion_reward_type_discussion_tooltip": "",
"discussion_reward_type_declarativeSentence_tootlip": "",
"discussion_reward_type_interrogativeSentence_tooltip": "",
"discussion_reward_type_response_tooltip": ""
} }
\ No newline at end of file
...@@ -138,6 +138,7 @@ ...@@ -138,6 +138,7 @@
"role_reward_type_label": "Type", "role_reward_type_label": "Type",
"role_reward_type_newQuest": "Débuter une nouvelle quête", "role_reward_type_newQuest": "Débuter une nouvelle quête",
"role_reward_type_newQuest_tooltip": "Choisir une quête d'une autre mission avec le même nom de Rôle", "role_reward_type_newQuest_tooltip": "Choisir une quête d'une autre mission avec le même nom de Rôle",
"role_reward_quest_placeholder": "Nom de la quête",
"role_reward_type_skill": "Travailler un champ de compétence", "role_reward_type_skill": "Travailler un champ de compétence",
"role_reward_type_skill_tooltip": "Choisir une compétence créée ci-dessous", "role_reward_type_skill_tooltip": "Choisir une compétence créée ci-dessous",
"role_reward_type_character": "Récupérer le contact d'un PNJ", "role_reward_type_character": "Récupérer le contact d'un PNJ",
...@@ -146,6 +147,7 @@ ...@@ -146,6 +147,7 @@
"role_reward_type_objective_tooltip": "Choisir un objectif pédagogique créé ci-dessus", "role_reward_type_objective_tooltip": "Choisir un objectif pédagogique créé ci-dessus",
"role_reward_type_object": "Récupérer un objet", "role_reward_type_object": "Récupérer un objet",
"role_reward_type_object_placeholder": "Nom de l'objet", "role_reward_type_object_placeholder": "Nom de l'objet",
"role_reward_type_object_tooltip": "Choisir un objet créé",
"role_reward_type_object_delete": "cet Objet de la Récompense", "role_reward_type_object_delete": "cet Objet de la Récompense",
"role_reward_type_other": "Autre", "role_reward_type_other": "Autre",
"role_reward_delete": "cette Récompense", "role_reward_delete": "cette Récompense",
...@@ -434,7 +436,7 @@ ...@@ -434,7 +436,7 @@
"discussion_declarativeSentence": "Phrase", "discussion_declarativeSentence": "Phrase",
"discussion_interrogativeSentence": "Question", "discussion_interrogativeSentence": "Question",
"discussion_response": "Réponse", "discussion_response": "Réponse",
"discussion_result_label": "Résultat", "discussion_result_label": "Résultats",
"discussion_result_placeholder": "Choisir un résultat", "discussion_result_placeholder": "Choisir un résultat",
"discussion_nextSentence_label": "Phrase suivante", "discussion_nextSentence_label": "Phrase suivante",
"discussion_nextSentence_placeholder": "Choisir la phrase suivante", "discussion_nextSentence_placeholder": "Choisir la phrase suivante",
...@@ -448,5 +450,9 @@ ...@@ -448,5 +450,9 @@
"discussion_delete": "cette Discussion", "discussion_delete": "cette Discussion",
"discussion_declarativeSentence_delete": "cette Phrase", "discussion_declarativeSentence_delete": "cette Phrase",
"discussion_interrogativeSentence_delete": "cette Question", "discussion_interrogativeSentence_delete": "cette Question",
"discussion_response_delete": "cette Réponse" "discussion_response_delete": "cette Réponse",
"discussion_reward_type_discussion_tooltip": "",
"discussion_reward_type_declarativeSentence_tootlip": "",
"discussion_reward_type_interrogativeSentence_tooltip": "",
"discussion_reward_type_response_tooltip": ""
} }
\ No newline at end of file
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