Skip to content

Commit

Permalink
Bringing branch in line with old repo.
Browse files Browse the repository at this point in the history
  • Loading branch information
Esrin authored Jun 2, 2020
1 parent af360c3 commit 4722474
Show file tree
Hide file tree
Showing 20 changed files with 7,705 additions and 7,640 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.
181 changes: 92 additions & 89 deletions README.md

Large diffs are not rendered by default.

22 changes: 17 additions & 5 deletions lang/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"SWFFG.ForcePool": "Force Pool",
"SWFFG.ForcePoolCommitted": "Committed",
"SWFFG.ForcePoolAvailable": "Available",
"SWFFG.Encumbrance": "Encum",
"SWFFG.Encumbrance": "Encumbrance",
"SWFFG.TabCharacteristics": "Characteristics",
"SWFFG.TabGear": "Gear & Equipment",
"SWFFG.TabTalents": "Talents",
Expand All @@ -25,9 +25,9 @@
"SWFFG.CharacteristicCunning": "Cunning",
"SWFFG.CharacteristicWillpower": "Willpower",
"SWFFG.CharacteristicPresence": "Presence",
"SWFFG.SkillsGeneral": "General",
"SWFFG.SkillsCombat": "Combat",
"SWFFG.SkillsKnowledge": "Knowledge",
"SWFFG.SkillsGeneral": "General Skills",
"SWFFG.SkillsCombat": "Combat Skills",
"SWFFG.SkillsKnowledge": "Knowledge Skills",
"SWFFG.SkillsName": "Name",
"SWFFG.SkillsCS": "CS",
"SWFFG.SkillsCareerSkill": "Career Skill",
Expand Down Expand Up @@ -61,5 +61,17 @@
"SWFFG.DescriptionObligation": "Obligation",
"SWFFG.DescriptionDuty": "Duty",
"SWFFG.DescriptionMorality": "Morality",
"SWFFG.DescriptionConflict": "Conflict"
"SWFFG.DescriptionConflict": "Conflict",
"SWFFG.ItemWeaponDamage": "Dmg",
"SWFFG.ItemWeaponCritical": "Crit",
"SWFFG.ItemWeaponEncumbrance": "Encum",
"SWFFG.ItemWeaponHardPoints": "HP",
"SWFFG.ItemWeaponRarity": "Rarity",
"SWFFG.ItemWeaponSkill": "Skill",
"SWFFG.ItemWeaponRange": "Range",
"SWFFG.ItemWeaponPrice": "Price",
"SWFFG.ItemWeaponQuantity": "Qty",
"SWFFG.ItemWeaponSpecial": "Special",
"SWFFG.ItemArmorDefense": "Def",
"SWFFG.ItemTalentRanked": "Ranked?"
}
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 4722474

Please sign in to comment.