Skip to content

Commit

Permalink
feat(Survivors): Update the front to the new jobs parsing
Browse files Browse the repository at this point in the history
  • Loading branch information
leonard-IMBERT committed Apr 3, 2019
1 parent b725cd3 commit 3c5eb47
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
4 changes: 2 additions & 2 deletions src/Survivor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ type Survivor = {
Health: string,
Items: string,
Conditions: string | null,
Jobs: string | null,
Jobs: [{ Name: string, Level: string }],
id: string | null
}

export default Survivor;
export default Survivor;
8 changes: 3 additions & 5 deletions src/components/SideBar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@ function funct(str: string): (surv: Survivor) => boolean {
case 'jobs':
return (surv: Survivor) => value.split(',').every((job) => {
if (surv.Jobs != null) {
return surv.Jobs.toLowerCase().match(job.toLowerCase()) != null;
return surv.Jobs.reduce((acc, j) => acc + j.Name, '')
.toLowerCase().match(job.toLowerCase()) != null;
} return false;
});
case 'items':
Expand Down Expand Up @@ -94,17 +95,14 @@ export default class SideBar extends Vue {
Health: `${inhab.Health}/${inhab.MaxHealth}`,
Items: `(${numItems}) ${inhab.items.toString().replace(/,/g, ', ')}`,
Conditions: null,
Jobs: null,
Jobs: inhab.jobs,
id: uuid.v4(),
};
// Pretifiying the conditions and jobs
if (!inhab.conditions.includes('')) {
survivor.Conditions = inhab.conditions.toString().replace(/,/g, ', ');
}
if (!inhab.jobs.includes('')) {
survivor.Jobs = inhab.jobs.toString().replace(/,/g, ', ');
}
return survivor;
});
Expand Down
4 changes: 3 additions & 1 deletion src/components/Survivor.vue
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@
<li>Health: {{ survivor.Health }}</li>
<li>Items: {{ survivor.Items }}</li>
<li v-if="survivor.Conditions != null"> Conditions: {{ survivor.Conditions }}</li>
<li v-if="survivor.Jobs != null">Jobs: {{ survivor.Jobs }}</li>
<li v-if="survivor.Jobs != null">Jobs: {{
survivor.Jobs.map(job => `${job.Name} ${job.Level}`).toString()
}}</li>
</ul>
</div>
</li>
Expand Down

0 comments on commit 3c5eb47

Please sign in to comment.