Commit 5a322757 authored by Romain DELEAU's avatar Romain DELEAU

task reward side-piece

parent 7e95f22b
......@@ -119,6 +119,7 @@
<div class="container-sider">
<div class="container-sider-title">{{getSiderTitle()}}</div>
<div class="container-sider-elements">
<app-rewards class="container-sider-elements-element" [task]="pieceDetailsService.pieceAsTask()" [role]="pieceDetailsService.parentAsRole()" *ngIf="pieceDetailsService.pieceIsTask()" [scenario]="scenario"></app-rewards>
<app-role-occurence class="container-sider-elements-element" [role]="pieceDetailsService.pieceAsRole()" *ngIf="pieceDetailsService.pieceIsRole()" [scenario]="scenario"></app-role-occurence>
<app-supplementary-task class="container-sider-elements-element" [task]="pieceDetailsService.pieceAsTask()" [role]="pieceDetailsService.parentAsRole()" *ngIf="pieceDetailsService.pieceIsTask()" [scenario]="scenario"></app-supplementary-task>
<app-repeat class="container-sider-elements-element" [task]="pieceDetailsService.pieceAsTask()" *ngIf="pieceDetailsService.pieceIsTask()" [scenario]="scenario"></app-repeat>
......
......@@ -313,6 +313,18 @@ export class AppComponent {
prerequire.ressource = role.ressources[i];
}
})
if (task.rewardType == 'object' || task.rewardType == 'skill') {
if (scenario.ressources.some(element => element.name == (task.reward as Ressource).name && element.type == (task.reward as Ressource).type && element.number == (task.reward as Ressource).number)) {
let i: number = scenario.ressources.findIndex(element => element.name == (task.reward as Ressource).name && element.type == (task.reward as Ressource).type && element.number == (task.reward as Ressource).number);
task.reward = scenario.ressources[i];
} else {
let i: number = role.ressources.findIndex(element => element.name == (task.reward as Ressource).name && element.type == (task.reward as Ressource).type && element.number == (task.reward as Ressource).number);
task.reward = role.ressources[i];
}
} else if (task.rewardType == 'character') {
let i: number = scenario.characters.findIndex(element => element.name == (task.reward as Character).name && element.description == (task.reward as Character).description && element.color == (task.reward as Character).color);
task.reward = scenario.characters[i];
}
}
});
});
......
......@@ -53,6 +53,7 @@ import { VerifyDialogComponent } from './components/dialogs/verify-dialog/verify
import { RoleNameDuplicateComponent } from './components/snackbars/role-name-duplicate/role-name-duplicate.component';
import { CopyRoleSuccessComponent } from './components/snackbars/copy-role-success/copy-role-success.component';
import { LegalDialogComponent } from './components/dialogs/legal-dialog/legal-dialog.component';
import { RewardsComponent } from './sider-pieces/rewards/rewards.component';
export function HttpLoaderFactory(http: HttpClient) {
return new TranslateHttpLoader(http);
......@@ -97,7 +98,8 @@ export function HttpLoaderFactory(http: HttpClient) {
VerifyDialogComponent,
RoleNameDuplicateComponent,
CopyRoleSuccessComponent,
LegalDialogComponent
LegalDialogComponent,
RewardsComponent
],
imports: [
BrowserModule,
......
......@@ -3,6 +3,7 @@ import { Comment } from "../comment/comment";
import { PrerequireRessource } from "../prerequires/prerequire-ressource/prerequire-ressource";
import { PrerequireTask } from "../prerequires/prerequire-task/prerequire-task";
import { Repeat } from "../repeat/repeat";
import { Ressource } from "../ressource/ressource";
import { SupplementaryRole } from "../supplementary-role/supplementary-role";
import { Symbol } from "../symbol/symbol";
......@@ -23,6 +24,11 @@ export class Task {
supplementaryRole!: SupplementaryRole;
interrupt: string = '';
rewardType: string = 'none'; //none / object / character / skill
//rewardName: string = '';
rewardQuantity: number = 1;
reward: (Character | Ressource | null) = null;
constructor(type: string) {
this.type = type;
}
......@@ -36,4 +42,9 @@ export class Task {
this.type = type;
}
}
public resetReward(): void {
this.reward = null;
this.rewardQuantity = 1;
}
}
......@@ -46,6 +46,10 @@ export class GameCharactersComponent implements OnInit {
inlineTasks.forEach(task => {
if (task instanceof Task) {
task.characters = [];
if (task.rewardType == 'character') {
task.resetReward();
task.rewardType = 'none';
}
}
});
});
......@@ -80,6 +84,10 @@ export class GameCharactersComponent implements OnInit {
if (typeof i !== 'undefined' && i !== -1) {
task?.characters.splice(i, 1);
}
if (task?.rewardType == 'character') {
task.resetReward();
task.rewardType = 'none';
}
});
});
});
......
......@@ -109,6 +109,10 @@ export class RoleComponent implements OnInit {
let index: number = task.prerequireRessources.findIndex(element => element.ressource == ressource);
task.prerequireRessources.splice(index, 1);
}
if ((task?.rewardType == 'object' || task?.rewardType == 'attribut') && task.reward == ressource) {
task.resetReward();
task.rewardType = 'none';
}
});
});
});
......@@ -179,6 +183,10 @@ export class RoleComponent implements OnInit {
task.prerequireRessources.splice(j, 1);
}
});
if ((task?.rewardType == 'object' || task?.rewardType == 'skill') && task.reward == this.role.ressources[index]) {
task.resetReward();
task.rewardType = 'none';
}
});
});
this.role.ressources.splice(index, 1);
......
......@@ -49,6 +49,10 @@ export class RulesComponent implements OnInit {
task.prerequireRessources.splice(j, 1);
}
});
if (task.rewardType == 'object' && ressource == task.reward) {
task.resetReward();
task.rewardType = 'none';
}
}
});
});
......@@ -83,6 +87,10 @@ export class RulesComponent implements OnInit {
task.prerequireRessources.splice(j, 1);
}
});
if (task?.rewardType == 'object' && this.scenario.ressources[index] == task.reward) {
task.resetReward();
task.rewardType = 'none';
}
});
});
});
......
<div class="piece"
[matTooltip]="translate.instant('rewards_tooltip')"
matTooltipPosition="before" [matTooltipDisabled]="!tooltipService.activatedTooltips">
<div class="piece-form">
<div class="piece-form-title">{{'rewards_title' | translate}}</div>
<div class="piece-form-content">
<div class="piece-form-content-type">
<label for="type">{{'rewards_type_label'| translate}}</label>
<select name="type" [(ngModel)]="task.rewardType" (change)="resetReward()">
<option value="none" selected>{{'rewards_type_none' | translate}}</option>
<option value="object">{{'rewards_type_object' | translate}}</option>
<option value="character">{{'rewards_type_character' | translate}}</option>
<option value="skill">{{'rewards_type_skill' | translate}}</option>
</select>
</div>
<div *ngIf="task.rewardType != 'none'">
<!--
<div class="piece-form-content-name">
<label for="name">{{'rewards_name_label' | translate}}</label>
<input type="text" name="name" [(ngModel)]="task.rewardName">
</div>
-->
<div class="piece-form-content-object" *ngIf="task.rewardType == 'object'">
<input type="number" name="quantity" [(ngModel)]="task.rewardQuantity"/>
<select name="object_name" [(ngModel)]="task.reward">
<option value="null" selected disabled>{{'rewards_object_placeholder' | translate}}</option>
<ng-container *ngFor="let ressource of scenario.ressources">
<option *ngIf="ressource.type == 'ressource'" [ngValue]="ressource">{{ressource.name}}</option>
</ng-container>
<ng-container *ngFor="let ressource of pieceDetailsService.parentAsRole().ressources">
<option *ngIf="ressource.type == 'ressource'" [ngValue]="ressource">{{ressource.name}}</option>
</ng-container>
</select>
</div>
<div class="piece-form-content-character" *ngIf="task.rewardType == 'character'">
<select name="character" [(ngModel)]="task.reward">
<option value="null" selected disabled>{{'rewards_character_placeholder' | translate}}</option>
<option *ngFor="let character of scenario.characters" [ngValue]="character">{{character.name}}</option>
</select>
</div>
<div class="piece-form-content-skill" *ngIf="task.rewardType == 'skill'">
<input type="number" name="quantity" [(ngModel)]="task.rewardQuantity"/>
<select name="skill" [(ngModel)]="task.reward">
<option value="null" selected disabled>{{'rewards_skill_placeholder' | translate}}</option>
<ng-container *ngFor="let ressource of pieceDetailsService.parentAsRole().ressources">
<option *ngIf="ressource.type == 'attribut'" [ngValue]="ressource">{{ressource.name}}</option>
</ng-container>
</select>
</div>
</div>
</div>
</div>
</div>
\ No newline at end of file
.piece {
--piece-background-color: #cfe3b9;
width: 300px;
position: relative;
background-color: var(--piece-background-color);
border: solid #707070 1px;
border-radius: 6px;
&-form {
margin: 10px 5px 10px 5px;
display: flex;
flex-direction: column;
&-title {
font-family: "Glacial Indifference Bold";
margin-bottom: 10px;
}
input {
width: 25px;
border: none;
border-radius: 10px;
padding: 5px 5px 5px 5px;
}
select {
border-radius: 10px;
border: none;
background-color: white;
margin-left: 10px;
width: 230px;
padding: 5px 5px 5px 5px;
}
&-content {
&-type, &-name, &-object, &-character, &-skill {
margin-bottom: 5px;
}
&-type, &-name, &-object {
display: flex;
justify-content: space-between;
}
&-name {
input {
width: 220px;
}
}
&-object, &-skill {
input {
width: 40px;
}
}
&-character, &-skill {
display: flex;
justify-content: right;
}
}
}
}
\ No newline at end of file
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { RewardsComponent } from './rewards.component';
describe('RewardsComponent', () => {
let component: RewardsComponent;
let fixture: ComponentFixture<RewardsComponent>;
beforeEach(async () => {
await TestBed.configureTestingModule({
declarations: [ RewardsComponent ]
})
.compileComponents();
fixture = TestBed.createComponent(RewardsComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});
import { Component, OnInit, Input } from '@angular/core';
import { TranslateService } from '@ngx-translate/core';
import { Role } from 'src/app/class/role/role';
import { Scenario } from 'src/app/class/scenario/scenario';
import { Task } from 'src/app/class/task/task';
import { PieceDetailsService } from 'src/app/services/piece-details/piece-details.service';
import { TooltipService } from 'src/app/services/tooltip/tooltip.service';
@Component({
selector: 'app-rewards',
templateUrl: './rewards.component.html',
styleUrls: ['./rewards.component.scss']
})
export class RewardsComponent implements OnInit {
@Input() scenario: Scenario = new Scenario();
@Input() task: Task = new Task('normal');
@Input() role: Role = new Role();
constructor(protected translate: TranslateService, protected tooltipService: TooltipService, protected pieceDetailsService: PieceDetailsService) { }
ngOnInit(): void {
}
resetReward() {
this.task.resetReward();
}
}
......@@ -369,5 +369,17 @@
"legals_credits_content1": "The texts on this site are licensed under CC-BY-NC-SA (Creative Commons with permission for use under the conditions of attribution, non-commercial use, and sharing under the same initial terms).\n\nIcons created by max.icons and Freepik, sourced from: www.flaticon.com and are licensed under CC-BY 3.0.\n\nDevelopment: Romain Deleau\n\nWeb design: Gaëlle Guigon\n\nThese works are part of the Nucléofil project, funded by the government as part of the recovery plan.",
"legals_credits_content2": "Additionally, they are the subject of a doctoral thesis at Sorbonne Université (at LIP6 in the team MOCAH), in collaboration with IMT Nord Europe.",
"legals_cookies_title": "Cookies",
"legals_cookies_content": "We do not record any cookies and do not save any personal data!"
"legals_cookies_content": "We do not record any cookies and do not save any personal data!",
"rewards_tooltip": "",
"rewards_title": "Result / Reward",
"rewards_type_label": "Type",
"rewards_type_none": "None",
"rewards_type_object": "Object",
"rewards_type_character": "Character contact",
"rewards_type_skill": "Skill",
"rewards_name_label": "Name",
"rewards_object_placeholder": "Name of the object",
"rewards_character_placeholder": "Character",
"rewards_skill_placeholder": "Skill"
}
\ No newline at end of file
......@@ -369,5 +369,17 @@
"legals_credits_content1": "Les textes de ce site sont sous licence CC-BY-NC-SA (Creative Commons avec autorisation d'utilisation sous condition d'attribution de paternité, d'usage non commercial, et de conditions de partage identiques aux initiales).\n\nIcônes réalisées par max.icons et Freepik, provenant de : www.flaticon.com et sont sous la licence CC-BY 3.0.\n\nDéveloppement : Romain Deleau\n\nWebdesign : Gaëlle Guigon\n\nCes travaux s'inscrivent dans le projet Nucléofil, financé par le gouvernement dans le cadre du plan de relance.",
"legals_credits_content2": "De plus, ils font l'objet d'un travail de doctorat à Sorbonne Université (au LIP6 dans l'équipe MOCAH), en collaboration avec IMT Nord Europe.",
"legals_cookies_title": "Cookies",
"legals_cookies_content": "Nous n'enregistrons aucun cookie et ne sauvegardons aucune donnée personnelle !"
"legals_cookies_content": "Nous n'enregistrons aucun cookie et ne sauvegardons aucune donnée personnelle !",
"rewards_tooltip": "",
"rewards_title": "Résultat / Récompense",
"rewards_type_label": "Type",
"rewards_type_none": "Aucune",
"rewards_type_object": "Objet",
"rewards_type_character": "Contact du personnage",
"rewards_type_skill": "Compétence",
"rewards_name_label": "Nom",
"rewards_object_placeholder": "Nom de l'objet",
"rewards_character_placeholder": "Personnage",
"rewards_skill_placeholder": "Compétence"
}
\ 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