Commit 566ce1a6 authored by Romain DELEAU's avatar Romain DELEAU

role rewards

parent 9a3ce3f8
...@@ -54,7 +54,7 @@ ...@@ -54,7 +54,7 @@
</div> </div>
<div style="display: flex; flex-direction: row;"> <div style="display: flex; flex-direction: row;">
<app-role [style.z-index]="2" [role]="role" [mission]="mission" [i]="i"></app-role> <app-role [style.z-index]="2" [scenario]="scenario" [role]="role" [mission]="mission" [i]="i"></app-role>
<div class="container-scenario-main-missions-mission-roles-role-tasks" [style.z-index]="1"> <div class="container-scenario-main-missions-mission-roles-role-tasks" [style.z-index]="1">
<div class="container-scenario-main-missions-mission-roles-role-tasks-inlineTasks" *ngFor="let tasks of role.tasks, let i = index" [style.z-index]="role.tasks.length+i"> <div class="container-scenario-main-missions-mission-roles-role-tasks-inlineTasks" *ngFor="let tasks of role.tasks, let i = index" [style.z-index]="role.tasks.length+i">
<div *ngFor="let task of tasks, let j = index" [style.z-index]="tasks.length-j"> <div *ngFor="let task of tasks, let j = index" [style.z-index]="tasks.length-j">
......
...@@ -15,6 +15,13 @@ import { SupplementaryRole } from './class/supplementary-role/supplementary-role ...@@ -15,6 +15,13 @@ import { SupplementaryRole } from './class/supplementary-role/supplementary-role
import { Symbol } from './class/symbol/symbol'; import { Symbol } from './class/symbol/symbol';
import { PieceDetailsService } from './services/piece-details/piece-details.service'; import { PieceDetailsService } from './services/piece-details/piece-details.service';
import { Comment } from './class/comment/comment'; import { Comment } from './class/comment/comment';
import { Reward } from './class/rewards/reward';
import { SkillReward } from './class/rewards/skill-reward/skill-reward';
import { CharacterReward } from './class/rewards/character-reward/character-reward';
import { QuestReward } from './class/rewards/quest-reward/quest-reward';
import { ObjectsReward } from './class/rewards/objects-reward/objects-reward';
import { ObjectiveReward } from './class/rewards/objective-reward/objective-reward';
import { OtherReward } from './class/rewards/other-reward/other-reward';
@Component({ @Component({
selector: 'app-root', selector: 'app-root',
...@@ -99,6 +106,41 @@ export class AppComponent { ...@@ -99,6 +106,41 @@ export class AppComponent {
role.ressources = role.ressources.map((ressourceData: any) => Object.assign(new Ressource(), ressourceData)); role.ressources = role.ressources.map((ressourceData: any) => Object.assign(new Ressource(), ressourceData));
role.occurences = role.occurences.map((occurrenceData: any) => Object.assign(new RoleOccurrence(), occurrenceData)); role.occurences = role.occurences.map((occurrenceData: any) => Object.assign(new RoleOccurrence(), occurrenceData));
role.supplementaryRoles = role.supplementaryRoles.map((supplementaryRoleData: any) => Object.assign(new SupplementaryRole(), supplementaryRoleData)); role.supplementaryRoles = role.supplementaryRoles.map((supplementaryRoleData: any) => Object.assign(new SupplementaryRole(), supplementaryRoleData));
role.rewards = role.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 == 'objects') {
return Object.assign(new ObjectsReward(), rewardData);
}
if (rewardData.type == 'objective') {
return Object.assign(new ObjectiveReward(), rewardData);
}
if (rewardData.type == 'other') {
return Object.assign(new OtherReward(), rewardData);
}
});
role.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 ObjectiveReward) {
let i: number = role.educationnalObjectives.findIndex(element => element.objective == reward.objective.objective);
reward.objective = role.educationnalObjectives[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) {
......
import { RoleEducationnalObjective } from "../../role-educationnal-objective/role-educationnal-objective";
import { Reward } from "../reward"; import { Reward } from "../reward";
export class ObjectiveReward extends Reward { export class ObjectiveReward extends Reward {
...@@ -6,5 +7,5 @@ export class ObjectiveReward extends Reward { ...@@ -6,5 +7,5 @@ export class ObjectiveReward extends Reward {
super('objective'); super('objective');
} }
name: string = ''; objective!: RoleEducationnalObjective;
} }
...@@ -7,5 +7,5 @@ export class QuestReward extends Reward { ...@@ -7,5 +7,5 @@ export class QuestReward extends Reward {
super('quest'); super('quest');
} }
quest!: Role; indexQuest!: number;
} }
...@@ -7,5 +7,6 @@ export class SkillReward extends Reward { ...@@ -7,5 +7,6 @@ export class SkillReward extends Reward {
super('skill'); super('skill');
} }
quantity: number = 1;
skill!: Ressource; skill!: Ressource;
} }
...@@ -60,7 +60,7 @@ ...@@ -60,7 +60,7 @@
</div> </div>
<div class="piece-form-rewards-reward-character" *ngIf="reward.type == 'character'"> <div class="piece-form-rewards-reward-character" *ngIf="reward.type == 'character'">
<select [(ngModel)]="getCharacterReward(i).character"> <select [(ngModel)]="getCharacterReward(i).character">
<option>Personnage 1</option> <option [ngValue]="character" *ngFor="let character of scenario.characters">{{character.name}}</option>
</select> </select>
<button mat-button (click)="removeReward(i)"><mat-icon fontIcon="remove"></mat-icon></button> <button mat-button (click)="removeReward(i)"><mat-icon fontIcon="remove"></mat-icon></button>
</div> </div>
...@@ -73,21 +73,25 @@ ...@@ -73,21 +73,25 @@
</div> </div>
--> -->
<div class="piece-form-rewards-reward-skill" *ngIf="reward.type == 'skill'"> <div class="piece-form-rewards-reward-skill" *ngIf="reward.type == 'skill'">
<input type="number"/> <input type="number" [(ngModel)]="getSkillReward(i).quantity"/>
<select [(ngModel)]="getSkillReward(i).skill"> <select [(ngModel)]="getSkillReward(i).skill">
<option>Compétence 1</option> <ng-container *ngFor="let skill of role.ressources">
<option [ngValue]="skill" *ngIf="skill.type == 'attribut'">{{skill.name}}</option>
</ng-container>
</select> </select>
<button mat-button (click)="removeReward(i)"><mat-icon fontIcon="remove"></mat-icon></button> <button mat-button (click)="removeReward(i)"><mat-icon fontIcon="remove"></mat-icon></button>
</div> </div>
<div class="piece-form-rewards-reward-quest" *ngIf="reward.type == 'quest'"> <div class="piece-form-rewards-reward-quest" *ngIf="reward.type == 'quest'">
<select [(ngModel)]="getQuestReward(i).quest"> <select [(ngModel)]="getQuestReward(i).indexQuest">
<option>Quête 1</option> <ng-container *ngFor="let quest of mission.roles; let index = index">
<option [ngValue]="index" *ngIf="i != index">{{quest.intitule ? quest.intitule : 'Role '+(index+1)}}</option>
</ng-container>
</select> </select>
<button mat-button (click)="removeReward(i)"><mat-icon fontIcon="remove"></mat-icon></button> <button mat-button (click)="removeReward(i)"><mat-icon fontIcon="remove"></mat-icon></button>
</div> </div>
<div class="piece-form-rewards-reward-objective" *ngIf="reward.type == 'objective'"> <div class="piece-form-rewards-reward-objective" *ngIf="reward.type == 'objective'">
<select [(ngModel)]="getObjectiveReward(i).name"> <select [(ngModel)]="getObjectiveReward(i).objective">
<option>Objectif pédagoqique 1</option> <option [ngValue]="objective" *ngFor="let objective of role.educationnalObjectives">{{objective.objective}}</option>
</select> </select>
<button mat-button (click)="removeReward(i)"><mat-icon fontIcon="remove"></mat-icon></button> <button mat-button (click)="removeReward(i)"><mat-icon fontIcon="remove"></mat-icon></button>
</div> </div>
......
...@@ -6,10 +6,10 @@ import { ObjectiveReward } from 'src/app/class/rewards/objective-reward/objectiv ...@@ -6,10 +6,10 @@ import { ObjectiveReward } from 'src/app/class/rewards/objective-reward/objectiv
import { ObjectsReward } from 'src/app/class/rewards/objects-reward/objects-reward'; import { ObjectsReward } from 'src/app/class/rewards/objects-reward/objects-reward';
import { OtherReward } from 'src/app/class/rewards/other-reward/other-reward'; import { OtherReward } from 'src/app/class/rewards/other-reward/other-reward';
import { QuestReward } from 'src/app/class/rewards/quest-reward/quest-reward'; import { QuestReward } from 'src/app/class/rewards/quest-reward/quest-reward';
import { Reward } from 'src/app/class/rewards/reward';
import { SkillReward } from 'src/app/class/rewards/skill-reward/skill-reward'; import { SkillReward } from 'src/app/class/rewards/skill-reward/skill-reward';
import { RoleEducationnalObjective } from 'src/app/class/role-educationnal-objective/role-educationnal-objective'; import { RoleEducationnalObjective } from 'src/app/class/role-educationnal-objective/role-educationnal-objective';
import { Role } from 'src/app/class/role/role'; import { Role } from 'src/app/class/role/role';
import { Scenario } from 'src/app/class/scenario/scenario';
import { SupplementaryRole } from 'src/app/class/supplementary-role/supplementary-role'; import { SupplementaryRole } from 'src/app/class/supplementary-role/supplementary-role';
import { PieceDetailsService } from 'src/app/services/piece-details/piece-details.service'; import { PieceDetailsService } from 'src/app/services/piece-details/piece-details.service';
...@@ -20,6 +20,7 @@ import { PieceDetailsService } from 'src/app/services/piece-details/piece-detail ...@@ -20,6 +20,7 @@ import { PieceDetailsService } from 'src/app/services/piece-details/piece-detail
}) })
export class RoleComponent implements OnInit { export class RoleComponent implements OnInit {
@Input() scenario: Scenario = new Scenario();
@Input() role: Role = new Role(); @Input() role: Role = new Role();
@Input() mission: Mission = new Mission(); @Input() mission: Mission = new Mission();
@Input() i: number = 0; @Input() i: number = 0;
......
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