Skip to content

Commit

Permalink
Merge branch 'esrin-dev' of https://github.com/StarWarsFoundryVTT/Sta…
Browse files Browse the repository at this point in the history
…rWarsFFG into esrin-dev

# Conflicts:
#	README.md
#	modules/items/item-sheet-ffg.js
#	package-lock.json
#	package.json
#	scss/global/_window.scss
#	styles/swffg.css
#	system.json
#	templates/actors/ffg-character-sheet.html
#	templates/actors/ffg-minion-sheet.html
#	templates/actors/ffg-vehicle-sheet.html
  • Loading branch information
Esrin committed Jun 2, 2020
2 parents 85db39c + 4722474 commit 95050e7
Show file tree
Hide file tree
Showing 23 changed files with 1,983 additions and 2,015 deletions.
42 changes: 21 additions & 21 deletions LICENSE.txt
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
MIT License

Copyright (c) 2020 Foundry Network

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
MIT License
Copyright (c) 2020 Foundry Network
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ NICE TO HAVE:

- 02/06/2020 - Esrin - Minor bugfix to character sheet, soak value set to disabled for auto-calculation, encumbrance max and current values swapped to correct fields and current set to disabled for auto-calculation.
- 02/06/2020 - CStadther - Major sheet restyling
- 02/06/2020 - Jaxxa - Added Icons in the Dice roller, visually indicating the dice types.
- 31/05/2020 - Esrin - Work in progress on the group management GM tool. Destiny Pool now working (will reset on page refresh). Player Character list under construction.
- 31/05/2020 - Esrin - Bugfix to localisation hook for Gear Quantity on Character Sheet (thanks Alex | HDScurox for the bug report).
- 31/05/2020 - CStadther - Added SASS configuration using Gulp.
Expand Down
220 changes: 110 additions & 110 deletions modules/actors/actor-ffg.js
Original file line number Diff line number Diff line change
@@ -1,110 +1,110 @@
/**
* Extend the base Actor entity.
* @extends {Actor}
*/
export class ActorFFG extends Actor {
/**
* Augment the basic actor data with additional dynamic data.
*/
prepareData() {
super.prepareData();

const actorData = this.data;
const data = actorData.data;
const flags = actorData.flags;

// Make separate methods for each Actor type (character, minion, etc.) to keep
// things organized.
if (actorData.type === "minion") this._prepareMinionData(actorData);
if (actorData.type === "character") this._prepareCharacterData(actorData);
}

/**
* Prepare Minion type specific data
*/
_prepareMinionData(actorData) {
const data = actorData.data;

// Set Wounds threshold to unit_wounds * quantity to account for minion group health.
data.stats.wounds.max = Math.floor(data.unit_wounds.value * data.quantity.value);
// Check we don't go below 0.
if (data.stats.wounds.max < 0) {
data.stats.wounds.max = 0;
}

// Loop through Skills, and where groupskill = true, set the rank to 1*(quantity-1).
for (let [key, skill] of Object.entries(data.skills)) {
// Check to see if this is a group skill, otherwise do nothing.
if (skill.groupskill) {
skill.rank = Math.floor(1 * (data.quantity.value - 1));
// Check we don't go below 0.
if (skill.rank < 0) {
skill.rank = 0;
}
} else if (!skill.groupskill) {
skill.rank = 0;
}
}
}

/**
* Prepare Character type specific data
*/
_prepareCharacterData(actorData) {
const data = actorData.data;
const items = actorData.items;
var soak = 0;
var armoursoak = 0;
var othersoak = 0;
var encum = 0;

// Calculate soak based on Brawn value, and any Soak modifiers in weapons, armour, gear and talents.
// Start with Brawn. Also calculate total encumbrance from items.
soak = +data.characteristics.Brawn.value;

for (let characteristic of Object.keys(data.characteristics)) {
const strId = `SWFFG.Characteristic${this._capitalize(characteristic)}`;
const localizedField = game.i18n.localize(strId);

data.characteristics[characteristic].label = localizedField;
}

// Loop through all items
for (let [key, item] of Object.entries(items)) {
// For armour type, get all Soak values and add to armoursoak.
if (item.type == "armour") {
armoursoak += +item.data.soak.value;
}
// Loop through all item attributes and add any modifiers to our collection.
for (let [k, mod] of Object.entries(item.data.attributes)) {
if (mod.mod == "Soak") {
othersoak += +mod.value;
}
}

// Calculate encumbrance.
if (item.type != "talent") {
encum += +item.data.encumbrance.value;
}
}

// Set Encumbrance value on character.
data.stats.encumbrance.value = encum;

// Add together all of our soak results.
soak += +armoursoak;
soak += +othersoak;

// Finally set Soak value on character.
data.stats.soak.value = soak;
}

/**
* Capitalize string
* @param {String} s String value to capitalize
*/
_capitalize(s) {
if (typeof s !== 'string') return ''
return s.charAt(0).toUpperCase() + s.slice(1)
}
}
/**
* Extend the base Actor entity.
* @extends {Actor}
*/
export class ActorFFG extends Actor {
/**
* Augment the basic actor data with additional dynamic data.
*/
prepareData() {
super.prepareData();

const actorData = this.data;
const data = actorData.data;
const flags = actorData.flags;

// Make separate methods for each Actor type (character, minion, etc.) to keep
// things organized.
if (actorData.type === "minion") this._prepareMinionData(actorData);
if (actorData.type === "character") this._prepareCharacterData(actorData);
}

/**
* Prepare Minion type specific data
*/
_prepareMinionData(actorData) {
const data = actorData.data;

// Set Wounds threshold to unit_wounds * quantity to account for minion group health.
data.stats.wounds.max = Math.floor(data.unit_wounds.value * data.quantity.value);
// Check we don't go below 0.
if (data.stats.wounds.max < 0) {
data.stats.wounds.max = 0;
}

// Loop through Skills, and where groupskill = true, set the rank to 1*(quantity-1).
for (let [key, skill] of Object.entries(data.skills)) {
// Check to see if this is a group skill, otherwise do nothing.
if (skill.groupskill) {
skill.rank = Math.floor(1 * (data.quantity.value - 1));
// Check we don't go below 0.
if (skill.rank < 0) {
skill.rank = 0;
}
} else if (!skill.groupskill) {
skill.rank = 0;
}
}
}

/**
* Prepare Character type specific data
*/
_prepareCharacterData(actorData) {
const data = actorData.data;
const items = actorData.items;
var soak = 0;
var armoursoak = 0;
var othersoak = 0;
var encum = 0;

// Calculate soak based on Brawn value, and any Soak modifiers in weapons, armour, gear and talents.
// Start with Brawn. Also calculate total encumbrance from items.
soak = +data.characteristics.Brawn.value;

for (let characteristic of Object.keys(data.characteristics)) {
const strId = `SWFFG.Characteristic${this._capitalize(characteristic)}`;
const localizedField = game.i18n.localize(strId);

data.characteristics[characteristic].label = localizedField;
}

// Loop through all items
for (let [key, item] of Object.entries(items)) {
// For armour type, get all Soak values and add to armoursoak.
if (item.type == "armour") {
armoursoak += +item.data.soak.value;
}
// Loop through all item attributes and add any modifiers to our collection.
for (let [k, mod] of Object.entries(item.data.attributes)) {
if (mod.mod == "Soak") {
othersoak += +mod.value;
}
}

// Calculate encumbrance.
if (item.type != "talent") {
encum += +item.data.encumbrance.value;
}
}

// Set Encumbrance value on character.
data.stats.encumbrance.value = encum;

// Add together all of our soak results.
soak += +armoursoak;
soak += +othersoak;

// Finally set Soak value on character.
data.stats.soak.value = soak;
}

/**
* Capitalize string
* @param {String} s String value to capitalize
*/
_capitalize(s) {
if (typeof s !== 'string') return ''
return s.charAt(0).toUpperCase() + s.slice(1)
}
}
Loading

0 comments on commit 95050e7

Please sign in to comment.