Commit c33e8cc1 authored by Romain DELEAU's avatar Romain DELEAU

add discussion reward in role, discussion, sentence, response

parent f9ff153d
......@@ -48,6 +48,7 @@ import { Sentence } from './class/sentence/sentence';
import { InterrogativeSentence } from './class/sentence/interrogativeSentence/interrogative-sentence';
import { DeclarativeSentence } from './class/sentence/declarativeSentence/declarative-sentence';
import { ObjectReward } from './class/rewards/object-reward/object-reward';
import { DiscussionReward } from './class/rewards/discussion-reward/discussion-reward';
@Component({
selector: 'app-root',
......@@ -279,6 +280,9 @@ export class AppComponent {
if (rewardData.type == 'object') {
return Object.assign(new ObjectReward(), rewardData);
}
if (rewardData.type == 'discussion') {
return Object.assign(new DiscussionReward(), rewardData);
}
});
role.rewards.forEach((reward: Reward, index: number) => {
if (reward instanceof SkillReward) {
......@@ -328,6 +332,9 @@ export class AppComponent {
if (rewardData.type == 'object') {
return Object.assign(new ObjectReward(), rewardData);
}
if (rewardData.type == 'discussion') {
return Object.assign(new DiscussionReward(), rewardData);
}
});
discussion.rewards.forEach((reward: Reward, index: number) => {
if (reward instanceof SkillReward) {
......@@ -371,6 +378,9 @@ export class AppComponent {
if (rewardData.type == 'object') {
return Object.assign(new ObjectReward(), rewardData);
}
if (rewardData.type == 'discussion') {
return Object.assign(new DiscussionReward(), rewardData);
}
});
sentence.rewards.forEach((reward: Reward, index: number) => {
if (reward instanceof SkillReward) {
......@@ -407,6 +417,9 @@ export class AppComponent {
if (rewardData.type == 'object') {
return Object.assign(new ObjectReward(), rewardData);
}
if (rewardData.type == 'discussion') {
return Object.assign(new DiscussionReward(), rewardData);
}
});
response.rewards.forEach((reward: Reward, index: number) => {
if (reward instanceof SkillReward) {
......
import { Character } from "../character/character";
import { CharacterReward } from "../rewards/character-reward/character-reward";
import { DiscussionReward } from "../rewards/discussion-reward/discussion-reward";
import { ObjectReward } from "../rewards/object-reward/object-reward";
import { QuestReward } from "../rewards/quest-reward/quest-reward";
import { Reward } from "../rewards/reward";
......@@ -40,6 +41,9 @@ export class Discussion {
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;
case 'discussion': this.rewards[index] = new DiscussionReward();
//this.scenario.traces.push(new Trace(this.scenario.traces.length,'transform',this.missionIndex,this.i,'Reward_['+index+']_transform_into_[DiscussionReward]', 'Role_['+this.i+']', '#9AD5EC', '*'));
break;
}
}
......@@ -71,6 +75,10 @@ export class Discussion {
return this.rewards[index] as ObjectReward;
}
getDiscussionReward(index: number): DiscussionReward {
return this.rewards[index] as DiscussionReward;
}
changeQuestReward(roleIntitule: string, index: number, event: any) {
let value: string = event.target.value;
let reward = new QuestReward();
......
import { CharacterReward } from "../rewards/character-reward/character-reward";
import { DiscussionReward } from "../rewards/discussion-reward/discussion-reward";
import { ObjectReward } from "../rewards/object-reward/object-reward";
import { QuestReward } from "../rewards/quest-reward/quest-reward";
import { Reward } from "../rewards/reward";
......@@ -35,6 +36,9 @@ export class Response {
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;
case 'discussion': this.rewards[index] = new DiscussionReward();
//this.scenario.traces.push(new Trace(this.scenario.traces.length,'transform',this.missionIndex,this.i,'Reward_['+index+']_transform_into_[DiscussionReward]', 'Role_['+this.i+']', '#9AD5EC', '*'));
break;
}
}
......@@ -66,6 +70,10 @@ export class Response {
return this.rewards[index] as ObjectReward;
}
getDiscussionReward(index: number): DiscussionReward {
return this.rewards[index] as DiscussionReward;
}
changeQuestReward(roleIntitule: string, index: number, event: any) {
let value: string = event.target.value;
let reward = new QuestReward();
......
import { DiscussionReward } from './discussion-reward';
describe('DiscussionReward', () => {
it('should create an instance', () => {
expect(new DiscussionReward()).toBeTruthy();
});
});
import { Reward } from "../reward";
export class DiscussionReward extends Reward {
constructor() {
super('discussion');
}
discussionId: number = -1;
}
......@@ -9,6 +9,7 @@ import { Comment } from "../comment/comment";
import { Discussion } from "../discussion/discussion";
import { Sentence } from "../sentence/sentence";
import { Response } from "../response/response";
import { Character } from "../character/character";
export class Role {
......@@ -275,4 +276,12 @@ export class Role {
return cpt;
}
characterHasDiscussion(char: Character): boolean {
if (this.discussions.find(discussion => discussion.character == char) != undefined) {
return true;
} else {
return false;
}
}
}
import { CharacterReward } from "../rewards/character-reward/character-reward";
import { DiscussionReward } from "../rewards/discussion-reward/discussion-reward";
import { ObjectReward } from "../rewards/object-reward/object-reward";
import { QuestReward } from "../rewards/quest-reward/quest-reward";
import { Reward } from "../rewards/reward";
......@@ -34,6 +35,9 @@ export abstract class Sentence {
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;
case 'discussion': this.rewards[index] = new DiscussionReward();
//this.scenario.traces.push(new Trace(this.scenario.traces.length,'transform',this.missionIndex,this.i,'Reward_['+index+']_transform_into_[DiscussionReward]', 'Role_['+this.i+']', '#9AD5EC', '*'));
break;
}
}
......@@ -65,6 +69,10 @@ export abstract class Sentence {
return this.rewards[index] as ObjectReward;
}
getDiscussionReward(index: number): DiscussionReward {
return this.rewards[index] as DiscussionReward;
}
changeQuestReward(roleIntitule: string, index: number, event: any) {
let value: string = event.target.value;
let reward = new QuestReward();
......
......@@ -30,7 +30,7 @@
<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>-->
<option value="discussion">{{'role_reward_type_discussion' | translate}}</option>
</select>
</div>
......@@ -69,6 +69,21 @@
</select>
</div>
<div class="form-result-results-result-discussion" *ngIf="reward.type == 'discussion'">
<select [(ngModel)]="discussion.getDiscussionReward(rewardIndex).discussionId"
[matTooltip]="translate.instant('role_reward_type_discussion_tooltip')"
matTooltipPosition="above" [matTooltipDisabled]="!tooltipService.activatedTooltips">
<option [ngValue]="-1" selected disabled>{{'role_reward_type_discussion_placeholder' | translate}}</option>
<ng-container *ngFor="let character of scenario.characters">
<optgroup [label]="character.name" *ngIf="role.characterHasDiscussion(character)">
<ng-container *ngFor="let discuss of role.discussions">
<option [ngValue]="discuss.ID" *ngIf="discuss.character == character && discussion.ID != discuss.ID">{{discuss.name}}</option>
</ng-container>
</optgroup>
</ng-container>
</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"
......@@ -148,7 +163,7 @@
<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>-->
<option value="discussion">{{'role_reward_type_discussion' | translate}}</option>
</select>
</div>
......@@ -186,6 +201,21 @@
<option [ngValue]="character" *ngFor="let character of scenario.characters">{{character.name}}</option>
</select>
</div>
<div class="form-result-results-result-discussion" *ngIf="reward.type == 'discussion'">
<select [(ngModel)]="sentence.getDiscussionReward(rewardIndex).discussionId"
[matTooltip]="translate.instant('role_reward_type_discussion_tooltip')"
matTooltipPosition="above" [matTooltipDisabled]="!tooltipService.activatedTooltips">
<option [ngValue]="-1" selected disabled>{{'role_reward_type_discussion_placeholder' | translate}}</option>
<ng-container *ngFor="let character of scenario.characters">
<optgroup [label]="character.name" *ngIf="role.characterHasDiscussion(character)">
<ng-container *ngFor="let discuss of role.discussions">
<option [ngValue]="discuss.ID" *ngIf="discuss.character == character && discussion.ID != discuss.ID">{{discuss.name}}</option>
</ng-container>
</optgroup>
</ng-container>
</select>
</div>
<div class="form-result-results-result-object" *ngIf="reward.type == 'object'">
<input type="number" [(ngModel)]="sentence.getObjectReward(rewardIndex).quantity"/>
......@@ -249,7 +279,7 @@
<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>-->
<option value="discussion">{{'role_reward_type_discussion' | translate}}</option>
</select>
</div>
......@@ -287,6 +317,21 @@
<option [ngValue]="character" *ngFor="let character of scenario.characters">{{character.name}}</option>
</select>
</div>
<div class="form-result-results-result-discussion" *ngIf="reward.type == 'discussion'">
<select [(ngModel)]="sentence.getDiscussionReward(rewardIndex).discussionId"
[matTooltip]="translate.instant('role_reward_type_discussion_tooltip')"
matTooltipPosition="above" [matTooltipDisabled]="!tooltipService.activatedTooltips">
<option [ngValue]="-1" selected disabled>{{'role_reward_type_discussion_placeholder' | translate}}</option>
<ng-container *ngFor="let character of scenario.characters">
<optgroup [label]="character.name" *ngIf="role.characterHasDiscussion(character)">
<ng-container *ngFor="let discuss of role.discussions">
<option [ngValue]="discuss.ID" *ngIf="discuss.character == character && discussion.ID != discuss.ID">{{discuss.name}}</option>
</ng-container>
</optgroup>
</ng-container>
</select>
</div>
<div class="form-result-results-result-object" *ngIf="reward.type == 'object'">
<input type="number" [(ngModel)]="sentence.getObjectReward(rewardIndex).quantity"/>
......@@ -348,7 +393,7 @@
<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>-->
<option value="discussion">{{'role_reward_type_discussion' | translate}}</option>
</select>
</div>
......@@ -386,6 +431,21 @@
<option [ngValue]="character" *ngFor="let character of scenario.characters">{{character.name}}</option>
</select>
</div>
<div class="form-result-results-result-discussion" *ngIf="reward.type == 'discussion'">
<select [(ngModel)]="response.getDiscussionReward(rewardIndex).discussionId"
[matTooltip]="translate.instant('role_reward_type_discussion_tooltip')"
matTooltipPosition="above" [matTooltipDisabled]="!tooltipService.activatedTooltips">
<option [ngValue]="-1" selected disabled>{{'role_reward_type_discussion_placeholder' | translate}}</option>
<ng-container *ngFor="let character of scenario.characters">
<optgroup [label]="character.name" *ngIf="role.characterHasDiscussion(character)">
<ng-container *ngFor="let discuss of role.discussions">
<option [ngValue]="discuss.ID" *ngIf="discuss.character == character && discussion.ID != discuss.ID">{{discuss.name}}</option>
</ng-container>
</optgroup>
</ng-container>
</select>
</div>
<div class="form-result-results-result-object" *ngIf="reward.type == 'object'">
<input type="number" [(ngModel)]="response.getObjectReward(rewardIndex).quantity"/>
......
......@@ -92,7 +92,7 @@ mat-dialog-actions {
}
}
&-character, &-quest {
&-character, &-quest, &-discussion {
margin-top: 3px;
width: 250px;
......
......@@ -71,7 +71,7 @@ matTooltipPosition="left" [matTooltipDisabled]="!tooltipService.activatedTooltip
<option value="objective">{{'role_reward_type_objective' | translate}}</option>
<option value="objects" hidden>{{'role_reward_type_object' | translate}}</option>
<option value="object">{{'role_reward_type_object' | translate}}</option>
<!--<option value="discuss">Changer de discussion</option>-->
<option value="discussion">{{'role_reward_type_discussion' | translate}}</option>
<option value="other">{{'role_reward_type_other' | translate}}</option>
</select>
</div>
......@@ -92,6 +92,22 @@ matTooltipPosition="left" [matTooltipDisabled]="!tooltipService.activatedTooltip
<button mat-button (click)="removeReward(i)"><mat-icon fontIcon="remove"></mat-icon></button>
</div>
<div class="piece-form-rewards-reward-discussion" *ngIf="reward.type == 'discussion'">
<select [(ngModel)]="getDiscussionReward(i).discussionId" (change)="editTrace($event, 'Reward_['+i+']_discussion')"
[matTooltip]="translate.instant('role_reward_type_discussion_tooltip')"
matTooltipPosition="above" [matTooltipDisabled]="!tooltipService.activatedTooltips">
<option [ngValue]="-1" selected disabled>{{'role_reward_type_discussion_placeholder' | translate}}</option>
<ng-container *ngFor="let character of scenario.characters">
<optgroup [label]="character.name" *ngIf="role.characterHasDiscussion(character)">
<ng-container *ngFor="let discussion of role.discussions">
<option [ngValue]="discussion.ID" *ngIf="discussion.character == character">{{discussion.name}}</option>
</ng-container>
</optgroup>
</ng-container>
</select>
<button mat-button (click)="removeReward(i)"><mat-icon fontIcon="remove"></mat-icon></button>
</div>
<!--
<div class="piece-form-rewards-reward-discussion" *ngIf="reward.type == 'discuss'">
<select>
......
......@@ -29,6 +29,7 @@ import { CopyRoleSuccessComponent } from 'src/app/components/snackbars/copy-role
import { RoleOccurrence } from 'src/app/class/role-occurrence/role-occurrence';
import { ObjectReward } from 'src/app/class/rewards/object-reward/object-reward';
import { Reward } from 'src/app/class/rewards/reward';
import { DiscussionReward } from 'src/app/class/rewards/discussion-reward/discussion-reward';
@Component({
selector: 'app-role',
......@@ -613,6 +614,9 @@ export class RoleComponent implements OnInit {
case 'object': this.role.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;
case 'discussion': this.role.rewards[index] = new DiscussionReward();
this.scenario.traces.push(new Trace(this.scenario.traces.length,'transform',this.missionIndex,this.i,'Reward_['+index+']_transform_into_[DiscussionReward]', 'Role_['+this.i+']', '#9AD5EC', '*'));
break;
}
}
......@@ -657,6 +661,10 @@ export class RoleComponent implements OnInit {
return this.role.rewards[index] as ObjectsReward;
}
getDiscussionReward(index: number): DiscussionReward {
return this.role.rewards[index] as DiscussionReward;
}
addObject(index: number): void {
this.getObjectsReward(index).objects.push(new Ressource);
this.scenario.traces.push(new Trace(this.scenario.traces.length,'new',this.missionIndex,this.i,'Reward_['+index+']_object_['+this.getObjectsReward(index).objects.length+']', 'Role_['+this.i+']', '#9AD5EC', '*'));
......
......@@ -3,7 +3,10 @@ import { MatDialog } from '@angular/material/dialog';
import { TranslateService } from '@ngx-translate/core';
import { Character } from 'src/app/class/character/character';
import { Discussion } from 'src/app/class/discussion/discussion';
import { Mission } from 'src/app/class/mission/mission';
import { Response } from 'src/app/class/response/response';
import { DiscussionReward } from 'src/app/class/rewards/discussion-reward/discussion-reward';
import { Reward } from 'src/app/class/rewards/reward';
import { Role } from 'src/app/class/role/role';
import { Scenario } from 'src/app/class/scenario/scenario';
import { DeclarativeSentence } from 'src/app/class/sentence/declarativeSentence/declarative-sentence';
......@@ -73,6 +76,50 @@ export class DiscussionsComponent implements OnInit {
}
}
this.role.discussions.splice(discussionIndex,1);
for (let rewardIndex: number = 0; rewardIndex < this.role.rewards.length; rewardIndex++) {
let reward: Reward = this.role.rewards[rewardIndex];
if (reward.type == 'discussion') {
if ((reward as DiscussionReward).discussionId == discussion.ID) {
this.role.rewards.splice(rewardIndex,1);
rewardIndex--;
}
}
}
this.role.discussions.forEach(discuss => {
for (let rewardIndex: number = 0; rewardIndex < discuss.rewards.length; rewardIndex++) {
let reward: Reward = discuss.rewards[rewardIndex];
if (reward.type == 'discussion') {
if ((reward as DiscussionReward).discussionId == discussion.ID) {
discuss.rewards.splice(rewardIndex,1);
rewardIndex--;
}
}
}
});
this.role.sentences.forEach(sentence => {
for (let rewardIndex: number = 0; rewardIndex < sentence.rewards.length; rewardIndex++) {
let reward: Reward = sentence.rewards[rewardIndex];
if (reward.type == 'discussion') {
if ((reward as DiscussionReward).discussionId == discussion.ID) {
sentence.rewards.splice(rewardIndex,1);
rewardIndex--;
}
}
}
});
this.role.discussions.forEach(response => {
for (let rewardIndex: number = 0; rewardIndex < response.rewards.length; rewardIndex++) {
let reward: Reward = response.rewards[rewardIndex];
if (reward.type == 'discussion') {
if ((reward as DiscussionReward).discussionId == discussion.ID) {
response.rewards.splice(rewardIndex,1);
rewardIndex--;
}
}
}
});
}
});
}
......
......@@ -150,6 +150,9 @@
"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_discussion_placeholder": "Name of the discussion",
"role_reward_type_discussion": "Unlock a discussion",
"role_reward_type_discussion_tooltip": "Choose the name of the discussion",
"role_reward_delete": "this Reward",
"role_personnalization_title": "Customization",
"role_personnalization_label": "Appearance, equipment",
......
......@@ -150,6 +150,9 @@
"role_reward_type_object_tooltip": "Choisir un objet créé",
"role_reward_type_object_delete": "cet Objet de la Récompense",
"role_reward_type_other": "Autre",
"role_reward_type_discussion_placeholder": "Nom de la discussion",
"role_reward_type_discussion": "Débloquer une discussion",
"role_reward_type_discussion_tooltip": "Choisir le nom de la discussion",
"role_reward_delete": "cette Récompense",
"role_personnalization_title": "Personnalisation",
"role_personnalization_label": "Apparence, équipement",
......
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