mirror of
https://github.com/em-squared/5e-drs.git
synced 2025-10-29 20:54:19 +00:00
support des alliés dans le calculateur de rencontres
This commit is contained in:
parent
5dcd1ceb7c
commit
9b9a54b134
2 changed files with 96 additions and 32 deletions
|
|
@ -47,9 +47,12 @@ export default {
|
||||||
state.creatures = []
|
state.creatures = []
|
||||||
},
|
},
|
||||||
addCreature: (state, payload) => {
|
addCreature: (state, payload) => {
|
||||||
payload.qty = 1
|
// payload.qty = 1
|
||||||
state.creatures.push(payload)
|
let c = Object.assign({}, payload)
|
||||||
state.creatures.sort((a, b) => { return sortByString(a.title, b.title) })
|
c.ally = false
|
||||||
|
state.creatures.push(c)
|
||||||
|
c = null
|
||||||
|
// state.creatures.sort((a, b) => { return sortByString(a.title, b.title) })
|
||||||
},
|
},
|
||||||
updateCreatures: (state, payload) => {
|
updateCreatures: (state, payload) => {
|
||||||
let creatureIndex = getResourceIndexInLibrary(payload, state.creatures)
|
let creatureIndex = getResourceIndexInLibrary(payload, state.creatures)
|
||||||
|
|
@ -58,9 +61,13 @@ export default {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
removeCreature: (state, payload) => {
|
removeCreature: (state, payload) => {
|
||||||
let creatureIndex = getResourceIndexInLibrary(payload, state.creatures)
|
if (payload >= 0) {
|
||||||
if (creatureIndex >= 0) {
|
state.creatures.splice(payload, 1)
|
||||||
state.creatures.splice(creatureIndex, 1)
|
}
|
||||||
|
},
|
||||||
|
switchCampCreature: (state, payload) => {
|
||||||
|
if (payload >= 0) {
|
||||||
|
state.creatures[payload].ally = !state.creatures[payload].ally
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
setCreatureQty: (state, payload) => {
|
setCreatureQty: (state, payload) => {
|
||||||
|
|
|
||||||
|
|
@ -24,13 +24,14 @@
|
||||||
></v-progress-linear>
|
></v-progress-linear>
|
||||||
<span class="subtitle-2">PX : </span>{{ totalXP }} ({{ Math.floor(totalXP / pc) }} par PJ)
|
<span class="subtitle-2">PX : </span>{{ totalXP }} ({{ Math.floor(totalXP / pc) }} par PJ)
|
||||||
</div>
|
</div>
|
||||||
<v-row class="d-flex align-center my-0" v-for="c in creatures">
|
<v-row class="d-flex align-center my-0" v-for="(c, idx) in creatures">
|
||||||
<v-col class="px-0 py-1">
|
<v-col class="px-0 py-1">
|
||||||
<div class="subtitle-2">{{c.title}}</div>
|
<div class="subtitle-2">{{c.title}}</div>
|
||||||
<!-- <div><span class="subtitle-2">ID : </span>{{c.frontmatter.challenge}}</div> -->
|
<!-- <div><span class="subtitle-2">ID : </span>{{c.frontmatter.challenge}}</div> -->
|
||||||
</v-col>
|
</v-col>
|
||||||
<v-col class="px-0 py-1">
|
<v-col class="px-0 py-1">
|
||||||
<v-btn dense icon small @click="removeCreatureInEncounter(c)">
|
<v-switch :value="c.ally" label="Allié" dense class="ma-0 d-inline-block" @click="switchCampCreatureInEncounter(idx)" color="accent"></v-switch>
|
||||||
|
<v-btn dense icon small @click="removeCreatureInEncounter(idx)">
|
||||||
<v-icon color="red">mdi-delete</v-icon>
|
<v-icon color="red">mdi-delete</v-icon>
|
||||||
</v-btn>
|
</v-btn>
|
||||||
</v-col>
|
</v-col>
|
||||||
|
|
@ -58,6 +59,8 @@ export default {
|
||||||
panels: [0],
|
panels: [0],
|
||||||
challenges: CHALLENGES,
|
challenges: CHALLENGES,
|
||||||
encounterLevels: ENCOUNTERLEVELS,
|
encounterLevels: ENCOUNTERLEVELS,
|
||||||
|
totalPC: 0,
|
||||||
|
totalXP: 0,
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
@ -66,9 +69,9 @@ export default {
|
||||||
creatures: state => state.encounterCalculator.creatures,
|
creatures: state => state.encounterCalculator.creatures,
|
||||||
}),
|
}),
|
||||||
|
|
||||||
...mapGetters({
|
// ...mapGetters({
|
||||||
totalPC: 'encounterCalculator/totalPC',
|
// totalPC: 'encounterCalculator/totalPC',
|
||||||
}),
|
// }),
|
||||||
|
|
||||||
pc: {
|
pc: {
|
||||||
get () {
|
get () {
|
||||||
|
|
@ -110,25 +113,30 @@ export default {
|
||||||
return {label, color}
|
return {label, color}
|
||||||
},
|
},
|
||||||
|
|
||||||
totalPC () {
|
// totalPC () {
|
||||||
let pc = 0
|
// let pc = 0
|
||||||
for (let c of this.creatures) {
|
// for (let c of this.creatures) {
|
||||||
pc += getPCbyChallenge(Number(c.frontmatter.challenge))
|
// if (c.ally) {
|
||||||
}
|
// pc -= getPCbyChallenge(Number(c.frontmatter.challenge))
|
||||||
return pc
|
// } else {
|
||||||
},
|
// pc += getPCbyChallenge(Number(c.frontmatter.challenge))
|
||||||
|
// }
|
||||||
|
// console.log(c)
|
||||||
|
// }
|
||||||
|
// return pc
|
||||||
|
// },
|
||||||
|
|
||||||
totalXP () {
|
// totalXP () {
|
||||||
let xp = 0
|
// let xp = 0
|
||||||
for (let c of this.creatures) {
|
// for (let c of this.creatures) {
|
||||||
if (c.frontmatter.challenge == 0) {
|
// if (c.frontmatter.challenge == 0) {
|
||||||
xp += 10
|
// xp += 10
|
||||||
} else {
|
// } else {
|
||||||
xp += stats.challenges[c.frontmatter.challenge].xp
|
// xp += stats.challenges[c.frontmatter.challenge].xp
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
return xp
|
// return xp
|
||||||
},
|
// },
|
||||||
|
|
||||||
challengeForGroup () {
|
challengeForGroup () {
|
||||||
let level = this.encounterLevels[this.encounterLevels.findIndex((item) => { return item.level == this.level })]
|
let level = this.encounterLevels[this.encounterLevels.findIndex((item) => { return item.level == this.level })]
|
||||||
|
|
@ -146,13 +154,62 @@ export default {
|
||||||
},
|
},
|
||||||
|
|
||||||
methods: {
|
methods: {
|
||||||
removeCreatureInEncounter (creature) {
|
removeCreatureInEncounter (idx) {
|
||||||
this.$store.commit('encounterCalculator/removeCreature', creature)
|
this.$store.commit('encounterCalculator/removeCreature', idx)
|
||||||
}
|
},
|
||||||
|
|
||||||
|
switchCampCreatureInEncounter (idx) {
|
||||||
|
this.$store.commit('encounterCalculator/switchCampCreature', idx)
|
||||||
|
this.setTotalPC()
|
||||||
|
this.setTotalXP()
|
||||||
|
},
|
||||||
|
|
||||||
|
setTotalPC () {
|
||||||
|
let pc = 0
|
||||||
|
for (let c of this.creatures) {
|
||||||
|
if (c.ally) {
|
||||||
|
pc -= getPCbyChallenge(Number(c.frontmatter.challenge))
|
||||||
|
} else {
|
||||||
|
pc += getPCbyChallenge(Number(c.frontmatter.challenge))
|
||||||
|
}
|
||||||
|
// console.log(c)
|
||||||
|
}
|
||||||
|
this.totalPC = pc
|
||||||
|
},
|
||||||
|
|
||||||
|
setTotalXP () {
|
||||||
|
let xp = 0
|
||||||
|
for (let c of this.creatures) {
|
||||||
|
if (c.frontmatter.challenge == 0) {
|
||||||
|
if (c.ally) {
|
||||||
|
xp -= 10
|
||||||
|
} else {
|
||||||
|
xp += 10
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (c.ally) {
|
||||||
|
xp -= stats.challenges[c.frontmatter.challenge].xp
|
||||||
|
} else {
|
||||||
|
xp += stats.challenges[c.frontmatter.challenge].xp
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (xp < 0) {
|
||||||
|
xp = 0
|
||||||
|
}
|
||||||
|
this.totalXP = xp
|
||||||
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
mounted () {
|
mounted () {
|
||||||
|
|
||||||
|
},
|
||||||
|
|
||||||
|
watch: {
|
||||||
|
creatures () {
|
||||||
|
this.setTotalPC()
|
||||||
|
this.setTotalXP()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue